【问题标题】:SwiftMail SMTP ErrorSwiftMail SMTP 错误
【发布时间】:2013-03-16 23:08:12
【问题描述】:

我正在尝试为 Mandrill 使用标准 Swiftmail SMTP 连接,该连接位于此处:

http://help.mandrill.com/entries/21746308-Sending-via-SMTP-in-various-programming-languages

我得到一个:

Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.mandrillapp.com [Connection refused #111]' in /home/content/15/10121515/html/includes/classes/Swift/Transport/StreamBuffer.php:259 Stack trace: #0 /home/content/15/10121515/html/includes/classes/Swift/Transport/StreamBuffer.php(64): Swift_Transport_StreamBuffer->_establishSocketConnection() #1 /home/content/15/10121515/html/includes/classes/Swift/Transport/AbstractSmtpTransport.php(115): Swift_Transport_StreamBuffer->initialize(Array) #2 /home/content/15/10121515/html/includes/classes/Swift/Mailer.php(80): Swift_Transport_AbstractSmtpTransport->start() #3 /home/content/15/10121515/html/includes/mail.php(62): Swift_Mailer->send(Object(Swift_Message), Array) #4 {main} thrown in /home/content/15/10121515/html/includes/classes/Swift/Transport/StreamBuffer.php on line 259

有什么想法吗?

【问题讨论】:

    标签: php smtp swiftmailer mailchimp mandrill


    【解决方案1】:

    这表明您没有连接到 Mandrill 服务器,通常意味着托管服务提供商正在阻止出站 SMTP 访问,或者您正在使用的端口。您可以尝试切换端口(Mandrill 支持没有加密或 STARTTLS 的 25、587 和 2525,以及使用 SSL 的 465 端口)或联系托管服务提供商,看看他们是否可以打开您用于访问 Mandrill 的端口。

    【讨论】:

      【解决方案2】:

      不要浪费您的时间并尝试配置其他 SMTP 服务器(Gmail、mandrillapp 等)以在共享服务器上处理您的外发电子邮件。 GoDaddy、Hostgator 等...已阻止此选项。我发现将“localhost”作为主机并摆脱用户名和密码就像一个魅力!看起来太简单了,但确实如此。

      【讨论】:

      • 已确认 - 此答案有效。这对我来说就像一个魅力 - 托管在 Go daddy 上的网站。
      • 成功了!我们如何配置我们的 GoDaddy 共享主机以使用 mailtrap 或 mailgun 发送电子邮件?
      【解决方案3】:

      很可能,您的凭据有误。请重新检查您的 API 密钥作为密码,并确保您使用正确的端口访问 smtp 服务器。

      另外,如果您在 Symfony2 中使用 swiftmailer,请确保您提供如下默认设置:

      在 app/config.yml 中:

      # Swiftmailer Configuration
      swiftmailer:
          transport: "%mailer_transport%"
          host:      "%mailer_host%"
          username:  "%mailer_user%"
          password:  "%mailer_password%"
          port:      "%mailer_port%"
          #spool:     { type: memory }
      

      此外,在参数/_dev.yml 中为配置提供值:

      mailer_transport: smtp
      mailer_host: smtp.mandrillapp.com
      mailer_user: [USERNAME]
      mailer_password: [APIKEY]
      mailer_port: 587
      

      【讨论】:

        【解决方案4】:

        遇到了同样的问题,我生成了一个新的 API 密钥,它可以正常工作。

        【讨论】:

          【解决方案5】:

          我今天遇到了同样的问题。找到了这个问题,但由于缺乏答案,我正在写我是如何解决它的(我假设你和我一样在 Linux 下)。

          显然问题是没有安装邮件服务器。所以你必须找到你选择的服务器并安装它。我使用了postfix并通过以下方式安装它:

          sudo apt-get install postfix
          

          这解决了问题。

          【讨论】:

            【解决方案6】:

            对于 godaddy 共享服务器,它适用于我。

            'driver' => 'smtp',
            'host' => 'localhost',
            'port' => '587',
            'from' => array('address' => 'xxx@xxx.com', 'name' =>'This is a Sign up mail' ),
            'encryption' => 'tls',
            'username' => 'xxxxxxxx',
            'password' => 'xxxxxx',
            'sendmail' => '/usr/sbin/sendmail -bs',
            'pretend' => false,
            

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2018-12-21
              • 2012-02-11
              • 2012-06-08
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2017-07-03
              • 2010-12-04
              相关资源
              最近更新 更多