Self-Hosted Email Server: Full Control, Zero Monthly Fees
Published: 2024-07-04
Email is one of the most fundamental internet services, yet most of us rely on third-party providers like Gmail or Outlook. While convenient, these services come with trade-offs: privacy concerns, limited customization, and potential censorship. So I asked myself:
Can I host my own email server. One that gives me full control, no ads, no vendor lock-in?
The answer: Yes. And you can too.
💡 Why Self-Host Your Email?
Before jumping into the setup, here’s why I chose to go down this rabbit hole:
- Data sovereignty: My emails stay on my server, not on someone else’s cloud.
- Privacy: No profiling, no scanning for ads.
- Custom domains: I can have any email address I want (
mal@malwande.me
). - Learning experience: It’s a great deep dive into mail protocols, system administration, and DNS.
🧰 Tech Stack Overview
Component | Purpose |
---|---|
Ubuntu Server 24.04 | OS of choice for stability |
Postfix | SMTP server (sending mail) |
Dovecot | IMAP server (retrieving mail) |
rspamd | Spam filtering |
Let’s Encrypt | TLS certificates (via Certbot) |
Roundcube (optional) | Webmail interface |
MariaDB | User and mail storage backend |
🛠️ Setup Steps (Overview)
Here’s a high-level summary of how I built the stack:
1. Provision a Raspberry Pi & Domain
- I used a Raspberry Pi 4B.
- Acquired a domain (
malwande.me
) and pointed DNS records to the server’s IP.
2. Install & Configure Postfix
- Set it up to send mail using authenticated SMTP.
- Configured TLS using Let’s Encrypt.
- Enabled submission port (587) and SMTPS (465).
3. Set Up Dovecot
- Configured to handle IMAP logins securely.
- Linked with Postfix for SASL authentication.
- Mailboxes stored under
/var/mail/vhosts/
.
4. Enable Spam & Virus Filtering
- Installed and configured rspamd and ClamAV.
- Fine-tuned rules and enabled greylisting for better deliverability.
5. DKIM, SPF, and DMARC
- Signed outgoing emails with OpenDKIM.
- Set SPF and DMARC records in DNS.
- Tested using Mail Tester.
6. Optional: Webmail via Roundcube
- Installed via Apache and PHP.
- Clean interface , great for occasional use.
🧪 Testing Deliverability
After setting everything up, I tested sending to Gmail, Outlook, ProtonMail, and others. Key observations:
✅ Gmail accepted mail with a “secure” badge
⚠️ Outlook flagged it as spam initially resolved by fixing SPF/DMARC alignment
✅ Excellent score on Mail Tester (9.3/10)
🔐 Security Considerations
- Fail2Ban for brute-force protection on SMTP/IMAP
- Enforced strong TLS ciphers
- Limited mail size and rate to prevent abuse
📦 Backup & Maintenance
- Nightly
rsync
backups of maildir and configs - Certbot auto-renewal with a cron job
- Weekly log reviews and spam rule updates
🤯 Lessons Learned
- Running mail is harder than a web server, but so rewarding
- IP reputation is a real challenge, residential or cheap VPS IPs can be blacklisted
- A basic VPS (or Pi) can handle low-volume personal email just fine
📫 Final Thoughts
Hosting your own email isn’t for everyone, but if you love tinkering and value digital sovereignty, it’s a powerful project. With proper setup, it’s secure, reliable, and frees you from Big Tech inboxes.
You can now email me at my self-hosted inbox: mal@malwande.me 🚀