user image

Eslam Zedan
Published in : 2022-02-16

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=smtpMAIL_HOST=smtp.gmail.comMAIL_PORT=587MAIL_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 Date : 2022-02-16

Best answers

51

Best answers

51

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

Eslam Zedan Date : 2022-02-16

thank you for your replay 

it is working fine on my local PC

 

Yasen Sayed Date : 2022-02-21

Best answers

8

Best answers

8

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

Eslam Zedan Date : 2022-02-21

Thank you

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

Get user location (city - country) from his IP address
Publish date: 2022-03-02 | Comments: 2
API CORS error in Laravel 9x
Publish date: 2022-08-03 | Comments: 2
[solved] Class "App\Exceptions\Client" not found
Publish date: 2022-02-09 | Comments: 2
[solved] Nginx 413 Request Entity Too Large - Laravel
Publish date: 2022-02-01 | Comments: 7