代码之家  ›  专栏  ›  技术社区  ›  josef.van.niekerk

为什么SwiftMailer抛出“内部服务器错误”?

  •  1
  • josef.van.niekerk  · 技术社区  · 14 年前

    我正在使用Symfony+SwiftMailer并从SwiftMailer得到以下错误:

    500 | Internal Server Error | Swift_TransportException
    Expected response code 220 but got code "", with message ""
    

      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);
    

    以前有人遇到过这样的问题吗?

    任何帮助都将不胜感激!


    "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太早了,而这仅仅是一个时间问题?我能把直升机的传送延迟一点吗?

    "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"
    

    因此,这与直升机/EHLO确认有关。请告知!:)

    3 回复  |  直到 14 年前
        1
  •  2
  •   timdev    14 年前

    听起来像是SMTP问题。

    如果从命令行尝试以下操作,会发生什么情况:

    telnet splodge.loc 25

    你能接通吗?回复行是以220开头的吗?

        2
  •  0
  •   josef.van.niekerk    14 年前

    通过创建一个重试邮件发送的循环来实现这一点。。。

    $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);
    

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

        3
  •  0
  •   john    13 年前

    我只是想补充一下。对我来说,问题是当我的smtp服务器重新启动时,dovecot没有恢复。我刚开始多佛科特,一切都很好。所以最后它是一个smtp问题,所以如果其他人有这个问题,你可以几乎肯定这是一个smtp问题。