user

Eslam Zedan

16 Feb 2022

Laravel Network is unreachable stream_socket_client 587

Laravel

I have an error while trying to send email from gmail by laravel.

my env setting:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME={My Email}
MAIL_PASSWORD={My Password}
MAIL_ENCRYPTION=tls

The error that appears:

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)

Comments

Mohamed Atef

16 Feb 2022

githubgithubgithub

Probably you are using your personal password but you need a password called “App password” you can get it from your gmail account > security > app password

Replies

Eslam Zedan

16 Feb 2022

thank you for your replay 

it is working fine on my local PC

 

Yasen Sayed

21 Feb 2022

Best Answer

best answer

Hello Islam, 

 

You should use the host configuration of the host you are using for example create a new email that looks like this no-replay@domain.com.

The next step goes to your host mail config and takes this config into your env file.

Finally, try to clear the config cache and send a test email with these commands.

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

Replies

Eslam Zedan

21 Feb 2022

Thank you

© 2024 Copyrights reserved for web-brackets.com