user image

Jo Micheal
Published in : 2022-01-20

stream_socket_client(): Unable to connect to tcp://smtp.gmail.com:587 (Network is unreachable)

Laravel

Swift_TransportException
Connection could not be established with host smtp.gmail.com :stream_socket_client(): Unable to connect to tcp://smtp.gmail.com:587 (Network is unreachable)

I am trying to use SMTP from Gmail with my laravel app but it didn't work when I switched to the live server I am getting this error 

What should I do? here is the .env config which I am uisng 

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME={my_email}@gmail.com
MAIL_PASSWORD="PASSWORD"
MAIL_FROM_NAME="Website"
MAIL_FROM_ADDRESS={my_email}@gmail.com
MAIL_ENCRYPTION=tls

I tried to change the port to 443 and also i changed tsl to ssl & nothing happen the same error 

Comments

Joseph Morgan Date : 2022-01-20

Best answers

11

Best answers

11

This config working for me when I am using Server supports HTTPS & SSL when I used a server without SSL (HTTP) it doesn't work until I switched the smtp with "sendmail”

MAIL_MAILER=sendmail

so your configuration should looks like 

MAIL_MAILER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME={my_email}@gmail.com
MAIL_PASSWORD="PASSWORD"
MAIL_FROM_NAME="Website"
MAIL_FROM_ADDRESS={my_email}@gmail.com
MAIL_ENCRYPTION=tls

Good luck

Jo Micheal Date : 2022-01-20

Wow, this works for me, never heard of sendmail thank you so much

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

How can i pass data from blade template to vue component?
Publish date: 2022-02-11 | Comments: 1
Method Illuminate\Auth\RequestGuard::attempt does not exist.
Publish date: 2022-02-18 | Comments: 2
tymon/jwt-auth 0.5.12 requires illuminate/support ~5.0
Publish date: 2022-02-18 | Comments: 2