Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm right now working with a script for emailing attachment (.png pics). Since I'm using mutt command with -a option, the email is sent as a mail attachment.

I want these .png pictures to be mailed inline with the mail body. How can I implement this with a bash script?

I had also tried with the mail command and the result was the same. Also I would like to have any ideas on this if it can be done with a Perl script.

share|improve this question
    
What do you mean by “inline”? An attachment is what happens when you send more than one piece of data in an e-mail, e.g. some text and a picture. Is the body text? HTML? –  Gilles Nov 23 '12 at 23:34
    
Term inline was used here because currenlty when I sent this email with .png picture attachments ,for all email client ,it would require to download all my .png picture to view them.what I really need is pictures to be present along with email body so that when someone open the email,he could see the pic displayed without downloading .(These png pictures are all server monitoring graphs) –  Kratos Nov 26 '12 at 7:35
add comment

1 Answer

By default mutt will label all non-text attachments and images as Content-Disposition: attachment - You can change this setting using Content-Disposition: inline

Set your .muttrc like this:

set attach_format="%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "

(%I is for inline , the other options are document in the manual : http://linux.die.net/man/5/muttrc )

Alternatively, this Perl script might help you :

 #!/usr/bin/perl -w
 use strict;
 use Mail::Sender;

 my $sender;

 ref ($sender = new Mail::Sender({from => 'you@xxxxxxxxxxx',
                                  smtp => 'your.smtp.server'})) 
        or die "$Mail::Sender::Error\n";

 ref ($sender->MailFile({to =>'address@xxxxxxxxxx',
                         msg=>"Here's your daily image\r\n\r\n", 
                         subject => 'Daily image',
                         file => 'image.gif',
                         disposition => 'inline'}))
        or die "$Mail::Sender::Error\n";
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.