Laravel on Localhost - 无法与主机smtp.gmail.com建立连接[连接超时#110]

问题描述 投票:2回答:4

我正在尝试使用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

这个错误很奇怪。为什么要尝试连接到Gmail?

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

编辑:

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"
laravel email mailgun laravel-mail
4个回答
14
投票

我的MAIL_HOST是mailtrap.io,似乎该URL不再有效。

当我把它改成smtp.mailtrap.io时,它又开始工作了。


1
投票

在你的.envfile你应该设置

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


0
投票

php artisan config:cache
php artisan cache:clear

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

© www.soinside.com 2019 - 2024. All rights reserved.