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"
4

4 回答 4

14

我的MAIL_HOSTmailtrap.io,并且该 URL 似乎不再有效。

当我将其更改为它时,smtp.mailtrap.io它又开始工作了。

于 2018-03-09T15:41:17.160 回答
11

看起来你.ENV还有缓存。

请尝试这种方式

php artisan config:cache
php artisan cache:clear

并尝试在您的Controller

dd(env('MAIL_HOST'));

如果它仍然得到smtp.gmail.com. 请尝试这种方式。

编辑您的config/app.php. 并在下面添加'env' => env('APP_ENV', 'production'),

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

并尝试在您的Controller

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

我确定它会显示smtp.mailgun.org

之后,您可以删除刚刚添加到的行config/app.php

于 2017-05-16T13:49:29.413 回答
2

在您的.env文件中,您应该设置

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

您可以参考这些教程以获取更多信息
Mailgun setup with Laravel 5 example
Ultimate Guide on Sending Email in Laravel

于 2017-05-16T13:22:46.960 回答
1

php artisan config:cache
php artisan cache:clear

您可能还需要重新启动 Web 服务器。

于 2019-02-22T10:17:56.680 回答