免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3300 | 回复: 9
打印 上一主题 下一主题

net smtp发邮件疑问 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-06-27 14:15 |只看该作者 |倒序浏览
我用以下代码发邮件,出现奇怪错误,以前都是正常的,麻烦各位帮忙看看,谢谢!
#!/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;

DEBUG出来结果如下:
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:<from@163.com>
Net::SMTP=GLOB(0x183631c)<<< 553 authentication is required,smtp10,DsCowLCLvwBqt
0VKfc3kKw--.28997S2 1246082922
Net::SMTP=GLOB(0x183631c)>>> RCPT TO:<to@qq.com>
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: myxiangshi@qq.com
Net::SMTP=GLOB(0x183631c)>>> From: myxiangshi@163.com
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


我保证用户名和密码没错,请各位帮忙分析一下,谢谢!

[ 本帖最后由 小公猫 于 2009-6-27 14:19 编辑 ]

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
2 [报告]
发表于 2009-06-27 14:22 |只看该作者
你机器上缺个模块。
$smtp->auth('user','pass') or die;

看看。

安装一下 Authen::SASL 再试试。

[ 本帖最后由 flw 于 2009-6-27 14:24 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2009-06-27 16:40 |只看该作者
原帖由 flw 于 2009-6-27 14:22 发表
你机器上缺个模块。
$smtp->auth('user','pass') or die;

看看。

安装一下 Authen::SASL 再试试。


老大就是老大,我爱你~ 亲!

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
4 [报告]
发表于 2009-06-27 16:50 |只看该作者
原帖由 小公猫 于 2009-6-27 16:40 发表

老大就是老大,我爱你~ 亲!

这也主要是由于你懂得如何提问。
有源代码,有 debug 输出,基本上精通 SMTP 并且用过 Net::SMTP 模块的人都会一眼看出问题来。

论坛徽章:
0
5 [报告]
发表于 2009-09-24 12:31 |只看该作者
我在安装Authen-SASL时出错,网上google也没找到解决办法,请各位老大指点,谢谢啊。



Searching krb5-config command... NOT FOUND!

seems this is a missing prerequirement.
The README file shipped with this module provides
more information regarding prerequirements.

论坛徽章:
0
6 [报告]
发表于 2009-09-24 14:55 |只看该作者
原帖由 gaochong 于 2009-9-24 12:31 发表
我在安装Authen-SASL时出错,网上google也没找到解决办法,请各位老大指点,谢谢啊。



Searching krb5-config command... NOT FOUND!

seems this is a missing prerequirement.
The README file sh ...


缺少prerequirement

论坛徽章:
0
7 [报告]
发表于 2009-09-24 21:21 |只看该作者
真是头大啊。


怎么能解决呢?

论坛徽章:
0
8 [报告]
发表于 2009-09-24 21:33 |只看该作者
原帖由 gaochong 于 2009-9-24 21:21 发表
真是头大啊。


怎么能解决呢?


我记得CPAN上有一个先决模块的列表,你把那些都装上试试

论坛徽章:
0
9 [报告]
发表于 2009-09-25 17:36 |只看该作者
你当时有没有遇到这个问题?


怎么找到这个模块列表呢?


谢谢啦。

论坛徽章:
0
10 [报告]
发表于 2009-09-26 12:35 |只看该作者
原帖由 gaochong 于 2009-9-25 17:36 发表
你当时有没有遇到这个问题?


怎么找到这个模块列表呢?


谢谢啦。

http://deps.cpantesters.org/?module=Net::SMTP;perl=latest
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP