Answers for "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)"

1

Connection could not be established with host smtp.googlemail.com

In Laravel project directory, edit config/mail.php and add the following:
'stream' => [
        'ssl' => [
            'allow_self_signed' => true,
            'verify_peer' => false,
            'verify_peer_name' => false,
        ],
    ]
    
It worked for me.

Fyi, my SMTP settings are:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=[Full Gmail Address]
MAIL_PASSWORD=[Google App Password obtained after two step verification on Google Account Page]
MAIL_ENCRYPTION=ssl
Posted by: Guest on February-02-2021
0

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 solved my problem in cpanel using the code:

inside `.env` file change 

	MAIL_DRIVER=smtp 
to
	MAIL_DRIVER=sendmail
Posted by: Guest on May-18-2021
0

Connection could not be established with host smtp.mailtrap.io :stream_socket_client(): Unable to connect to tcp://smtp.mailtrap.io:2525 (Connection refused)

use port 25 and mail encryption is empty like

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=25
MAIL_USERNAME=XXXXXddda513d4
MAIL_PASSWORD=da084XXXXXXbbe
MAIL_ENCRYPTION=
Posted by: Guest on August-17-2021

Code answers related to "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)"

Browse Popular Code Answers by Language