Introduction
Mailcow:
- Complete docker-compose stack: Postfix, Dovecot, Rspamd, ClamAV, SOGo (webmail + cal/cardDAV), Solr (search), Redis, MariaDB
- Web UI to manage domains, mailboxes, aliases, ACL
- Auto-generated DKIM per domain
- Preconfigured Rspamd anti-spam
- Quarantine and release of suspicious mails
- Per-mailbox whitelist / blacklist
- Simple backups
- DNSBL, SPF, DMARC, ARC
To host your mail without touching Postfix/Dovecot manually.
Prerequisites
- Linux VPS Debian 12 / Ubuntu 24.04
- 4 vCPU, 6 GB RAM minimum (8 GB recommended), 20 GB SSD + mail space
- Public IP with rDNS configured
- Domain
- Root access
- Ports: 25, 80, 110, 143, 443, 465, 587, 993, 995, 4190 available
Step 1: DNS pre-checks
Configure first:
mail.example.com. A YOUR_IP
autodiscover.example.com. CNAME mail.example.com.
autoconfig.example.com. CNAME mail.example.com.
example.com. MX 10 mail.example.com.
example.com. TXT "v=spf1 mx -all"
_dmarc.example.com. TXT "v=DMARC1; p=quarantine; rua=mailto:[email protected]"
DKIM added after install.
Step 2: Docker install
sudo apt update
sudo apt install -y curl gnupg lsb-release ca-certificates
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker
docker --version
docker compose version
Step 3: Clone Mailcow
cd /opt
sudo git clone https://github.com/mailcow/mailcow-dockerized
cd mailcow-dockerized
Step 4: Generate config
sudo ./generate_config.sh
Answer:
- Hostname:
mail.example.com - Timezone:
Europe/Paris - Branch:
master(stable)
Edit mailcow.conf if needed:
MAILCOW_HOSTNAME=mail.example.com
HTTPS_PORT=443
HTTP_PORT=80
MAILCOW_PASS_SCHEME=BLF-CRYPT
SKIP_LETS_ENCRYPT=n
ADDITIONAL_SAN=
DEFAULT_DKIM_KEY_LENGTH=2048
Step 5: Start the stack
sudo docker compose pull
sudo docker compose up -d
First boot: 5-10 min. Mailcow pulls ~15 images.
sudo docker compose ps
All services should be up.
Step 6: First access
Visit https://mail.example.com/.
Default login: admin / moohoo.
⚠️ Change immediately: Settings > Profile.
Step 7: Create a domain
UI > Mail Setup > Domains > Add domain.
Domain: example.com
Description: My main domain
Aliases: 200
Mailboxes: 20
Mailbox quota max: 5120 MB
Click Add domain and restart SOGo.
Step 8: Get DKIM
After adding domain, Configuration > Configuration > ARC/DKIM keys:
Copy the DKIM record (BIND format) and publish in DNS:
dkim._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhk..."
Verify:
dig dkim._domainkey.example.com TXT
Step 9: Create a mailbox
UI > Mail Setup > Mailboxes > Add mailbox.
Username: alice
Domain: example.com
Full name: Alice
Password: XXX
Quota: 2048 MB
Address [email protected] is created.
Step 10: Configure a client
Auto-config:
- Apple Mail / iOS: Mailcow exposes Apple Mobileconfig via UI > Mailboxes > Profile > QR code
- Outlook / Thunderbird: autodiscover/autoconfig active
Manual:
- IMAP:
mail.example.com, port 993 SSL/TLS - SMTP:
mail.example.com, port 587 STARTTLS (or 465 SSL/TLS) - Auth: login = full email address
Step 11: SOGo webmail
Included: https://mail.example.com/SOGo/
Login with email address. SOGo offers:
- Webmail
- Address book (CardDAV)
- Calendar (CalDAV)
- Mobile sync via EAS (ActiveSync)
For users: https://mail.example.com/ redirects to SOGo after login.
Step 12: Backups
Mailcow provides script:
cd /opt/mailcow-dockerized
sudo ./helper-scripts/backup_and_restore.sh backup all
Backs up:
- Databases (MariaDB, Redis)
- Maildir volumes (vmail)
- Rspamd, Solr volumes
- DKIM config
Choose path during execution.
Automate:
sudo crontab -e
0 3 * * * cd /opt/mailcow-dockerized && MAILCOW_BACKUP_LOCATION=/mnt/backups ./helper-scripts/backup_and_restore.sh backup all-attr --delete-days 30
⚠️ Plan an offsite (rsync, rclone to S3).
Restore:
sudo ./helper-scripts/backup_and_restore.sh restore
Troubleshooting
"Cannot start container" on first launch
Often a port 25/80/443 already taken:
sudo ss -tunlp | grep -E ':25 |:80 |:443 |:587 '
Stop conflicting service.
Outbound mails rejected
Check with https://www.mail-tester.com:
- SPF, DKIM, DMARC OK?
- rDNS configured?
- IP not blacklisted?
sudo docker exec -it mailcowdockerized-postfix-mailcow-1 postqueue -p
SOGo webmail timeout
sudo docker logs mailcowdockerized-sogo-mailcow-1 -f
Often corrupted Redis cache:
sudo docker compose restart sogo-mailcow redis-mailcow
Disk filling up
sudo du -sh /var/lib/docker/volumes/mailcowdockerized_vmail-vol-1/
Check mailbox quotas. Mailcow logs overloads in UI > Logs.
Update Mailcow
cd /opt/mailcow-dockerized
sudo ./update.sh
Script updates images, runs DB migrations. Backup first.
Useful commands
cd /opt/mailcow-dockerized
sudo docker compose ps
sudo docker compose logs -f postfix-mailcow
sudo docker compose restart
sudo docker compose pull && sudo docker compose up -d
sudo ./update.sh -c
sudo ./helper-scripts/backup_and_restore.sh backup all
sudo ./helper-scripts/backup_and_restore.sh restore
sudo ./helper-scripts/mailcow-reset-admin.sh
sudo docker exec -it mailcowdockerized-postfix-mailcow-1 postqueue -p
sudo docker exec -it mailcowdockerized-postfix-mailcow-1 postsuper -d ALL
curl http://localhost:11334/stat | jq
sudo docker compose logs -f --tail=100
Conclusion
Mailcow gives you:
- Complete mail server in 30 min
- Web UI to manage everything
- Preconfigured DKIM, SPF, DMARC, anti-spam
- Webmail + cal/cardDAV included
- Simple backups
Limits:
- Requires Docker
- Resources: 6+ GB RAM min
- Less flexible than bare Postfix (but that's the point)
Going further:
- Combine with external reverse proxy (Caddy / Nginx) if needed
- Migrate existing accounts with imapsync
- For HA, see Mailcow multi-instance docs
Resources
- Official docs: https://mailcow.github.io/mailcow-dockerized-docs/
- GitHub: https://github.com/mailcow/mailcow-dockerized
- Community forum: https://community.mailcow.email
- imapsync: https://imapsync.lamiral.info

















