Mailu is the slim cousin of Mailcow — same problem (self-hosted dockerized mail), tighter image set, opinionated network model, Kubernetes support. This article is the install we run when a client wants a lighter alternative to mailcow-self-hosted-stack — Docker Compose or Kubernetes, fewer containers, a smaller admin UI, and a clearer separation between MTA, IMAP, antispam, and webmail. The trade-off versus Mailcow is also worth knowing.
How to verify
Same baseline as Mailcow — clean ports, Docker available, real FQDN with PTR.
ss -ltnp | grep -E ':(25|80|110|143|443|465|587|993|995)\b'
which docker docker-compose
hostnamectl
dig +short -x $(curl -s ifconfig.me)
free -m
A Mailu deployment is happy with 2-4 GB RAM (smaller than Mailcow’s 6 GB recommendation). Disk depends on mail retention; 20 GB minimum, more for steady-state.
What’s happening — Mailu vs Mailcow at a glance
| Dimension | Mailcow | Mailu |
|---|---|---|
| Container count | ~12 | ~7 |
| MTA | Postfix | Postfix |
| IMAP | Dovecot | Dovecot |
| Antispam | Rspamd | Rspamd |
| Antivirus | ClamAV (default on) | ClamAV (default off, opt-in) |
| Webmail | SOGo (full groupware) + Roundcube | Roundcube only (no calendar) |
| Web UI for admin | rich (per-mailbox quotas, ACLs, etc.) | terse (domain, user, alias) |
| Config layout | mailcow.conf + admin UI in MySQL | mailu.env + a Flask admin UI |
| Kubernetes | community, less polished | first-class manifests provided |
| Upgrade cadence | monthly | quarterly-ish |
| Source of truth | admin UI (DB-backed) | partially in env file, partially in DB |
| Memory floor | ~6 GB | ~2 GB |
The big picks:
- Pick Mailu when you want a small, predictable mail box for a single org or small tenant, are comfortable with Docker, and don’t need calendar/contacts sharing.
- Pick Mailcow when you need SOGo (CalDAV/CardDAV), heavier antivirus, or the richer per-domain settings UI.
For new mid-sized deployments without groupware needs, Mailu lands fewer pieces in production and is easier to reason about.
The procedure
-
Prepare host and firewall:
sudo apt update sudo apt install -y docker.io docker-compose-plugin sudo systemctl enable --now docker sudo ufw allow 25,80,110,143,443,465,587,993,995/tcp sudo ufw reload -
Generate the deployment with the upstream setup tool. Mailu provides a web setup at
https://setup.mailu.io/. Fill in the form (FQDN, admin email, subnets, optional components), and download the resultingdocker-compose.ymlandmailu.env:sudo mkdir -p /mailu cd /mailu sudo curl -O https://setup.mailu.io/2.0/file/<deployment-id>/docker-compose.yml sudo curl -O https://setup.mailu.io/2.0/file/<deployment-id>/mailu.env lsYou can also hand-write
mailu.env— the docs list every variable. We prefer the setup tool for first install, then commit both files to the client’s infra repo. -
Publish DNS. Mailu’s setup tool prints the records you need; the minimum is:
mx1.example.com. IN A 203.0.113.10 example.com. IN MX 10 mx1.example.com. example.com. IN TXT "v=spf1 mx ~all"DMARC and DKIM follow once Mailu has generated the keys (step 6).
-
Start the stack. Pull and bring up:
sudo docker compose pull sudo docker compose up -d sudo docker compose psHealthy state is all containers
Up(Mailu doesn’t always set healthchecks the way Mailcow does; absence ofunhealthyis success). -
Create the admin user and first domain. Mailu exposes a
flaskCLI inside the admin container:sudo docker compose exec admin flask mailu admin admin@example.com 'strong-initial-password'Then browse to
https://mx1.example.com/admin/and log in. The UI is sparse — domains, users, aliases, relays, fetchers. Add the domain, add mailboxes. -
Pull the DKIM record. From the admin UI: Domains → example.com → Generate keys. The UI shows the public key to publish at
dkim._domainkey.example.com. Publish, then verify:dig +short TXT dkim._domainkey.example.com -
Publish DMARC. Same TXT record pattern as the OpenDMARC article:
_dmarc.example.com. IN TXT "v=DMARC1; p=none; rua=mailto:dmarc@example.com; adkim=r; aspf=r" -
Smoke test. Send a probe to port25.com from the new mailbox via Roundcube at
https://mx1.example.com/webmail/. Confirm SPF/DKIM/DMARC pass.
Kubernetes deployment (when applicable)
Mailu publishes Helm-style manifests for Kubernetes. We use them when the client already runs a multi-service K8s cluster and wants mail on the same control plane. The constraints worth knowing:
- Port 25 requires a
LoadBalancerService or a host-network DaemonSet — Ingress controllers terminate HTTP/HTTPS only. - Persistent storage must be ReadWriteOnce (Maildir on RWX shares is a known recipe for corruption).
- The DKIM private key lives in a PV that must be backed up independently of the cluster state.
For most clients, a single dedicated VM with Docker Compose is simpler and we keep K8s for the application workloads.
Common pitfalls
- The
mailu.envfile is regenerated by the setup tool with new secrets every run — commit it once, do not re-run the generator without recopying the secrets. - Port 25 outbound is blocked by the cloud provider (the same trap as Mailcow); test outbound delivery from the container with
swaksbefore declaring the deploy complete. - ClamAV is disabled by default in Mailu; if compliance requires antivirus, enable it in
mailu.envand accept the extra 1 GB RAM. - The admin Flask UI is exposed at the same FQDN as the webmail — set a strong admin password and consider IP-restricting
/admin/via the front Nginx. - Migrations between major Mailu versions sometimes require a manual
flask mailuupgrade command in the admin container; read the release notes beforedocker compose pull.
Stack Harbor stands up Mailu as the lightweight option in the engagements we run — when groupware isn’t required and the operator wants a smaller surface than Mailcow. The fitness check (Mailu vs Mailcow vs a hand-rolled Postfix) is part of the planning we do under our Managed Operations practice — pick the platform that matches the operating budget, not the one that maximizes feature checkboxes.