Self-Hosted Email: The Complete Guide

March 8, 2026 • Self-Hosting • 25 min read

Own your inbox. Learn how email works at a technical level, set up your own mail server with Mailu, configure DNS for proper deliverability, and migrate away from Gmail and Outlook.

Why Self-Hosted Email?

Prerequisites

DNS Records Explained

MX Record

Mail exchanger - tells other mail servers where to deliver your email.

@ MX 10 mail.yourdomain.com

SPF Record

Sender Policy Framework - authorizes which servers can send email for your domain.

@ TXT v=spf1 mx -all

DKIM Record

DomainKeys Identified Mail - cryptographic signature proving the email wasn't tampered with.

DMARC Record

Domain-based Message Authentication - tells receivers what to do with failed SPF/DKIM.

_dmarc TXT v=DMARC1; p=quarantine; rua=mailto:dmarc@yourdomain.com

Installing Mailcow

cd /opt
git clone https://github.com/mailcow/mailcow-dockerized
cd mailcow-dockerized
./generate_config.sh
docker-compose up -d

Configuring DNS

After Mailcow is running, access the admin panel and generate DNS records. Add the following to your domain's DNS:

Testing Your Setup

nslookup -type=mx yourdomain.com
dig yourdomain.com TXT
# Use mail-tester.com to check deliverability

Migrating from Gmail/Outlook

  1. Set up your new email addresses in Mailcow
  2. Configure your new accounts in your email client
  3. Use imapsync to migrate existing emails
  4. Update your accounts on services
  5. Keep old accounts forwarding to new for a transition period

Self-hosted email is challenging but rewarding. The feeling of owning your inbox is worth the effort!

// Comments

Leave a Comment