Skip to main content
All posts

Why self-hosting email is so hard

I thought running my own mail server would be a weekend project. It turned out to be one of the hardest things I have self-hosted, not because of the software, but because of everything around it.

I like running things myself. My websites run on my own server, my analytics run on my own server, and I enjoy knowing exactly how everything fits together. So at some point, email felt like the logical next step. How hard could it be? It's one of the oldest protocols on the internet.

Very hard, it turns out. Not because the software is difficult, but because of everything around it. Here's what I ran into, and why I now think twice before recommending anyone to host their own email.

Getting a server to send mail is the easy part

This is what makes self-hosting email so misleading. Setting up a mail server is very doable. I tried two systems: Postal for outgoing mail, and Stalwart, an all-in-one mail server that handles both sending and receiving. Both are well built and well documented, and within an evening you can send and receive your first emails.

And then you feel like you're done. You're not. That first email that "worked" probably landed in a spam folder, and you won't know until someone tells you they never got it.

Nobody trusts a new mail server

Email runs on trust. Gmail, Outlook and every other large provider judge each incoming message on the reputation of the server and the domain that sent it. A brand-new server has no reputation at all, and to a spam filter, "unknown" looks a lot like "suspicious".

That's exactly what happened to me. Emails that were perfectly fine ended up in spam, and some providers refused them outright. Microsoft in particular is strict: a mail server it doesn't know can be rejected or silently filtered, even when everything is configured correctly.

The worst part is that a lot of it happens silently. A rejection at least gives you an error message. Mail that lands in someone's spam folder gives you nothing. Your server says "delivered", and from your side everything looks fine.

Your IP address has a history

When you rent a server from a hosting provider, you get an IP address that someone else may have used before. If the previous tenant sent spam from it, that address can still be on a blocklist. Some blocklists even list entire ranges of hosting providers, simply because a lot of spam comes from cheap servers.

So before you've sent a single email, you may already be on the back foot. You can check the big blocklists and request a removal, but every list has its own process, and some even charge for a quick delisting.

On top of that, many cloud and VPS providers block outgoing traffic on port 25, the port mail servers use to talk to each other, by default. Sometimes you can ask them to open it, sometimes you can't. It's one of those things you only find out once you're already halfway through.

Every DNS record has to line up

To be trusted at all, your server needs a whole set of DNS records, and they all have to agree with each other:

  • MX: tells the world which server receives mail for your domain.
  • SPF: lists which servers are allowed to send mail for your domain.
  • DKIM: a digital signature on every outgoing email, so the receiver can verify it wasn't changed.
  • DMARC: tells receivers what to do when SPF or DKIM fails, and sends you reports about it.
  • Reverse DNS (PTR): links your IP address back to your mail server's hostname. You don't set this in your own DNS, but at your hosting provider.

In practice, it looks something like this:

example.com.                  MX   10 mail.example.com.
example.com.                  TXT  "v=spf1 mx -all"
mail._domainkey.example.com.  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkq..."
_dmarc.example.com.           TXT  "v=DMARC1; p=quarantine; rua=mailto:[email protected]"

; reverse DNS, set at your hosting provider:
203.0.113.10                  PTR  mail.example.com.

On top of that, the name your server introduces itself with has to match the reverse DNS. One typo, one forgotten record or one mismatch between them, and your mail is treated as suspicious. These aren't optional extras anymore either: Gmail and Yahoo have required proper authentication since 2024, and Microsoft followed with similar rules in 2025.

Receiving mail is a job of its own

Sending is only half the story. As soon as your server is online, the spam starts coming in, and now you're the one who has to filter it. I used SpamAssassin for that, and quickly learned that installing it is the easy part. The real work is tuning its rules until they're just right.

Too loose, and your inbox fills up with junk. Too strict, and real emails disappear. Finding that balance takes time, and it's never quite finished, because spammers keep changing their tactics.

Security never stops

A mail server is one of the most attacked services you can put on the internet. From the moment it's online, bots try to log in to your mailboxes, day and night. If one account has a weak password, a spammer will happily use your server to send thousands of emails. Your reputation, which took weeks to build, is gone in an hour.

So you also need rate limits, something like Fail2ban to block brute-force attempts, TLS certificates that renew on time and updates for every part of the stack. A misconfiguration that turns your server into an open relay is the nightmare scenario: then anyone on the internet can send mail through it.

When it breaks, you don't notice

When a website goes down, you notice quickly. When email breaks, it often stays quiet. A full disk, an expired certificate or a mail queue that's stuck: you only find out when someone asks why you never replied, or when an invoice turns out to have never arrived.

Email is also critical in a way most self-hosted services aren't. Password resets, invoices, messages from clients: everything comes in through your inbox. That means monitoring, backups of every mailbox and a plan for when your server is down. It's not a project you set up once; it's a service you keep running.

So, should you never do it?

I wouldn't go that far. If you want to understand how email really works, setting up your own mail server is one of the most educational things you can do. I learned more about DNS, reputation and security from it than from any course.

But for the email you actually depend on, I'd now pick a hosted mailbox provider. They have years of reputation, a team that deals with blocklists and someone who gets paid to wake up at night when something breaks. For email sent by an application, like a contact form or a password reset, a dedicated sending service or SMTP relay is usually the better choice. It handles reputation for you, so your messages simply arrive.

Still want to try it yourself? Then at least do this:

  1. Check before you start whether your provider allows outgoing traffic on port 25.
  2. Look up your IP address on the major blocklists, and ask for a different one if it's listed.
  3. Set up reverse DNS, SPF, DKIM and DMARC before you send your first email.
  4. Test your setup with a tool like mail-tester.com, and keep an eye on Google Postmaster Tools and Microsoft SNDS.
  5. Start small and build up your sending volume slowly, so your reputation can grow.

Self-hosting email taught me a lot. Mostly that the hard part was never the server itself, but earning the trust of everyone else on the internet.

Have a project in mind?

I'd love to hear about it. Send me a message and I'll get back to you as soon as possible.

Get in touch