DEV Community

Cover image for When Emails Stopped Sending After Migrating to DigitalOcean
ADEKOLA Abdwahab
ADEKOLA Abdwahab

Posted on

When Emails Stopped Sending After Migrating to DigitalOcean

A while ago, I had to move some services from Render to DigitalOcean Droplets. The migration went smoothly—until I noticed something odd.

Emails weren’t going out.

Every attempt ended with a timeout error. Frustrating.

At first, I suspected our email provider. A quick search even revealed a few people complaining about similar issues, so I confidently pointed fingers in that direction and proposed switching providers.

But then the unexpected happened—the exact same issue occurred with the new provider.
Meanwhile, everything worked perfectly on my local machine.

That’s when the lightbulb went on.
The issue wasn’t with the providers at all… it was with DigitalOcean itself.


The Real Culprit: Blocked SMTP Ports

After digging deeper, I discovered that DigitalOcean blocks all popular SMTP ports (25, 465, 587, etc.).
They do this intentionally to reduce spam, prevent abuse, and protect instance IP reputations.

Unfortunately for me, this meant any attempt to connect via the usual SMTP routes was doomed to fail.


The Workaround

Thankfully, my SMTP provider happened to support an alternate port that DigitalOcean didn’t block.
I switched to that port, and emails started flowing again. 🎉

But this was just a temporary fix.


The Better Approach

Moving forward, I’ve decided to avoid relying on SMTP altogether. Instead, I’ll be using email provider APIs for sending emails. They’re faster, more reliable, and not at the mercy of port restrictions.

Using Mailtrap package


Lesson Learned

What started out looking like a provider issue turned out to be a hosting environment limitation.
It reminded me of a simple but important lesson:

Always question your assumptions before blaming the wrong part of the stack.

And just like that, my brief urge to build a custom SMTP server quietly died. 😀

Top comments (0)