分类: Python/Ruby
2012-01-31 14:58:20
#!/usr/bin/perl use Net::SMTP; my $mailhost = "smtp.163.com"; # the smtp host my $mailfrom = [email=]'from@163.com'[/email]; # your email address my @mailto = ([email=]'to@qq.com'[/email]); # the recipient list my $subject = "此为标题"; my $text = "此为正文\n第二行位于此。"; my $smtp = Net::SMTP->new($mailhost, Hello => 'localhost', Timeout => 120, Debug => 1); # anth login, type your user name and password here $smtp->auth('user','pass'); #用户名和密码确定没错 foreach my $mailto (@mailto) { # Send the From and Recipient for the mail servers that require it $smtp->mail($mailfrom); $smtp->to($mailto); # Start the mail $smtp->data(); # Send the header $smtp->datasend("To: $mailto\n"); $smtp->datasend("From: $mailfrom\n"); $smtp->datasend("Subject: $subject\n"); $smtp->datasend("\n"); # Send the message $smtp->datasend("$text\n\n"); # Send the termination string $smtp->dataend(); } $smtp->quit; |
Net::SMTP>>> Net::SMTP(2.31)
Net::SMTP>>> Net::Cmd(2.29)
Net::SMTP>>> Exporter(5.62)
Net::SMTP>>> IO::Socket::INET(1.31)
Net::SMTP>>> IO::Socket(1.30_01)
Net::SMTP>>> IO::Handle(1.27)
Net::SMTP=GLOB(0x183631c)<<< 220 163.com Anti-spam GT for Coremail System (163co
m[20081010])
Net::SMTP=GLOB(0x183631c)>>> EHLO localhost
Net::SMTP=GLOB(0x183631c)<<< 250-mail
Net::SMTP=GLOB(0x183631c)<<< 250-PIPELINING
Net::SMTP=GLOB(0x183631c)<<< 250-AUTH LOGIN PLAIN
Net::SMTP=GLOB(0x183631c)<<< 250-AUTH=LOGIN PLAIN
Net::SMTP=GLOB(0x183631c)<<< 250 8BITMIME
Net::SMTP=GLOB(0x183631c)>>> MAIL FROM:<>
Net::SMTP=GLOB(0x183631c)<<< 553 authentication is required,smtp10,DsCowLCLvwBqt
0VKfc3kKw--.28997S2 1246082922
Net::SMTP=GLOB(0x183631c)>>> RCPT TO:<>
Net::SMTP=GLOB(0x183631c)<<< 503 bad sequence of commands
Net::SMTP=GLOB(0x183631c)>>> DATA
Net::SMTP=GLOB(0x183631c)<<< 503 bad sequence of commands
Net::SMTP=GLOB(0x183631c)>>> To:
Net::SMTP=GLOB(0x183631c)>>> From: example
Net::SMTP=GLOB(0x183631c)>>> Subject: 此为标题
Net::SMTP=GLOB(0x183631c)>>> 此为正文
Net::SMTP=GLOB(0x183631c)>>> 第二行位于此。
Net::SMTP=GLOB(0x183631c)>>> .
Net::SMTP=GLOB(0x183631c)<<< 502 Error: command not implemented
Net::SMTP=GLOB(0x183631c)>>> QUIT
Net::SMTP=GLOB(0x183631c)<<< 502 Error: command not implemented
解决方案:安装一下 Authen::SASL模块