#!/usr/bin/perl
use Mail::Sender;
#new一个sender,定义编码格式防止乱码
my $sender = new Mail::Sender{
ctype => 'text/plain; charset=utf-8',
encoding => 'utf-8',
};
#die "Error in mailing : $Mail::Sender::Error\n" unless ref $sender;
if ($sender->MailFile({
smtp => '127.0.0.1',#hostname or ip
from => 'yourmail@qq.com',
to =>'someonemail@qq.com',
subject => 'this is a test',
msg => "Hi all.\nHow are you? 这是测试信息! skip it! ",
auth => 'LOGIN',#验证方式
authid => 'user',
authpwd => 'pwd',
file=>'perl_mail.pl',#添加附件
# charset=>'gb2312'
}) < 0) {
die "$Mail::Sender::Error\n";
}
$sender->Close();
print "Mail sent OK.";
转载于:https://my.oschina.net/suzm/blog/341533