SUMMARY: Sending E-Mail With Attachments From A Script - Addendum

From: Dave Warchol <>
Date: Mon Mar 24 2003 - 08:17:00 EST
I ended up getting several more responses after I had posted the
summary, so I decided to include them in this addendum.  

I received several kudos for the summary, those really belong to
everyone who took the time to respond with suggestions.......

I did not try every approach that was suggested.  What I did do (and
what worked just fine) was
to load mutt and use it from the command line as suggested.

>From Adam Ronthal:

I've used mpack to do this in the past.  You'll have to compile from 
source, but it runs fine on solaris. 
>From John Timon:

The key is in the MIME header

You need to include these two
Content-Type: multipart/mixed; boundary="---some arbitrary text --"

Then uuencode the attachment and append it to the end of the message
the boundary text as a separator between it and the actual message.
>From  Bendriss Elmehdi:

i think you should have a look at uuencode and uudecode witch convert a
file to a standard format known by win and *nix (this is uuencode) and
you can have the file back with uudecode (c the man page)

>From Matt Garrett:

I did not see your original request , sorry
If you are doing this from perl then have a look at MIME::Entity 
It allows to send all sorts of files e.g csv Excel files etc
Small snippet of perl code

use MIME::Entity ;
my $email_addrs = "Matt.M.Garrett\";
my $header = "Nagios Availability Report \nDouble click to open and
my $subject = "Nagios Availability report .";
my $mail = MIME::Entity->build(
                                Subject => $subject,
                                To => $email_addrs,
                                Type    => 'text/plain',
                                Encoding => '7bit',
                                Data    => $header) ;

 $mail->attach(Encoding => 'base64',
                Type    => 'application/msexcel',
                Description => 'Nagios Availability',
                Disposition => 'attachment',
                Filename => 'Nagios.CSV',
                Data    => \@avail );

 $mail->send('sendmail') ; 


Thanks Again,
sunmanagers mailing list
Received on Mon Mar 24 08:21:09 2003

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:07 EST