Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to send email from my laravel 5.1 system. I can send emails from my localhost and unable to send from the server. See my email configuration settings in .env file,

MAIL_DRIVER=smtp
MAIL_HOST= smtp.gmail.com
MAIL_PORT= 587
MAIL_USERNAME= username***@gmail.com
MAIL_PASSWORD= *********
MAIL_ENCRYPTION=tls

This configuration only work on my localhost. On server I am getting this error,

Swift_TransportException in StreamBuffer.php line 268:
Connection could not be established with host smtp.gmail.com [Network is unreachable #101]

I also try with changing MAIL_PORT from 587 to 465 and MAIL_ENCRYPTION from tls to ssl. But I am geeitng the same error. How can I fix this issue?

like image 201
Vinod VT Avatar asked Jul 28 '17 07:07

Vinod VT


1 Answers

I solved my problem in cpanel using the code:

change MAIL_DRIVER=smtp to MAIL_DRIVER=sendmail in ".env" file
like image 190
Nur Uddin Avatar answered Sep 18 '22 10:09

Nur Uddin