raphting.dev

Why you should run your own email server

Even some experienced self-hosters don’t trust themselves enough to run an email server, as it is considered difficult and error-prone. For most, email is not a toy that can be offline for a while.

Usually, email is part of your personal critical infrastructure. Lose access to it, and you can’t log in to websites, reset passwords, receive tickets, and so on.

If you hand your email over to a provider

Statistically, chances are high that your email is hosted on either Gmail or Outlook.

No matter which provider you choose, there are some worst-case scenarios:

  1. The provider uses your emails for training LLMs or other data mining.
  2. The provider locks you out of your account.
  3. There’s a data breach. To be fair, this can happen to self-hosters too.

What are typical problems with self-hosting email?

One of the most discussed issues is deliverability. What’s difficult is delivering email to other mail hosting providers. It doesn’t even matter much whether they are small or large. This comes down to three scenarios:

  1. Poor sender IP reputation. In the majority of cases, residential IPs are permanently listed on all major blocklists. When your IP is listed, you usually have no leverage to get it removed. Residential IPs are often dynamic too, so they get reassigned frequently. With a hosting provider, your IP is usually in a range that qualifies for delisting.
  2. Large ESP rules. All major email service providers (ESPs) have a few fixed rules you need to follow. DKIM-signed emails are the main requirement nowadays. From experience, I know that iCloud expects certain SPF settings that are undocumented (or very hard to find). In practice, you must follow all publicly documented rules, plus a few undocumented ones. You can find a good overview in the Spamhaus Rules.
  3. Smaller providers with custom rules. Every now and then, I need to reach out to smaller ESPs to sort out delivery issues. They are usually friendly and helpful, but it is time-consuming.

All of this applies provided that you have permission to open outbound TCP port 25 connections. Port 25 restrictions occur at both residential ISPs and hosting providers.

Theoretical background

Understanding email takes time. A modern email stack relies heavily on good DNS settings, including DNSSEC. Furthermore, you should have a basic understanding of DKIM, SPF, and DMARC and, to make the list complete, DANE (TLSA records).

That’s certainly a long list before you can even think about the actual mail transfer agent (MTA) software.

To configure your MTA, you need to understand the difference between the hostname, the envelope-from address, and your actual “email address”, which is the “From:” header. As a rule of thumb, sending email always means you need to be able to receive email too, at least to receive bounces. Keep that in mind if you’re thinking, “I can get started with sending email.” It’s better to start with receiving.

Explaining these concepts is beyond the scope of this article. There are many good resources online, and among the best are probably the relevant RFCs.

Practicality

If, to you, self-hosting means controlling every last bit of your side of the stack, you need a lot of knowledge and time to sort out issues with other ESPs. And even then, you’re only in control of your side. You never fully know what the other end does with it.

That’s why I recommend using p25.dev, a sovereign, privacy-focused EU email gateway. Not only does it hide your email infrastructure from the public internet, it also runs IPs with a good reputation and uses configuration principles that remove the burden of DNS configuration from you.

Tradeoff

Let’s say you’ve always had self-hosting in the back of your mind, and this article convinced you to finally get started. Here’s what I recommend: start with low stakes. Use a domain that doesn’t handle your important email, or use an experimental subdomain.

From there, you can add more domains, even mixing send-only and receive-only domains via p25.dev.

Once you feel comfortable with your setup, you can go fully sovereign and self-host your email.

p25.dev encrypts all emails on disk and tries to deliver them as fast as possible. Delivered emails are immediately deleted from disk. For privacy reasons, logs are deleted after two weeks. No email content will ever be inspected, let alone used to train LLMs or for any other data mining.

While your own email server is offline, p25.dev will spool incoming emails and deliver them to you as soon as your server is back online.

If you’ve considered self-hosting email before but found it intimidating, p25.dev is the right choice for you. Still, if you ask me whether you should self-host email, my answer is definitely yes! There’s so much to learn and customize. Your emails are too important to hand over to a third party.

By Raphael Sprenger