所以。
我无法从我的 Perl 脚本发送邮件。这就是我的代码的样子:
use Net::SMTP;
$smtp = Net::SMTP->new("smtpserver.mydomain.com");
$smtp->mail("myemail\@mydomain.com");
$smtp->to("myemail\@mydomain.com");
$smtp->data();
$smtp->datasend("From: myemail\@mydomain.com\n");
$smtp->datasend("To: myemail\@mydomain.com\n");
$smtp->datasend("Subject: Test message\n");
$smtp->datasend("Just a test message.\n");
$smtp->dataend();
$smtp->quit;
这是调试选项抛出的内容:
Net::SMTP>>> Net::SMTP(2.31)
Net::SMTP>>> Net::Cmd(2.29)
Net::SMTP>>> Exporter(5.64_03)
Net::SMTP>>> IO::Socket::INET(1.31)
Net::SMTP>>> IO::Socket(1.32)
Net::SMTP>>> IO::Handle(1.31)
Net::SMTP=GLOB(0x1d1a06c)<<< 220 ESMTP Postfix
Net::SMTP=GLOB(0x1d1a06c)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x1d1a06c)<<< 250-
Net::SMTP=GLOB(0x1d1a06c)<<< 250-PIPELINING
Net::SMTP=GLOB(0x1d1a06c)<<< 250-SIZE
Net::SMTP=GLOB(0x1d1a06c)<<< 250-ETRN
Net::SMTP=GLOB(0x1d1a06c)<<< 250-STARTTLS
Net::SMTP=GLOB(0x1d1a06c)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP=GLOB(0x1d1a06c)<<< 250-8BITMIME
Net::SMTP=GLOB(0x1d1a06c)<<< 250 DSN
Net::SMTP=GLOB(0x1d1a06c)>>> MAIL FROM:<myemail@mydomain.com>
Net::SMTP=GLOB(0x1d1a06c)<<< 250 2.1.0 Ok
Net::SMTP=GLOB(0x1d1a06c)>>> RCPT TO:<myemail@mydomain.com>
Net::SMTP=GLOB(0x1d1a06c)<<< 450 4.7.1 <localhost.localdomain>: Helo command rejected: Service temporarily unavailable
Net::SMTP=GLOB(0x1d1a06c)>>> DATA
Net::SMTP=GLOB(0x1d1a06c)<<< 554 5.5.1 Error: no valid recipients
Net::SMTP=GLOB(0x1d1a06c)>>> From: myemail@mydomain.com
Net::SMTP=GLOB(0x1d1a06c)>>> To: myemail@mydomain.com
Net::SMTP=GLOB(0x1d1a06c)>>> Subject: Test message
Net::SMTP=GLOB(0x1d1a06c)>>> Just a test message.
Net::SMTP=GLOB(0x1d1a06c)>>> .
Net::SMTP=GLOB(0x1d1a06c)<<< 221 2.7.0 Error: I can break rules, too. Goodbye.
Net::SMTP=GLOB(0x1d1a06c)>>> QUIT
有趣的是,当我直接与 SMTP 服务器交谈时,它会回复 250 OK 并且我可以正常接收邮件:
220 ESMTP Postfix
MAIL FROM:<myemail@mydomain.com>
250 2.1.0 Ok
RCPT TO:<myemail@mydomain.com>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Just a test message.
.
250 2.0.0 Ok: queued as B68672C02B
有人有一些光亮吗?
提前致谢。