4
votes

I'm trying to send message using PHPMailer and google SMTP, but i got an error

Connection: opening to ssl://smtp.gmail.com:465, t=10, opt=array ( 'ssl' => array ( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true, ),) SMTP ERROR: Failed to connect to server: Connection timed out (110) SMTP connect() failed.

Mail sends fine from server on my local machine, but it doesnt work on my VPS (Debian 9). The port 465 is listening, this what i see when calling command

netstat -pln -t

tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN 15436/master

tcp6 0 0 :::465 :::* LISTEN 15436/master

when im trying connect to google SMTP using telnet

telnet smtp.gmail.com 456

i got

Trying 173.194.73.109...

and nothing happens then. Just empty command line with cursor, and i cant even exit telnet with ^], i have to restart my ssh connection. Same with port 587.

UPD: After a lot of time waiting i got telnet error

Unable to connect to remote host: Network is unreachable

btw ping 173.194.73.109 works fine

telnet localhost 465 also works fine

1
Your VPS probably has outgoing connections to ports 465 and/or 587 block. Check your firewall settings.Jirka Hrazdil
I tried to open these ports by running iptables -A INPUT -p tcp --dport 465 -j ACCEPT and iptables -A OUTPUT -p tcp --sport 465 -j ACCEPT but it didnt heldИгорь Быстревский
And when im running iptables -L i got ACCEPT tcp -- anywhere anywhere tcp spt:urd on both input and outputИгорь Быстревский

1 Answers

0
votes

So if anyone is interested in solution, i just contacted to my support and asked if they have any limitations. They said that they doesn't have any, and they also resetted my SMTP, so it started to work fine.