+ -
当前位置:首页 → 问答吧 → perl发送连续多封邮件的问题

perl发送连续多封邮件的问题

时间:2010-12-22

来源:互联网

本帖最后由 cxw06023273 于 2010-12-22 18:53 编辑

我用perl写了一个发送多封邮件的程序,但是发送完第一封之后,就出现了错误:
  1. [root@xmntc smtp_send]# perl sendmail.pl
  2. /log/smtp/send/192.168.3.6_1301.eml
  3. user = [email protected]
  4. host = smtp.126.com
  5. to = [email protected]
  6. subject = Subject: 99999999999999999999999999999999
  7. #上面部分是自己调试用的
  8. Net::SMTP>>> Net::SMTP(2.31)
  9. Net::SMTP>>>   Net::Cmd(2.29)
  10. Net::SMTP>>>     Exporter(5.62)
  11. Net::SMTP>>>   IO::Socket::INET(1.31)
  12. Net::SMTP>>>     IO::Socket(1.30_01)
  13. Net::SMTP>>>       IO::Handle(1.27)
  14. Net::SMTP=GLOB(0x14519b0)<<< 220 126.com Anti-spam GT for Coremail System (126com[20101010])
  15. Net::SMTP=GLOB(0x14519b0)>>> EHLO smtp.126.com
  16. Net::SMTP=GLOB(0x14519b0)<<< 250-mail
  17. Net::SMTP=GLOB(0x14519b0)<<< 250-PIPELINING
  18. Net::SMTP=GLOB(0x14519b0)<<< 250-AUTH LOGIN PLAIN
  19. Net::SMTP=GLOB(0x14519b0)<<< 250-AUTH=LOGIN PLAIN
  20. Net::SMTP=GLOB(0x14519b0)<<< 250-coremail 1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2Ur3x9o8UCa0xDrUUUUj
  21. Net::SMTP=GLOB(0x14519b0)<<< 250-STARTTLS
  22. Net::SMTP=GLOB(0x14519b0)<<< 250 8BITMIME
  23. Net::SMTP=GLOB(0x14519b0)>>> AUTH LOGIN
  24. Net::SMTP=GLOB(0x14519b0)<<< 334 dXNlcm5hbWU6
  25. Net::SMTP=GLOB(0x14519b0)>>> Y3h3MDYwMjMyNzNAMTI2LmNvbQ==
  26. Net::SMTP=GLOB(0x14519b0)<<< 334 UGFzc3dvcmQ6
  27. Net::SMTP=GLOB(0x14519b0)>>> MDYwMjMyNzM=
  28. Net::SMTP=GLOB(0x14519b0)<<< 235 Authentication successful
  29. Net::SMTP=GLOB(0x14519b0)>>> MAIL FROM:<[email protected]>
  30. Net::SMTP=GLOB(0x14519b0)<<< 250 Mail OK
  31. Net::SMTP=GLOB(0x14519b0)>>> RCPT TO:<[email protected]>
  32. Net::SMTP=GLOB(0x14519b0)<<< 250 Mail OK
  33. Net::SMTP=GLOB(0x14519b0)>>> DATA
  34. Net::SMTP=GLOB(0x14519b0)<<< 354 End data with <CR><LF>.<CR><LF>
  35. Net::SMTP=GLOB(0x14519b0)>>> From:[email protected]
  36. Net::SMTP=GLOB(0x14519b0)>>> To:[email protected]
  37. Net::SMTP=GLOB(0x14519b0)>>> Subject: 99999999999999999999999999999999
  38. Net::SMTP=GLOB(0x14519b0)>>> Content-Transfer-Encoding: 7bit
  39. Net::SMTP=GLOB(0x14519b0)>>>
  40. Net::SMTP=GLOB(0x14519b0)>>> 9999999999999999999999999999999999999999999999999999999999999999999999999999
  41. Net::SMTP=GLOB(0x14519b0)>>> 9
  42. Net::SMTP=GLOB(0x14519b0)>>>
  43. Net::SMTP=GLOB(0x14519b0)>>> 9999999999999999999999999999999999999999999999999999999999999999999999999999
  44. Net::SMTP=GLOB(0x14519b0)>>> 9
  45. Net::SMTP=GLOB(0x14519b0)>>>
  46. Net::SMTP=GLOB(0x14519b0)>>> 9999999999999999999999999999999999999999999999999999999999999999999999999999
  47. Net::SMTP=GLOB(0x14519b0)>>> 9
  48. Net::SMTP=GLOB(0x14519b0)>>>
  49. Net::SMTP=GLOB(0x14519b0)>>> 9999999999999999999999999999999999999999999999999999999999999999999999999999
  50. Net::SMTP=GLOB(0x14519b0)>>> 9
  51. Net::SMTP=GLOB(0x14519b0)>>>
  52. Net::SMTP=GLOB(0x14519b0)>>> 9999999999999999999999999999999999999999999999999999999999999999999999999999
  53. Net::SMTP=GLOB(0x14519b0)>>> 9
  54. Net::SMTP=GLOB(0x14519b0)>>>
  55. Net::SMTP=GLOB(0x14519b0)>>> 9999999999999999999999999999999999999999999999999999999999999999999999999999
  56. Net::SMTP=GLOB(0x14519b0)>>> 9
  57. Net::SMTP=GLOB(0x14519b0)>>>
  58. Net::SMTP=GLOB(0x14519b0)>>> 9999999999999999999999999999999999999999999999999999999999999999999999999999
  59. Net::SMTP=GLOB(0x14519b0)>>> 9
  60. Net::SMTP=GLOB(0x14519b0)>>>
  61. Net::SMTP=GLOB(0x14519b0)>>> 9999999999999999999999999999999999999999999999999999999999999999999999999999
  62. Net::SMTP=GLOB(0x14519b0)>>> 9
  63. Net::SMTP=GLOB(0x14519b0)>>>
  64. Net::SMTP=GLOB(0x14519b0)>>> 9999999999999999999999999999999999999999999999999999999999999999999999999999
  65. Net::SMTP=GLOB(0x14519b0)>>> 9
  66. Net::SMTP=GLOB(0x14519b0)>>>
  67. Net::SMTP=GLOB(0x14519b0)>>> 9999999999999999999999999999999999999999999999999999999999999999999999999999
  68. Net::SMTP=GLOB(0x14519b0)>>> 9
  69. Net::SMTP=GLOB(0x14519b0)>>>
  70. Net::SMTP=GLOB(0x14519b0)>>> 9999999999999999999999999999999999999999999999999999999999999999999999999999
  71. Net::SMTP=GLOB(0x14519b0)>>> 9
  72. Net::SMTP=GLOB(0x14519b0)>>>
  73. Net::SMTP=GLOB(0x14519b0)>>> 9999999999999999999999999999999999999999999999999999999999999999999999999999
  74. Net::SMTP=GLOB(0x14519b0)>>> 9
  75. Net::SMTP=GLOB(0x14519b0)>>>
  76. Net::SMTP=GLOB(0x14519b0)>>> 9999999999999999999999999999999999999999999999999999999999999999999999999999
  77. Net::SMTP=GLOB(0x14519b0)>>> 9
  78. Net::SMTP=GLOB(0x14519b0)>>>
  79. Net::SMTP=GLOB(0x14519b0)>>> 9999999999999999999999999999999999999999999999999999999999999999999999999999
  80. Net::SMTP=GLOB(0x14519b0)>>> 9
  81. Net::SMTP=GLOB(0x14519b0)>>>
  82. Net::SMTP=GLOB(0x14519b0)>>>  
  83. Net::SMTP=GLOB(0x14519b0)>>>
  84. Net::SMTP=GLOB(0x14519b0)>>>
  85. Net::SMTP=GLOB(0x14519b0)>>> .
  86. Net::SMTP=GLOB(0x14519b0)<<< 250 Mail OK queued as smtp3,DcmowLAbH5RT1hFN1OzlAQ--.1235S2 1293014611
  87. Net::SMTP=GLOB(0x14519b0)>>> QUIT
  88. Net::SMTP=GLOB(0x14519b0)<<< 221 Bye
  89. /log/smtp/send/192.168.3.6_2440.eml
  90. user = [email protected]
  91. host = smtp.126.com
  92. to = [email protected]
  93. err smtp fault!
  94. [root@xmntc smtp_send]#
