当我尝试使用GMail SMTP通过Laravel发送电子邮件时,遇到以下错误:
Swift_TransportException
Connection could not be established with host smtp.gmail.com [Connection timed out #110]
这是错误的痕迹:
...
}
$this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options));
if (false === $this->_stream) {
throw new Swift_TransportException(
'Connection could not be established with host ' . $this->_params['host'] .
' [' . $errstr . ' #' . $errno . ']'...
这是我的邮件配置:
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => 'some@example.ir', 'name' => 'some'),
'encryption' => 'tls',
'username' => 'myemail@gmail.com',
'password' => 'mypassword',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false
我使用共享主机,并且本地主机上的端口587已打开。
最佳答案
我遇到了同样的问题,并以这种方式解决了这个问题:
'driver' => 'sendmail',
您只需要更改该行。
关于laravel-4 - 通过Laravel使用gmail smtp:无法与主机smtp.gmail.com建立连接[连接超时#110],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25572907/