8

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"
LeBlaireau
  • 14,709
  • 30
  • 95
  • 169

4 Answers4

14

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.

Mladen Janjetovic
  • 11,254
  • 8
  • 64
  • 74
11

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

Quynh Nguyen
  • 2,653
  • 2
  • 10
  • 25
2

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

Rezrazi
  • 675
  • 5
  • 15
1

After

php artisan config:cache
php artisan cache:clear

You probably also need to restart your web server.

Rajesh Chaudhary
  • 354
  • 5
  • 12