Skip navigation.
Your source for Perl tips, howto's, faq and tutorials
( categories: )

To send mail with attachments, create a multipart message using MIME::Lite module.


use MIME::Lite;
$body_msg = "Message body ... Attachments included\n\n";
$msg = MIME::Lite->new(To => test@localhost, Subject => 'test message,
              Type => 'multipart/mixed');
#-- body message
$msg->attach(Type => 'TEXT', Data => $body_msg);
#-- attach the file (be sure to specify the correct MIME type)
$msg->attach(Type => 'application/pdf', Path => 'file.pdf',
             Filename => 'file.pdf', Disposition => 'attachment');
#-- send the message