Yahya Uddin
Yahya Uddin

Reputation: 28871

MailTrap not working on Laravel with homestead

I used to use MailTrap with Laravel just fine.

However, since I updated to Laravel 5.6 and updated to Homestead, I can't seem to send any mail using MailTrap.

Here is a snippet of how my .env file looks similar to:

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=XXX
MAIL_PASSWORD=XXX
MAIL_ENCRYPTION=null
MAIL_FROM_NAME="John Smith"
[email protected]

I have also cleared my config cache and re-cached it, as well as restarted the server.

Whenever, I try sending mail I get a Swift_TransportException with the message: Connection could not be established with host mailtrap.io [Connection timed out #110].

Why is this happening and how can I fix this issue.

Upvotes: 1

Views: 2143

Answers (1)

Troyer
Troyer

Reputation: 7013

You need to change MAIL_HOST=mailtrap.io to MAIL_HOST=smtp.mailtrap.io because mailtrap.io is a deprecated url.

You can read more 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”

Upvotes: 3

Related Questions