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?
- Full control of your data
- No tracking or scanning
- Custom domain
- No ads
Prerequisites
- VPS with at least 2GB RAM
- Domain name
- Proper DNS configuration
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:
- MX record pointing to your server
- SPF TXT record
- DKIM TXT record
- DMARC TXT record
- Reverse PTR (contact your provider)
Testing Your Setup
nslookup -type=mx yourdomain.com
dig yourdomain.com TXT
# Use mail-tester.com to check deliverability
Migrating from Gmail/Outlook
- Set up your new email addresses in Mailcow
- Configure your new accounts in your email client
- Use imapsync to migrate existing emails
- Update your accounts on services
- 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!