复制代码
在我的一个文件夹内有多封的eml格式的邮件读取后,用我写的发送程序依次发送,但是出现没发送一封邮件之后就出现上面的错误,指示错误部分的代码如下:
  1. sub sendmail
  2. {       
  3.         my $smtp = Net::SMTP->new(
  4.                 Hello => $_[0],
  5.                 Host => $_[0],
  6.                 LocalPort => 2500,
  7.                 Timeout => 120,
  8.                 Debug => 1
  9.                 ) or die "err smtp fault!\n";
  10.        
  11.         $smtp->auth($_[1], $_[3]);
  12.        
  13.         $smtp->mail($_[1]);
  14.         $smtp->to($_[2]);
  15.        
  16.         $smtp->data();

  17.         $smtp->datasend("From:$_[1]");
  18.         $smtp->datasend("\n");
  19.         $smtp->datasend("To:$_[2]");
  20.         $smtp->datasend("\n");
  21.         $smtp->datasend($_[4]);
  22.        
  23.         #发送邮件内容
  24.         $smtp->datasend($_[5]);
  25.         $smtp->dataend();
  26.        
  27.         $smtp->quit();
  28. }
复制代码
我怀疑是发送后端口被占用,但是$smtp是局部变量啊,这说不通啊。。。。
欢迎大家提出宝贵的意见,谢了,初学perl,请大家多多指教。。。。。
另外这次没法出去,停几秒钟,运行perl脚本就发出去了,这是怎么回事呢?。。。。。

作者: cxw06023273   发布时间: 2010-12-22

perl高手呢。。。。。。。。
不要潜水了。。。。。

作者: cxw06023273   发布时间: 2010-12-23

有个 Mail::Sender 很简单,这个没用过

作者: zhlong8   发布时间: 2010-12-23

不要绑定本地端口

作者: flw   发布时间: 2010-12-23