N久写过的一个小程序可以用126的邮箱来发送邮件,今天突然要用到,一执行发现一大堆问题,后来发现原来是缺少了几个模块,今天特地记下来以备后需。
刚开始执行的时候一直出现一下错误:
Net::SMTP=GLOB(0x8e96e18)>>> MAIL FROM: Net::SMTP=GLOB(0x8e96e18)<<< 553 authentication is required,smtp5,jtKowLCrPZ+tpSVNNf4VAA--.4665S2 1294312877 Net::SMTP=GLOB(0x8e96e18)>>> RCPT TO: Net::SMTP=GLOB(0x8e96e18)<<< 503 bad sequence of commands Net::SMTP=GLOB(0x8e96e18)>>> DATA Net::SMTP=GLOB(0x8e96e18)<<< 503 bad sequence of commands Net::SMTP=GLOB(0x8e96e18)>>> To: hello@gmail.com Net::SMTP=GLOB(0x8e96e18)>>> Subject: A message from server Net::SMTP=GLOB(0x8e96e18)>>> This is just to let you know Net::SMTP=GLOB(0x8e96e18)>>> The flight is coming, Please check it out on time. Net::SMTP=GLOB(0x8e96e18)>>> . Net::SMTP=GLOB(0x8e96e18)<<< 502 Error: command not implemented Net::SMTP=GLOB(0x8e96e18)>>> QUIT Net::SMTP=GLOB(0x8e96e18)<<< 502 Error: command not implemented
|
主要还是那一句:553 authentication is required,smtp5,
大致意思说认证的时候出问题,经过一番搜索发现得额外安装模块: Authen::SASL
到perl网站上去下载来装上应该就木有问题了,
顺便把脚本发上来吧,有需要的哥们也可做个参考:
#!/usr/bin/perl -w
use strict;
use Net::SMTP;
my $to = 'toMail';
my $from = 'fromMail';
my $site = 'mail.126.com';
my $smtp_host = 'smtp.126.com';
my $pop_host = 'pop3.126.com';
my $username = "userName";
my $password = "password";
&writeAMesg;
sub writeAMesg{
my $smtp = Net::SMTP->new( $smtp_host, Timeout=>60, Debug=>1 );
$smtp->auth($username, $password);
$smtp->mail( $from );
$smtp->to( $to );
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("Subject: A message from server\n");
$smtp->datasend("\n");
$smtp->datasend("This is just to let you know\n");
$smtp->datasend("The flight is coming, Please check it out on time.\n");
$smtp->datasend("\n");
$smtp->dataend();
$smtp->quit;
}
|
阅读(4851) | 评论(1) | 转发(0) |