Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel SMTP mailtrap [Connection timed out #110]

I'm trying to send email with Laravel using mailtrap for testing in a local homestead server.

The firewall shows no rules blocking port 2525.

Mail driver config:

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=$USERNAME
MAIL_PASSWORD=$PASSWORD
MAIL_ENCRYPTION=null

Error returned:

Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host mailtrap.io [Connection timed out #110]'
like image 502
sbarb Avatar asked Mar 13 '18 21:03

sbarb


2 Answers

Your hostname is invalid. It should be smtp.mailtrap.io. More info here: https://mailtrap.io/blog/2018-03-09-why-mailtrap-updated-its-smtp-host

P.S. Mailtrap doesn't have static IP addresses, so your way with IPv4 will work not so long amount of time.

like image 74
Alexey Vasiliev Avatar answered Oct 15 '22 13:10

Alexey Vasiliev


Adding to Alexey Vasiliev answer , after you fix the hostname don't forget to clear the cache using the following commands

php artisan config:clear 
php artisan cache:clear 
like image 44
mohammed balhadadd Avatar answered Oct 15 '22 14:10

mohammed balhadadd