我使用的Symfony + 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(
    'noreply@splodge.loc',
    'info@splodge.loc',
    '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确认做。请指教! :)

有帮助吗?

解决方案 2

通过创建一个循环,重试邮件发送

好不容易才得到这个工作...

$sendResult = false;
do
{
    try
    {
        $message = Swift_Message::newInstance()
            ->setFrom('noreply@splodge.loc', 'Mr.Postman')
            ->setTo($to)
            ->setSubject('Password reminder...')
            ->setBody($this->getPartial('resetPasswordEmail', array(
                'newPassword' => $newPassword)), 'text/html');
        $sendResult = $this->getMailer()->send($message);
    }
    catch(Exception $e){/*Do nothing*/}
}
while($sendResult !== 1);

接下来,我将添加一些配置设置,以限制重试的次数。

其他提示

声音等的SMTP问题。

如果您尝试从发生在命令行中输入以下内容:

telnet splodge.loc 25

您可以连接?是否答复线开始与220?

如果没有,那么你有一个问题,您的SMTP服务器(或者防火墙)的配置。

我只是想添加到这一点。我的问题是,当我的SMTP服务器重启,达夫科特没有回来了。只要我一开始dovecot的,一切都很好。所以它到底是一个SMTP问题,因此,如果任何人有这个问题,你几乎可以肯定它是一个SMTP的问题。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top