使用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