2015-12-15 128 views
0

我收到来自我的网站发送的电子邮件的意外问题。它一直工作得很好,突然之间似乎没有明显的原因就停下来了。无法与主机建立SwiftMailer连接

[Swift_TransportException]异常 'Swift_TransportException' 与消息中的供应商/ swiftmailer/swiftmailer/LIB /类/夫特/运输/ StreamBuffer.php '连接无法与主机建立[连接超时#110]': 265

在我web.php

'mailer' => [ 
     'class' => 'yii\swiftmailer\Mailer', 
     'transport' => [ 
     'class' => 'Swift_SmtpTransport', 
     'host' => 'mail.website.com', 
     'username' => 'username', 
     'password' => 'password', 
     'port' => '587', 
     'encryption' => 'tls', 
     ], 

什么可能发生这种停止工作,我应该怎么修复呢?

我为我的电子邮件使用谷歌应用程序,但我一直使用这个配置,我连接到我的邮件服务器。我不知道为什么它突然停止工作。

回答

2

几天前在yii发生了同样的事情。通过改变端口来解决它。

尝试,

'port' => 26, 
+0

这为我工作,我不知道为什么它停止了,但高兴它开始工作。 – Jonnny

0

它正在寻找服务器mail.website.com,但无法解决它。 使用此域名smtp.gmail.com和端口25 or 465

if (!$this->_stream = fsockopen($host, $this->_params['port'], $errno, $errstr, $timeout)) 
{ 
    throw new Swift_TransportException(
    'Connection could not be established with host ' . $this->_params['host'] . 
    ' [' . $errstr . ' #' . $errno . ']' 
    ); 
} 

让你无论是需要输入一个有效的SMTP服务器或包裹在一个try/catch在send()线捕获异常,要么某处登陆或忽略。 请检查您使用的端口是否真的是您的邮件服务器使用的端口。

相关问题