Every major mailbox provider charges a recurring monthly fee for something you can run yourself. If you have the hardware, you can host a complete, production-grade email stackβSMTP, IMAP, webmail, antivirus, and antispamβusing Mailcow Dockerized.
But there is a catch: Self-hosting email is 20% Docker configuration and 80% DNS/Deliverability management.
In this quick guide, I'll show you the architecture and setup. But be warnedβif you don't configure your DNS correctly, your emails will go straight to the spam folder.
ποΈ The Infrastructure Requirements
Before you spin up the containers, you need the right environment. Do not use a shared VPS. On a shared node, your outbound mail inherits the spam history of other tenants.
You need a Dedicated Server with:
- A Clean IP Address: Check mxtoolbox.com to ensure your IP isn't blacklisted.
- Open Port 25: Many cloud providers block outbound port 25 by default. Confirm it's open before you start!
- Resources: Minimum 6β8 GB RAM. (Mailcow runs Postfix, Dovecot, SOGo, Rspamd, and ClamAV concurrently. ClamAV alone will crash a 2GB server).
- OS: Debian 11/12 or Ubuntu 22.04 LTS.
π The Docker Deployment
Start with a clean OS and ensure Docker Engine (v24.0+) and the Compose plugin are installed.
First, set your fully qualified domain name (FQDN):
hostnamectl set-hostname mail.yourdomain.com
Clone the official Mailcow repository:
git clone [https://github.com/mailcow/mailcow-dockerized](https://github.com/mailcow/mailcow-dockerized)
cd mailcow-dockerized
Run the configuration generator. This script asks for your mail hostname and timezone, then performs a memory check on the host:
./generate_config.sh
(Note: If you have less than 6GB RAM, the script will ask if you want to disable ClamAV SKIP_CLAMD=y. For a production server, it's better to provision more RAM than to run without antivirus).
Pull the images and bring the stack up:
docker compose pull
docker compose up -d
Once running, you can access your admin panel at https://mail.yourdomain.com (Default credentials: admin / moohoo β change this immediately!).
π The Hard Part: DNS & Deliverability
Having the Docker containers running is just the beginning. To actually land in Gmail or Outlook inboxes, you must properly configure your:
- MX Record
- SPF (Sender Policy Framework)
- DKIM (DomainKeys Identified Mail)
- DMARC
- PTR (Reverse DNS)
If even one of these is misconfigured, your mail server is useless.
π Read the Full Setup Guide
Since configuring the DNS matrix, generating DKIM keys, securing the firewall, and setting up automated backups requires a deep dive, I have published the complete step-by-step tutorial on the BytesRack blog.
Read the Full DNS & Mailcow Deployment Guide Here
π» Need Hardware for Your Mail Server?
A self-hosted mail server is only as reliable as the hardware underneath it. If you want a clean, dedicated IP, full root access, and guaranteed RAM without CPU contention, check out our optimized infrastructure.
Top comments (0)