Chinaunix首页 | 论坛 | 博客
  • 博客访问: 57182
  • 博文数量: 15
  • 博客积分: 1421
  • 博客等级: 上尉
  • 技术积分: 190
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-18 12:36
文章分类

全部博文(15)

文章存档

2013年(1)

2011年(4)

2010年(5)

2009年(5)

我的朋友

分类:

2011-01-06 19:40:18

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;
}






阅读(4815) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-01-07 16:56:36

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com