Email delivery fails on Ubuntu VDS through Mailgun SMTP - connection timeout issues

I’m having trouble getting emails to work on my Ubuntu VDS setup using Mailgun’s SMTP service. The weird thing is that my Laravel app sends emails just fine when it’s hosted elsewhere, but it completely fails on my current server.

My server runs on Fastpanel and their support team couldn’t help me figure this out. When I test the SMTP connection manually using this command:

openssl s_client -starttls smtp -connect smtp.eu.mailgun.org:587

I also tried different ports like 25 and 465 but got the same result. The error message I keep seeing is:

139704233522496:error:0200206E:system library:connect:Connection timed out:../crypto/bio/b_sock2.c:110:
139704233522496:error:2008A067:BIO routines:BIO_connect:connect error:../crypto/bio/b_sock2.c:111:
connect:errno=110

This looks like a connection timeout but I’m not sure what’s blocking it. Could this be a firewall issue or something with my server configuration?

This is definitely a network issue, not your Laravel code - it works fine elsewhere, right? The timeout screams that your VDS provider is blocking outbound SMTP on those ports. I’ve hit this with tons of hosting providers who block 25, 465, and 587 by default to stop spam.

Quick test: try telnetting to any external SMTP server. If it times out every time, the ports are blocked at the network level. Contact Fastpanel support and ask them to unblock outbound SMTP - you’ll probably need to submit a ticket. Some hosts want account verification or extra docs before they’ll allow SMTP traffic.

totally sounds like a port issue man. many providers block em for spam protection. try hitting up FastPanel again and get em to whitelist 587/465 for ya. they should help with that.

Had the exact same issue on my Ubuntu server a few months ago. That connection timeout is almost definitely your hosting provider blocking outbound SMTP ports at the firewall level. I’d check if iptables is blocking anything locally first with sudo iptables -L, but it’s usually the datacenter’s upstream filtering. Try connecting to other SMTP servers like Gmail’s - if they all timeout the same way, it’s network blocking. When I contacted my provider, they made me fill out an anti-spam policy form and justify why I needed it for business before removing the SMTP restrictions. Took 2-3 business days but fixed everything.