通过 Laravel 使用 gmail smtp:无法与主机 smtp.gmail.com 建立连接 [连接超时 #110] [英] Using gmail smtp via Laravel: Connection could not be established with host smtp.gmail.com [Connection timed out #110]
本文介绍了通过 Laravel 使用 gmail smtp:无法与主机 smtp.gmail.com 建立连接 [连接超时 #110]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试使用 GMail SMTP 通过 Laravel 发送电子邮件时,遇到以下错误:
When I try to use GMail SMTP for sending email via Laravel, I encounter the following error:
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
我使用的是共享主机,并且 localhost 上的 587 端口是开放的.
I use a shared host and the port 587 on localhost is open.
推荐答案
我遇到了同样的问题,我是这样解决的:
I had the same problem and I resolved it in this way:
'driver' => 'sendmail',
你只需要改变那一行.
这篇关于通过 Laravel 使用 gmail smtp:无法与主机 smtp.gmail.com 建立连接 [连接超时 #110]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文