Connection could not be established with host smtp.gmail.com Network is unreachable #101 error in Laravel email

旧城冷巷雨未停 提交于 2019-12-04 05:09:43

I solved my problem in cpanel using the code:

change MAIL_DRIVER=smtp to MAIL_DRIVER=sendmail in ".env" file

1.) clear the cache on the server after changing the configuration in the .env file.

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

and if the error still comes

Connection refused is a very explicit and clear error message. It means that the socket connection could not be established because the remote end actively refused to connect.

It's very unlikely that Google is blocking the connection.

It's very likely that your web hosting provider has firewall settings that block outgoing connections on port 465, or that they are blocking SMTP to Gmail. 465 is the "wrong" port for secure SMTP, though it is often used, and Gmail does listen there. Try port 587 instead. If the connection is still refused, call your host and ask them what's up.

Eben Gnanaraj

If your website URL is http://yourdomain.com

you need to use this port 587

or if your website URL is https://yourdomain.com

you need to use this port 25

acces to your server and edit nano /etc/csf/csf.conf

SMTP_ALLOWUSER = "cpanel,yourusr"

Localhost -> worked
Production -> Not Worked
Review your Production Firewall policies or Hosting Provider policies if they blocks email ports (because those ports were heavily spammed)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!