Laravel - 无法与主机smtp.gmail.com建立连接[#0] [英] Laravel - Connection could not be established with host smtp.gmail.com [ #0]

查看:166
本文介绍了Laravel - 无法与主机smtp.gmail.com建立连接[#0]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从本地主机使用Laravel从Gmail发送电子邮件。我收到了这个错误:连接无法建立与主机smtp.gmail.com [#0]



我使用ssl与端口465.我也试过587但它没有工作。



我也试过,但它没有奏效。我发现很多人都遭受同样的问题,但我找到的解决方案并不奏效。 同样的错误:无法与主机smtp.gmail.com [#0]建立连接,并按照以下步骤操作: https://github.com/swiftmailer/swiftmailer/issues/544



尝试将以下行添加到

  $ options [' ssl'] ['verify_peer'] = FALSE; 
$ options ['ssl'] ['verify_peer_name'] = FALSE;

请注意,这不是一个完美的解决方案,因为它涉及:a)黑客可能被覆盖的核心代码在SwiftMailer更新中,以及b)降低应用程序的安全性,因为您不再验证连接。但作为临时解决方案,它为我工作。


I'm trying to send an email from Gmail using Laravel from localhost. I'm getting this error: Connection could not be established with host smtp.gmail.com [ #0]

I'm using ssl with port 465. I also tried 587 but it didn't work.

I also tried this but it didn't work. I found a lot of people suffering from the same problems, but the solutions I found didn't work.

解决方案

I had the same error: Connection could not be established with host smtp.gmail.com [ #0] and followed the steps outlined here: https://github.com/swiftmailer/swiftmailer/issues/544.

Try adding the following lines to _establishSocketConnection() in Swift/Transport/StreamBuffer.php on line 263:

$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;

Note that this is not a perfect solution as it involves: a) Hacking core code which may be overwritten in a SwiftMailer update, and b) decreases the security of your app as you're no longer validating the connection. But as a temporary work-around it worked for me.

这篇关于Laravel - 无法与主机smtp.gmail.com建立连接[#0]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