使用Gmail从Laravel发送电子邮件

时间:2016-08-31 14:29:00

标签: laravel gmail swiftmailer

我一直在使用Laravel一段时间,所以我想我会深入研究HTML电子邮件,所以我按照教程进行了操作。

我有这个问题,以及其他很多人的问题:

Swift_TransportException in StreamBuffer.php line 269:

Connection could not be established with host smtp.gmail.com 
[A connection attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because connected host has  failed to respond.
#10060]

我的.ENV

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=EMAIL
MAIL_PASSWORD=PASS
MAIL_ENCRYPTION=tls

我也尝试过端口25和其他建议,以及ssl而不是tls,我也尝试使用sendmail而不是smtp。

除此之外,我在尝试使用Outlook帐户时遇到了同样的问题。

我甚至启用了选项来接受安全性较低的应用程序中的项目。

遇到这些问题的其他人?

更新

我遇到了与Mail Trap相同的问题,这可能是我的laravel安装吗?

还尝试全新安装...

进一步更新

当我ping任何网站时,我的请求超时,这意味着我认为我的路由器阻止了我?

2 个答案:

答案 0 :(得分:0)

According with help for administrator page of Google, when you try to connect by port 465 this requires encryption SSL, on the contrary if you use TLS you should set the port to 587, try changing the port on your .env file.

Reference: https://support.google.com/a/answer/176600?hl=es

答案 1 :(得分:0)

.env文件

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=youremailaddress
MAIL_PASSWORD=yourownpassword
MAIL_ENCRYPTION=tls