我使用的Symfony + SwiftMailer和SwiftMailer得到以下错误:为什么SwiftMailer抛出“内部服务器错误”?
500 | Internal Server Error | Swift_TransportException
Expected response code 220 but got code "", with message ""
,不能找出原因。我使用hMailServer我的本地机器上,并且有安装我的factories.yml文件的文件(如我使用的Symfony)如下:
mailer:
class: sfMailer
param:
logging: %SF_LOGGING_ENABLED%
charset: %SF_CHARSET%
delivery_strategy: realtime
transport:
class: Swift_SmtpTransport
param:
host: splodge.loc
port: 25
encryption: ~
username: ~
password: ~
我用下面的代码来发送:
$message = $this->getMailer()->compose(
'[email protected]',
'[email protected]',
'Reset Password',
'Message'
);
$result = $this->getMailer()->send($message);
有没有人有过这样的问题?
我发现有时和非常随机的发送过程中,但每隔一段时间,我都会收到上述错误消息。因此,不断刷新发送邮件的页面,不可预知地失败,并且随着代码有时起作用,很难弄清楚什么是错误的。
任何帮助将不胜感激!
进一步的调查表明,SMTP服务器并发送[220本地主机ESMTP],但考虑看看hMailServer登录后,我发现了以下内容:
"TCPIP" 5232 "2010-06-16 11:40:54.043" "TCPConnection - Posting AcceptEx on 0.0.0.0:25"
"DEBUG" 5232 "2010-06-16 11:40:54.043" "Creating session 51"
"SMTPD" 5232 51 "2010-06-16 11:40:54.043" "127.0.0.1" "SENT: 220 localhost ESMTP"
"DEBUG" 5296 "2010-06-16 11:40:54.199" "The read operation failed. Bytes transferred: 0 Remote IP: 127.0.0.1, Session: 51, Code: 10054, Message: An existing connection was forcibly closed by the remote host"
"DEBUG" 5296 "2010-06-16 11:40:54.199" "Ending session 51"
难道说SwiftMailer是HELO/EHLOing太早了,这只是一个时间问题?我可以延迟HELO传输吗?
的上等原木,当事情实际上发送如下所示:
"TCPIP" 5232 "2010-06-16 11:42:21.278" "TCPConnection - Posting AcceptEx on 0.0.0.0:25"
"DEBUG" 5232 "2010-06-16 11:42:21.294" "Creating session 54"
"SMTPD" 5232 54 "2010-06-16 11:42:21.294" "127.0.0.1" "SENT: 220 localhost ESMTP"
"SMTPD" 5224 54 "2010-06-16 11:42:21.294" "127.0.0.1" "RECEIVED: EHLO splodge.loc"
所以它必须与HELO/EHLO确认的事情。请指教! :)
问题可能在于您的主机。你为什么不尝试Gmail,看看你是否遇到同样的问题。 – Dziamid 2011-06-11 13:06:57