2012年6月12日 星期二

Perl MIME::LITE with attachement

Reference: http://www.akadia.com/services/email_attachments_using_perl.html

use MIME::Lite;
MIME::Lite->send('smtp', $mail_host, Debug=>0, Timeout=>60);

$msg = MIME::Lite->new(
From     => $mail_from,
To       => $mail_to,
Bcc       => $mail_bcc,
Subject  => $mail_subject,
Type     =>'multipart/mixed',
 Data => "Please check the attached file."
) or die "Error creating multipart container: $!\n";

$msg->attach (
Type => 'application/excel',
Path => $your_file,
Filename => $filename,
Disposition => 'attachment'
) or die "Error adding $filename: $!\n";

$msg->send();

沒有留言:

張貼留言