使用Net::SMTP::TLS待账号认证发邮件:
# cpan Net::SMTP::TLS
# vi mail.pl
#!/usr/bin/perl -w
use Net::SMTP::TLS;
my $subject = 'Test mail';
my $header = << "MAILHEADER";
Content-Type:text/plain;charset="UTF-8"
MAILHEADER
my $body = << "EOF";
Hi Zhi
hello
EOF
my $mailer = new Net::SMTP::TLS(
'smtp.ming.com',
Hello => 'ming.com',
Port => 587, #redundant
User => 'zhi.yang',
Password=> 'xxxxx');
$mailer->mail('zhi.yang@ming.com');
$mailer->to('ming.yang@ming.com');
$mailer->data();
$mailer->datasend("Subject:" . $subject . "\n");
$mailer->dataend("$header\n\n");
$mailer->dataend("$body\n\n");
$mailer->dataend();
$mailer->quit;
:wq
# perl mail.pl
本文转自linux博客51CTO博客,原文链接http://blog.51cto.com/yangzhiming/1935112如需转载请自行联系原作者
yangzhimingg