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

LeBlaireau picture LeBlaireau · May 16, 2017 · Viewed 30k times · Source

I am trying to use Mailgun

'driver' => env('MAIL_DRIVER', 'mailgun'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),


MAILGUN_DOMAIN=xxxxxxxxxx,
MAILGUN_SECRET=xxxxxxxxxx,

MAIL_DRIVER=smtp



MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

The error is a strange one. Why would it be trying to connect to gmail?

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

Edit:

Now I am getting

"mail" => array:9 [▼
      "driver" => "smtp"
      "host" => "smtp.mailgun.org"
      "port" => "2525"
      "from" => array:2 [▶]
      "encryption" => null
      "username" => null
      "password" => null
      "sendmail" => "/usr/sbin/sendmail -bs"
      "markdown" => array:2 [▼
        "theme" => "default"

Answer

Mladen Janjetovic picture Mladen Janjetovic · Mar 9, 2018

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.