Laravel on Localhost - Connection could not be established with host smtp.gmail.com [Connection timed out #110]

My MAIL_HOST was mailtrap.io, and it seems that that URL is not valid any more.

When I changed it to smtp.mailtrap.io it started working again.


It's look like your .ENV still have cache.

Please try this way

php artisan config:cache
php artisan cache:clear

And try to debug at your Controller

dd(env('MAIL_HOST'));

If it's still get smtp.gmail.com. Please try this way.

Edit your config/app.php. And add below 'env' => env('APP_ENV', 'production'),

'mail_host' => env('MAIL_HOST', 'smtp.mailgun.org'),

And try to debug at your Controller

dd(config('app.mail_host'));

I'm sure it's will show smtp.mailgun.org

After that you can delete the line you has just added to config/app.php


In your .envfile you should set

MAIL_HOST=smtp.mailgun.org
MAIL_USERNAME=(yourmailgunusername)
MAIL_PASSWORD=(yourmailgunpassword)
MAIL_PORT=587
MAIL_DRIVER=mailgun

You can refer to these tutorials for more informations
Mailgun setup with Laravel 5 example
Ultimate Guide on Sending Email in Laravel