MailTrap 无法在 Laravel 上使用 homestead

MailTrap not working on Laravel with homestead

我以前用 MailTrap 和 Laravel 很好。

但是,自从我更新到 Laravel 5.6 并更新到 Homestead 后,我似乎无法使用 MailTrap 发送任何邮件。

这是我的 .env 文件的一个片段,类似于:

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=XXX
MAIL_PASSWORD=XXX
MAIL_ENCRYPTION=null
MAIL_FROM_NAME="John Smith"
MAIL_FROM_ADDRESS=admin@foo.com

我还清除了我的配置缓存并重新缓存它,并重新启动了服务器。

每当我尝试发送邮件时,我都会收到 Swift_TransportException 消息:Connection could not be established with host mailtrap.io [Connection timed out #110].

为什么会发生这种情况,我该如何解决这个问题。

您需要将 MAIL_HOST=mailtrap.io 更改为 MAIL_HOST=smtp.mailtrap.io,因为 mailtrap.io 已弃用 url。

您可以阅读更多内容there

On 8 March 2018 Mailtrap blocked the traffic from “mailtrap.io”.

The Mailtrap users who signed up for Mailtrap before November 10th, 2016 and did not update their credentials have to make a slight change in the SMTP host address: add “smtp” to the current SMTP host name. So, instead of “mailtrap.io”, it will be called “smtp.mailtrap.io”