If you want a full-featured mail server that installs in minutes instead of days, this guide will show you exactly how to install Mailcow Debian 12 with Docker. Mailcow is a modern, Docker-based mail suite that bundles Postfix, Dovecot, SOGo webmail, and Rspamd spam filtering into one clean, manageable package — giving you a complete self-hosted email platform with a professional web interface.
Instead of manually wiring Postfix, Dovecot, DKIM signing, and webmail together (a process that can eat an entire weekend), Mailcow ships everything in pre-configured Docker containers. This tutorial walks through a fresh Debian 12 deployment from a bare VPS to a working mail server with SSL, spam filtering, and your first mailbox.
Prerequisites
Before you install Mailcow Debian 12, make sure you have the following:
- A fresh Debian 12 VPS — minimum 2 GB RAM (4 GB recommended), 1 vCPU, and at least 20 GB disk. Mailcow runs 20+ Docker containers, so a tiny 512 MB box will not cut it. If you need an affordable host, Contabo offers cheap VPS plans that work well for Mailcow.
- Port 25 open — many budget providers block outbound SMTP by default. If your provider blocks it, check RackNerd, a port-25-friendly VPS option, or request an unblock from your host.
- A domain name with DNS access (you will point A, MX, SPF, DKIM, and DMARC records at the server).
- Reverse DNS (PTR record) set on your server IP, ideally matching your mail hostname (e.g.
mail.yourdomain.com). - Root or sudo access on the VPS.
Step 1: Prepare the Debian 12 System
Start by updating the system and installing the packages you will need:
apt update && apt upgrade -y
apt install -y git curl netcat-openbsd
Check your hostname resolves correctly. Mailcow requires a valid FQDN for the mail host, for example mail.yourdomain.com. Verify DNS propagation before continuing:
host mail.yourdomain.com
Step 2: Install Docker and Docker Compose
Mailcow runs entirely in Docker, so a working Docker setup is the foundation of this install. Add Docker's official repository and install it:
curl -fsSL https://download.docker.com/linux/debian/gpg | 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 bookworm stable" > /etc/apt/sources.list.d/docker.list
apt update
apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
Verify the installation:
docker --version
docker compose version
Step 3: Clone Mailcow-dockerized
Download the official Mailcow stack into /opt and check out the stable branch:
cd /opt
git clone https://github.com/mailcow/mailcow-dockerized
cd mailcow-dockerized
git checkout master
Step 4: Generate the Configuration
Mailcow ships an interactive script that builds the main configuration file. Run it and answer the prompts:
./generate_config.sh
The key question is the mail server hostname. Enter your mail subdomain exactly as you set it in DNS — for example mail.yourdomain.com. The script writes everything to mailcow.conf.
Important mailcow.conf Settings
After generation, review these values in mailcow.conf:
MAILCOW_HOSTNAME— must be the FQDN of your mail server.MAILCOW_TZ— set your timezone (e.g.Asia/Kolkata).SKIP_LETS_ENCRYPT— leave asnto let Mailcow fetch a free Let's Encrypt certificate automatically.HTTP_PORT/HTTPS_PORT— default 80/443 are fine unless another service already binds them.
Step 5: Open the Required Firewall Ports
Open the ports Mailcow needs in UFW (or your cloud firewall):
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 25/tcp
ufw allow 110/tcp
ufw allow 143/tcp
ufw allow 465/tcp
ufw allow 587/tcp
ufw allow 993/tcp
ufw allow 995/tcp
ufw allow 4190/tcp
ufw --force enable
Step 6: Install Mailcow on Debian 12 — Pull Images and Start the Stack
This is the step where you actually install Mailcow on Debian 12. Pull all container images and start the stack in detached mode:
docker compose pull
docker compose up -d
The first pull downloads several gigabytes, so give it a few minutes. Then check that all containers are running:
docker compose ps
Now open https://mail.yourdomain.com in your browser. Mailcow's ACME client will fetch a Let's Encrypt certificate automatically (make sure port 80 was reachable during startup). Log in with the default credentials: username admin, password moohoo — and change the password immediately under System → Configuration.
Step 7: Add a Domain and Create a Mailbox
Inside the admin panel, go to Configuration → Mail Setup → Domains and add your domain (e.g. yourdomain.com). Then go to Mailboxes and create your first mailbox, for example [email protected].
Test it right away with the integrated SOGo webmail at https://mail.yourdomain.com/SOGo, or connect an email client via IMAPS (port 993) and submission (port 587).
Step 8: Configure the DNS Records
DNS is where most self-hosted mail setups fail, so get this right. Add these records at your DNS provider:
- A record:
mail.yourdomain.com→ your server IP. - MX record:
yourdomain.com→mail.yourdomain.com(priority 10). - SPF (TXT):
yourdomain.com→v=spf1 mx ~all. - DKIM (TXT): copy the key from Configuration → ARC/DKIM keys in the Mailcow admin panel, at the selector
dkim._domainkey.yourdomain.com. - DMARC (TXT):
_dmarc.yourdomain.com→v=DMARC1; p=quarantine; rua=mailto:[email protected]. - PTR record: ask your VPS provider to set reverse DNS for your IP to
mail.yourdomain.com.
Troubleshooting Common Errors
Most issues when you install Mailcow on Debian come down to three things: closed ports, blocked outbound SMTP, and wrong DNS records. Here is how to diagnose each.
“docker compose pull” fails with disk space errors
The Mailcow image set is large. Free up space with docker system prune -a (on a fresh system) or resize your VPS disk before retrying.
ACME certificate not issued
Let's Encrypt needs port 80 reachable and the A record pointing at the server. Check with curl -v http://mail.yourdomain.com/.well-known/acme-challenge/test and watch the ACME container logs: docker compose logs acme-mailcow.
Mail goes to spam or bounces
Nine times out of ten this is DNS: missing PTR record, wrong SPF, or DKIM not yet propagated. Use a mail tester like mail-tester.com, and confirm the DKIM selector matches what Mailcow generated.
Port 25 blocked
Some VPS providers block outbound SMTP even when inbound looks fine. Test with nc -zv smtp.gmail.com 25 from your server. If it times out, open a support ticket or move to a provider that allows outbound port 25.
Key Takeaways
- Mailcow bundles Postfix, Dovecot, SOGo, and Rspamd in Docker containers, making a full mail server install on Debian 12 a matter of minutes.
- You need a fresh Debian 12 VPS with at least 2 GB RAM, open port 25, and proper reverse DNS.
- The
./generate_config.shscript andMAILCOW_HOSTNAMEsetting are the core of the configuration. - Correct A, MX, SPF, DKIM, and DMARC records are essential for inbox delivery — do not skip this step.
- Change the default admin password (
moohoo) immediately after your first login.
Related Guides
- Best VPS Providers with Open Port 25 — compare VPS hosts that allow outbound SMTP, so your Mailcow server can actually send mail.
- How to Install PowerMTA on Ubuntu 24 — if you need a dedicated high-volume SMTP engine instead of a full mailbox suite, PowerMTA is the industry standard.