http://www.perlmonks.org?node_id=603867


in reply to Email With Attachment

mime lite for attachments demo:
#!/usr/bin/perl # use warnings; use strict; use MIME::Lite; use Net::SMTP; my $from = 'blee@blah.com'; my $to = 'blee@blah.com'; my $msg = MIME::Lite->new( From => $from, TO => $to, Subject => 'Testing Text Message ', Type =>'multipart/mixed', ); $msg->attach( Type =>'TEXT', Data =>"Mime message with attachment, sent with Net: +:SMTP" ); $msg->attach(Type =>'image/gif', Path =>'1.jpg', Filename =>'1.jpg', Disposition => 'attachment' ); $msg->attach(Type =>' text/tab-separated-values', Path =>'./2.csv', Filename =>'2.csv', Disposition => 'attachment' ); my $Servername = "mail.blah.com"; my $smtp = Net::SMTP->new($Servername); $smtp->mail($from); $smtp->to($to); my $msg_stringified = $msg->as_string(); $smtp -> data( $msg_stringified ) || warn("error sending email message +:" . $msg_stringified ); $smtp -> quit;