Abidus Sattar Aziz
Abidus Sattar Aziz

Reputation: 155

mail shows Connection could not be established with host smtp.gmail.com when site is not hosted in main domain

i am trying to send mail using laravel. it works fine in localhost. but gives an error as below Connection could not be established with host smtp.gmail.com :stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Network is unreachable)

But here to mention. my site is hosted in mysite.com/citizen. so i checked it with a site with main domain like anothersite.com and now it works fine. i think i have a path problem. i am trying to find the solution but not beign able to find it anywhere, anybody please help...

here is my env configuration

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=xxxxxx
MAIL_ENCRYPTION=ssl

i have tried changing the driver into sendmail but in this case gmail says its phishing and asks to report the mail

Upvotes: 0

Views: 1041

Answers (1)

Steffen Ullrich
Steffen Ullrich

Reputation: 123270

.. my site is hosted in mysite.com/citizen. so i checked it with a site with main domain like anothersite.com and now it works fine. i think i have a path problem.

The path of your site does not matter at all. Instead there is probably a firewall which disallows connections to the mail server port 465 on the hosting service for mysite.com but there is no such firewall on the hosting service for anothersite.com. This is indicated by Network is unreachable, i.e. it cannot even establish a TCP connection to the mail server.

There is not much you can do about this. Check with your hosting provider of why this port is blocked and what alternative ways they propose.

Upvotes: 1

Related Questions