laravel-4 - 通过Laravel使用gmail smtp:无法与主机smtp.gmail.com建立连接[连接超时#110]

标签 laravel-4 smtp swiftmailer

当我尝试使用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/

相关文章:

php - Laravel 邮件密件抄送

php - 尝试调用 类 的名为 "getRequest"的未定义方法。在 SwiftMailer Symfony 中发送电子邮件

php - Laravel4 数据库播种器错误 - 调用未定义的方法 SeedDummyOrders::setContainer()

php - 从单元测试运行时,Laravel Schema::create 忽略表前缀

java - 已发送邮件的送达确认

java - smtp 和 pop3 如何与 localhost 一起使用

php - 我可以在不发送电子邮件的情况下使用 SwiftMailer 对 SMTP 进行身份验证吗

php - 为什么我不能在我的托管域中使用 swiftmailer 发送邮件,但从我的本地主机服务器发送邮件时却没有错误

php - 为 Laravel 应用程序中的所有表单设置全局选项

python - 为每个收件人发送一封邮件