我正在尝试使用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"
我的MAIL_HOST是mailtrap.io
,似乎该URL不再有效。
当我把它改成smtp.mailtrap.io
时,它又开始工作了。
在你的.env
file你应该设置
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
后
php artisan config:cache
php artisan cache:clear
您可能还需要重新启动Web服务器。