Self-host your mail server

geek_at2 pts0 comments

You should self-host your mail server

If you have spent a few days online in self-hosting or data-sovereignty communities there is one advice that always pops up:

You can self-host anything but not your e-mail server!

I do understand where they are coming from since there are horror stories around about blocklists and delivery problems but today I want to show you that it is in fact possible in 2026 and you might even be able to host it from home! By design email is an open system and we should not accept that a few big corporations have all our mail and the internet to become less decentralized in the process.

Since my small MSP company helps people and corporations on a daily basis to switch from Gmail and Microsoft to cloud alternatives or self-hosted solutions I thought I should put my money where my mouth is and also move away from Google Workspace.

At home or on a VPS?

The small subset of self-hosters that are willing to self-host their mailserver is again divided between those who dare to host their mailservers at home and those, who will only use a VPS. Usually I'd suggest using a VPS but if your home internet checks these boxes, you can 100% host your own mailserver at home:

Static IPv4 address (make sure it's not blacklisted)

Not behind a CGNAT

Ability to change the PTR record of your IP (usually though the support of your ISP)

Ability to open common mailserver Ports (25,143,465,587,993)

If you checked all of these, then you are ready to host at home!

But what about internet outages? If my modem goes down I'll lose incoming mails, right?

Depends on how long your outage is but usually: No! EMails are very robust as in if your mail server is down, the sender will retry to deliver the mail because in the early internet, outages were plentiful.

If your internet is down less than 40% on any given day, it will still work fine.

What mailserver software should I use?

So this depends on your needs really. There are multiple mailserver solutions out there with different ways to host it.

A good starting point would be docker-mailserver which is a full mailserver suite deployable via Docker with sane defaults.

But there are other solutions out there like:

Stalwart

Mailcow

Or if you're a purist you can set up your whole server yourself

Personally my mail is on my ISPConfig Server which I have maintained for years for legacy reasons. If I would set up a mail server from scratch today I'd go for docker-mailserver.

What about my domain?

As with your IP you should check if your domain is listed on any spam list but you also need a few DNS records so you don't run into delivery troubles.

Your Mailserver software will probably guide you through all that but just for completeness you'll need these records:

SPF - The Sender Policy framework defines which servers can send from your Domain. Usually something like v=spf1 mx a ~all is good enough

DKIM - This is a cryptographic signature your email server adds to the mail headers of every sent mail. Your domain needs to have a specific entry but the name and value will be communicated by your mailserver. looks usually like this: v=DKIM1; t=s; h=sha256; p=MIGf[..]B;

DMARC - This entry is basically an extension to SPF and DKIM and should prevent email spoofing of your domain. If you are unsure what to put in here, use a DMARC generator

MX - The MX records tell other mailservers where to deliver the emails on your domain. Usually you's make an A-Record for mail.yourdomain.com which points to your IP and in the MX record you put the Priority 10 and then mail.yourdomain.com as the value

Also as mentioned before the IP address you use for your mailserver should have a PTR Record which can only be set by your ISP or the VPS provider. It allows the IP of the server to resolve to a domain (usually it's the other way around) and it must show to the hostname you use for your mailserver. eg mail.yourdomain.com

Some mailservers also encourage you to add a few more records for automatic service detection but these are the core settings you need to get going.

After you have set up your domain and server I highly recommend to test mail delivery with https://www.mail-tester.com/ which checks if all the records are correct and your server is behaving the way it should. That tool saved me lots of times.

What about spam?

Here comes the fun part! Spam used to be the biggest issue with self-hosted mailservers. It was so bad that I'd say it was the biggest reason people moved away from self-hosted or even (externally) hosted webmail that usually came free when you bought a web space or domain.

The open source anti spam solutions relied on IP blacklists, domainlists, external anti-spam services like spamhaus or keyword searches - which were all very ineffective which caused your inbox look like this every day:

Word on the street was if you don't want spam, you have to use Gmail or any of the other big cloud providers that can detect spam mail by processing...

mail mailserver server self host domain

Related Articles