且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何解决“无法通过主机smtp.gmail.com建立连接"?

更新时间:2021-08-27 07:53:08

几天前,我遇到了完全相同的问题,并且在各处搜索了类似laracast ***和许多github问题,并最终解决了该问题.

Few days ago I've faced exactly the same problem and I've searched everywhere like laracast *** and many github issues and finally solve the problem.

您需要这样的配置

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=youremail@gmail.com
MAIL_PASSWORD=yourpassword
MAIL_ENCRYPTION=ssl

完成此设置后,您应该确保您的Google帐户2 step verification已关闭,因为这增加了一层额外的安全保护,这就是无法建立连接的原因.

After this setup you should make sure that your google account 2 step verification is turned off because this adds an extra layer of security that's why connection can't be established.

我认为这是Google最近添加的新功能.我之前已经在进行邮件配置,但是最近相同的代码不起作用.

I think this is new feature added by google recently. I've working mail configuration before but recently same code doesn't work.

您可以转到自己的Google帐户,在该帐户中会看到登录和安全性标签.点击它,您将在此处看到两步验证.然后,您需要关闭该功能.然后我认为它会起作用.

You can go to your google account where you will see Sign-in and Security tab. Click on it then you will see 2 step verfication there. Then you need to turn off that. Then I think it'll work.

这件事对我有用,我希望它也对您有用. 我希望你能理解.

This thing worked for me I hope it'll work for you as well. I hope you understand.