How to Self-Host a Production-Grade Mail Server with Mailcow


Every major mailbox provider charges a recurring monthly fee for something you can run yourself. By using Mailcow Dockerized, you can package a complete email stack SMTP, IMAP, webmail, antivirus, and antispam into a single deployment on hardware you fully control.

However, self-hosting email is not as simple as just installing the software. If you want your emails to actually land in the inbox instead of the spam folder, here are the most important rules you must follow.

1. Always Use a Dedicated Server, Not a Shared VPS

The two things that quietly sink most self-hosted mail projects are shared IPs (inheriting someone else's spam history) and unpredictable CPU/RAM drops during traffic spikes. A dedicated server gives you:

  • A Clean IP Address: A reputation history that is entirely yours to build and protect.

  • Full Reverse DNS (PTR) Control: Major providers like Gmail will reject your mail if your IP doesn't resolve back to your exact hostname.

  • Guaranteed Resources: Mailcow needs real hardware. While it can run on 2.5 GB of RAM without antivirus, 6–8 GB of RAM is the realistic minimum for a secure, production-ready server.

2. Check Port 25 Before You Do Anything

Before you buy a server or install Docker, confirm with your hosting provider that outbound port 25 is open. Many hosting platforms block this by default to prevent spam, and your setup will completely fail without it.

3. Deliverability is a DNS Problem, Not a Server Problem

A technically perfect Mailcow installation will still go straight to spam if your DNS records are missing. You absolutely must configure these 5 records correctly:

  • MX: Routes your incoming mail.

  • SPF: Declares which servers are authorized to send on your behalf.

  • DKIM: Cryptographically signs your outgoing mail.

  • DMARC: Tells receiving servers what to do if mail fails SPF/DKIM checks.

  • PTR: Confirms your IP matches your server hostname.

4. Security and Backups are Mandatory

A mail server is a permanent, internet-facing target. You must restrict your firewall strictly to mail ports (25, 465, 587, 143, 993, 443), enable Two-Factor Authentication for the admin panel, and use Mailcow’s built-in backup_and_restore.sh script to send your backups to off-site storage.

🚀 Get the Full Step-by-Step Guide

This is just a high-level summary of the requirements. If you want the complete, step-by-step tutorial including the exact Docker commands, configuration scripts, and testing tools.

👉 Read the full guide on my main blog

Comments

Popular posts from this blog

The Ultimate Guide to Tokyo Dedicated Servers: Why Your Business Needs a BytesRack Bare Metal Server in Japan

How to Migrate from VMware ESXi to Proxmox VE (2026 Step-by-Step Guide)