简体   繁体   English

Laravel 5.6 SMTP 连接无法与主机 smtp.mailtrap.io 建立

[英]Laravel 5.6 SMTP Connection could not be established with host smtp.mailtrap.io

.env file: .env 文件:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=myuser
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=TLS

I have done the following command to clear cache and config:我已经完成了以下命令来清除缓存和配置:

php artisan cache:clear
php artisan config:cache
php artisan config:clear

I get the following error我收到以下错误

Connection could not be established with host smtp.mailtrap.io [php_network_getaddresses: getaddrinfo failed: No such host is known.无法与主机 smtp.mailtrap.io 建立连接 [php_network_getaddresses: getaddrinfo failed: No such host is known.

I have also tried restaring local development server.我也试过重新启动本地开发服务器。

I do it like this: change the port and the encryption.我是这样做的:更改端口和加密。

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=465
MAIL_USERNAME=[your username]
MAIL_PASSWORD=[your password]
MAIL_ENCRYPTION=null

And of course change username and password to your credentials.当然,将用户名和密码更改为您的凭据。

wrong code typo error错误代码错字错误

MAIL_HOST=smtp.mailtrap.io
MAIL_ENCRYPTION=NULL

and do this并这样做

php artisan cache:clear
php artisan config:clear
sudo service apache2 restart

It seems the server is not able to ping the destination address.服务器似乎无法 ping 目标地址。

Try to clear cache, config cache, and restart apache2.尝试清除缓存,配置缓存,重启apache2。 It will work fine.它会正常工作。

php artisan config:clear

php artisan cache:clear

sudo service apache2 restart

Note: clear browser cache & cookies as well.注意:也要清除浏览器缓存和 cookie。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法与主机 smtp.mailtrap.io 建立连接 - Connection could not be established with host smtp.mailtrap.io 无法与主机smtp.mailtrap.io建立连接[连接超时#110] - Connection could not be established with host smtp.mailtrap.io [Connection timed out #110] 无法与主机 smtp.mailtrap.io [连接超时 #110] 使用正确的环境建立连接 - Connection could not be established with host smtp.mailtrap.io [Connection timed out #110] with right env 无法与主机smtp.mailtrap.io建立Swift_TransportException连接#10060 - Swift_TransportException Connection could not be established with host smtp.mailtrap.io #10060 无法与主机 smtp.mailtrap.io:stream_socket_client() 建立连接:使用 SENDGRID 发送邮件时 - Connection could not be established with host smtp.mailtrap.io :stream_socket_client(): when using SENDGRID to send mail 连接到tcp://smtp.mailtrap.io:587超时 - Connection to tcp://smtp.mailtrap.io:587 Timed Out 无法在 laravel 5.6 电子邮件发送中与主机 smtp.gmail.com [连接被拒绝 #111] 建立连接 - Connection could not be established with host smtp.gmail.com [Connection refused #111] in laravel 5.6 email send 无法与主机smtp.gmail.com建立连接 - Connection could not be established with host smtp.gmail.com Laravel 在Windows 7中无法使用主机smtp.gmail.com建立Laravel 5连接 - Laravel 5 Connection could not be established with host smtp.gmail.com in windows 7 无法在laravel 5.2中与主机smtp.gmail.com建立连接[连接超时#110] - Connection could not be established with host smtp.gmail.com [Connection timed out #110] in laravel 5.2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM