我试图从一个Perl脚本发送一封电子邮件,但我连接到我的SMTP服务器的时间很糟糕。我正在使用MailCatcher- https://github.com/sj26/mailcatcher/ - 使用默认设置(localhost:1025)运行。Perl Mail :: Sendmail无法连接到SMTP服务器
MailCatcher正在运行,我可以通过其他服务向其发送邮件。任何可能出错的线索? (还试图发送一个带有网:: SMTP邮件,但还未能连接)
print "Testing Mail::Sendmail version $Mail::Sendmail::VERSION\n";
my %mail = (
To => '[email protected]',
From => '[email protected]',
Subject => 'Test message'
);
$mail{server} = 'localhost:1025';
$mail{'mESSaGE : '} = "The message key looks terrible, but works.";
print Dumper(%mail);
if (sendmail %mail) { print "Mail sent OK.\n" }
else { print "Error sending mail: $Mail::Sendmail::error \n" }
输出
Testing Mail::Sendmail version 0.79
Default server: localhost
Default sender:
$VAR1 = 'Subject';
$VAR2 = 'Test message';
$VAR3 = 'server';
$VAR4 = 'localhost:1025';
$VAR5 = 'To';
$VAR6 = '[email protected]';
$VAR7 = 'message : ';
$VAR8 = 'The message key looks terrible, but works.';
$VAR9 = 'From';
$VAR10 = '[email protected]';
Error sending mail: connect to localhost failed (Connection refused)
connect to localhost failed
connect to localhost failed (Connection refused)
connect to localhost failed
connect to localhost failed (Connection refused) no (more) retries!
编辑:
原来mailcatcher被另一个端口和WASN上运行”当我试图在25上启动它时发出错误。
1025端口?不是25? – 2012-07-17 17:30:41
默认情况下,MailCatcher在1025上运行SMTP服务器 – Marklar 2012-07-18 07:26:41