Laravel在Localhost上-无法与主机smtp.gmail.com建立连接[连接超时#110]
问题描述:
我正在尝试使用Mailgun
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
该错误是一个奇怪的错误.为什么会尝试连接到gmail?
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]
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"
答
看来您的.ENV
仍具有缓存.
请尝试这种方式
php artisan config:cache
php artisan cache:clear
并尝试在您的Controller
dd(env('MAIL_HOST'));
如果仍然显示smtp.gmail.com
.请尝试这种方式.
If it's still get smtp.gmail.com
. Please try this way.
编辑您的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
After that you can delete the line you has just added to config/app.php