2

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.

  • 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 'SO- stop being evil' 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
2

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";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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