I don't want my mail at a big tech company like Google or Microsoft. I don't want it at my ISP either. I want to host it myself and be in control of my data. But self-hosting mail is often considered a bad idea, and for good reasons: mail from a home-made server lands in spam, the setup is a stack of programs that each need their own configuration, and when something breaks there is nobody to call.
Most of those reasons come from one part of the job: sending. Receiving and storing mail is easy to do well on your own. Sending it so that Gmail and Outlook trust it is the hard part, and it is the part you can hand to someone else without giving up your mailbox.
This post is the setup we use ourselves, with every choice made for you and the reason behind it. It fits a household and a small company, club or association alike; where they differ, the post says so. It assumes someone is comfortable on a Linux command line. A disclosure up front: we make Outwright, the mail app recommended at the end.
Why self-hosted mail has a bad name
Set up a fresh server, point your domain at it and send a message to a friend on Gmail. One of three things happens: it bounces, it lands in spam, or it never leaves your server. The reasons:
- The port is closed. Cloud providers block outgoing mail on port 25 to keep spammers off their networks. Hetzner does this on every new cloud account and only opens it on request, case by case, after the first paid invoice.
- A new address has no reputation. Gmail and Outlook judge a sender partly by the history of its IP address. A fresh server has none, so its mail is treated as suspect.
- Cloud addresses have a bad name. Spammers rent servers too, so whole ranges of cloud addresses end up on blocklists or get extra scrutiny. Your mail can suffer for a neighbour's spam.
- A household or a small organisation never sends enough to build a reputation. An address earns trust through steady volume over weeks. A few dozen messages a day never get there.
- It never ends. Watching blocklists, asking to be removed from them, and finding out why Outlook suddenly bounces your mail is work that keeps coming back.
All five are about sending. So we don't send from our own server: outgoing mail goes through a relay, a service whose whole job is to be trusted by the big mail providers. Incoming mail still arrives directly at your server, and your mailboxes never leave it.
The choices
1. Hetzner, because it is in the EU
Hetzner is a German hosting company with data centres in Germany and Finland. Your mail sits on a server under EU law, run by a company that is not in the business of reading it. A small cloud server costs a few euros a month. Pick a location in Germany or Finland when you create it.
2. Stalwart, because it is easy to set up
A classic mail server is several programs wired together: one to receive mail, one to store it, a spam filter, and something else again for calendars and contacts. Stalwart is one program that does all of it: SMTP, IMAP, JMAP, CalDAV, CardDAV and spam filtering. It is open source, written in Rust, and it tells you exactly which DNS records to publish for your domain.
3. One Debian VM, only for mail
Mail gets a server of its own. Nothing else running on it means nothing else can break it or expose it, and you can rebuild or move it without touching anything else. Debian is stable and needs little attention. Stalwart runs directly on it, installed by its own script; with nothing else on the machine there is no need for containers.
4. SMTP2GO for sending
SMTP2GO is the relay. Its free plan covers 1,000 messages a month and 200 a day, with up to five sending domains, and it doesn't expire. That is plenty for a household and for most small companies and associations; if you outgrow it, a paid plan raises the limits without changing anything else. Newsletters to all your members or customers belong in a newsletter service, not in this relay.
SMTP2GO is a New Zealand company, so your outgoing mail passes through a provider outside the EU. We looked for an EU relay first. The ones we found either put a logo in every message on their free and cheapest plans, run on a US cloud, or have a free plan too small for everyday use. SMTP2GO is small, independent and not big tech, and that is the trade we chose. For low volume, Lettermint is a fully EU alternative.
Whichever relay you use, it carries your outgoing mail and can read it, as every mail server on the way can. It never holds your mailbox.
5. Outwright on the phone
Outwright is our mail, calendar and contacts app for iOS, in alpha. It speaks the open standards (IMAP, SMTP, CalDAV and CardDAV) to your own server and finds that server from your address alone, using DNS records the setup publishes. Any other standards-based mail app works with this setup too.
The setup
1. Get a domain
Your address lives on your domain, so the domain is what makes you independent: with it, you can change server, relay or mail app and keep the same address. Buy one from any domain registrar; to keep this part in the EU too, INWX in Germany and Loopia in Sweden both let you search for a free name and point the domain at other nameservers, which the setup needs. A domain costs from about ten euros a year, and registrars often run offers where the first year costs one euro or just a few cents.
The examples use example.org for your domain and mail.example.org for the server. Replace both
with your own.
2. Open two accounts
- Hetzner Cloud. Create a project, and under Security > API tokens create a token with Read & Write. The setup script uses it to set up the firewall, reverse DNS and your domain's DNS records, and Stalwart keeps using it to renew its certificate and rotate its signing keys.
- SMTP2GO. Create a free account, add
example.orgunder Sending > Verified senders, and note the number in the DNS records it shows (the785097ins785097._domainkey). Then create a user under Sending > SMTP Users.
3. Create the server
In the Hetzner Cloud console, create a server with Debian, in Germany or Finland, with your SSH key. A small plan with 2 to 4 GB of memory is enough for a household or a small organisation, and you can resize the server later without reinstalling.
Before you press Create, open our setup script, fill in the six values at the top (your domain, the people who get an account, the Hetzner token and the three SMTP2GO values) and paste the whole script into the Cloud config field. At its first start the server sets itself up:
- a firewall that lets in only mail, IMAP, the web admin and SSH
- reverse DNS for the server's addresses, which other mail servers check
- a DNS zone for your domain at Hetzner, with the server's address, the MX record and SMTP2GO's records
- Stalwart, with a certificate from Let's Encrypt, its own signing keys, and the DKIM, SPF, DMARC and SRV records published for you
- outgoing mail through SMTP2GO, with its certificate always checked
- an account for each person and an administrator, each with a generated password
The script is short and plain enough to read before you run it, and you should. On a Debian server somewhere else, run it as root without a Hetzner token; it then sets up Stalwart and tells you which DNS records to publish yourself.
4. Point your domain at it
When the server is up, read what the script left for you:
ssh root@<server address> cat /root/mail-setup.txt
It holds the passwords and the next two steps. At your registrar, set the domain's nameservers to the Hetzner ones it lists. Once they are in place, Stalwart publishes the rest of the records and fetches its certificate by itself, and you can press Verify for the domain in SMTP2GO. Store the passwords in your password manager and give each person theirs.
In the web admin at https://mail.example.org/admin, shared addresses such as info@ or
board@ can be aliases on one person's account, or a group that several people read. In an
organisation, give a second person administrator access, so the mail never depends on one person.
5. Send a test message
Send a message to an outside address and look for it in SMTP2GO's activity list. It should say Delivered.
6. Check that the world trusts you
- Send a message to mail-tester.com and read the score on its page.
- Send one to a Gmail and an Outlook address, open Show original, and check that SPF, DKIM and DMARC all say pass and that the message landed in the inbox.
- After a week, read the DMARC reports that arrive at the
ruaaddress. They show who sends mail in your domain's name.
7. Bring your old mail along
Stalwart imports mail from Google Takeout, from Microsoft 365 and Exchange, and from any IMAP server. Its migration guide covers each. Switch the MX record once the import is done; mail that arrives at the old provider in between can be fetched with one more IMAP import.
8. Back it up
Turn on Hetzner's backups for the server, which keeps a copy of the whole machine for the last seven days, and add a backup of Stalwart's data to somewhere outside Hetzner. A mail server you can't restore doesn't put you in control.
9. Add the accounts on the phones
Each person adds their own account in Outwright, with their address and password. It reads
the SRV records the setup published and finds IMAP, SMTP, calendars and contacts on mail.example.org by itself.
You stay in control
Every part of this can be replaced. The relay is one setting in Stalwart and a few DNS records: if SMTP2GO changes its terms, or a good EU relay comes along, you move in an afternoon and nobody you write to notices. The server can move to another host by restoring a backup and changing the A record. Your address stays the same through all of it, because the domain is yours.
That is the difference from Gmail or Microsoft, where leaving means moving everything and starting over with a new address. Here you rent the parts and own the whole.
PS: The same setup works on a physical server in your house. We don't recommend that, for many reasons, but the rationale is for another post.