Running a self-hosted email server across 12 domains for a media company — the architecture, challenges, and why I'd do it again.
When I joined Prachyam Studios as the primary technical hire, they were paying for Google Workspace across multiple domains. The costs were climbing fast — 12 domains, growing team, and the per-user-per-domain pricing model was bleeding money.
I proposed Mailcow: a Docker-based mail server with a full admin UI, anti-spam (Rspamd), antivirus (ClamAV), and DKIM/DMARC/SPF baked in. The savings were immediate and significant — lakhs annually.
# docker-compose excerpt
services:
mailcow-dockerized:
image: mailcow/mailcow-dockerized
volumes:
- ./data/conf:/opt/mailcow-dockerized/data/conf
- ./data/store:/var/vmail
ports:
- "25:25" # SMTP
- "587:587" # Submission
- "993:993" # IMAPS
- "443:443" # Web UIThe setup runs on a dedicated server with:
Each domain gets its own set of DNS records — MX, SPF, DKIM, and DMARC. I automated the DNS provisioning with a script that generates the correct records for each new domain:
Karanveer Singh Shaktawat
Full Stack Engineer & Infrastructure Architect
Building portfolio, contributing to open source, and seeking remote full-time roles with significant technical ownership.
Pick what you want to hear about — I'll only email when it's worth it.
Did this resonate?
The full story of building a self-hosted email stack across 12 domains and 6 servers at Prachyam Studios — the architecture, the hard lessons, and why I'd do it again.
#!/bin/bash
DOMAIN=$1
DKIM_KEY=$(cat /opt/mailcow-dockerized/data/conf/rspamd/dkim/${DOMAIN}.pub)
echo "MX Record: @ -> mail.${DOMAIN} (priority 10)"
echo "SPF: v=spf1 mx a ip4:YOUR_IP -all"
echo "DKIM: dkim._domainkey -> ${DKIM_KEY}"
echo "DMARC: _dmarc -> v=DMARC1; p=quarantine; rua=mailto:admin@${DOMAIN}"After 2+ years of running this setup:
Email deliverability is an art. Getting IP reputation right took weeks. I had to:
Backups are non-negotiable. I run daily incremental backups with a 30-day retention. Lost email is lost business.
Monitoring matters. I set up alerts for queue length, disk space, and certificate expiry. Most issues were caught before they became problems.
Absolutely. The control, cost savings, and learning were worth every hour. If you're comfortable with Docker and DNS, Mailcow is a solid choice for self-hosted email. Just respect the complexity — email is one of the oldest protocols on the internet, and it shows.
How a bulk marketing campaign starved transactional email at Prachyam Studios — and how I fixed it by understanding Postfix queue internals and building a priority queue on top of Mailcow.