I’m having trouble with my email setup and keep running into timeout issues when trying to connect through Mailgun’s SMTP service. Every time I try to establish a connection, it just hangs for about 5 minutes and then fails.
Here’s what I’m seeing in my logs:
2017-07-30 08:22:15 Opening connection to ssl://smtp.mailgun.org:2195, timeout=300
2017-07-30 08:27:30 Connection failed. Error: stream_socket_client() unable to connect to ssl://smtp.mailgun.org:2195 (Connection timed out)
2017-07-30 08:27:30 SMTP ERROR: Failed to connect to server: Connection timed out (110)
2017-07-30 08:27:30 SMTP connect() failed. Message could not be sent. Mailer Error: SMTP connect() failed
I’m using PHPMailer and this worked fine before. Has anyone else experienced similar connection problems with Mailgun? What could be causing this timeout issue?
Had the same timeout issue with Mailgun a few months back. Turned out my hosting provider’s firewall was blocking it. The timeout usually means your requests aren’t reaching Mailgun’s servers properly. Try running telnet to smtp.mailgun.org on port 2195 - if that fails too, it’s definitely a network problem, not PHPMailer. Also worth trying Mailgun’s other SMTP settings. Switching to port 587 with STARTTLS fixed everything for me.
Sounds like a firewall or port blocking issue on your server. Had the exact same problem last year when I moved to a new VPS - connection would hang then timeout just like yours. I contacted hosting support to check outbound SMTP access. They had to whitelist Mailgun’s IP ranges specifically. While waiting for that, I switched to Mailgun’s alternative endpoint smtp.eu.mailgun.org on port 587 and it worked right away. The EU endpoint sometimes routes differently and bypasses network restrictions. Try both endpoints - one might connect while the other doesn’t.
check if ur server’s outbound ports are open - most shared hosting blocks port 2195 by default. i switched to mailgun’s api instead of smtp and it solved all my timeout headaches. way more reliable than dealing with smtp configs imo