Skip to content

Mailu self-hosted stack — slim Docker mail, alternative to Mailcow

Install the Mailu dockerized mail platform, compare it operationally to Mailcow, and decide which lightweight self-hosted option fits the workload.

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

DimensionMailcowMailu
Container count~12~7
MTAPostfixPostfix
IMAPDovecotDovecot
AntispamRspamdRspamd
AntivirusClamAV (default on)ClamAV (default off, opt-in)
WebmailSOGo (full groupware) + RoundcubeRoundcube only (no calendar)
Web UI for adminrich (per-mailbox quotas, ACLs, etc.)terse (domain, user, alias)
Config layoutmailcow.conf + admin UI in MySQLmailu.env + a Flask admin UI
Kubernetescommunity, less polishedfirst-class manifests provided
Upgrade cadencemonthlyquarterly-ish
Source of truthadmin 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

  1. 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
  2. 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 resulting docker-compose.yml and mailu.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
    ls

    You 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.

  3. 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).

  4. Start the stack. Pull and bring up:

    sudo docker compose pull
    sudo docker compose up -d
    sudo docker compose ps

    Healthy state is all containers Up (Mailu doesn’t always set healthchecks the way Mailcow does; absence of unhealthy is success).

  5. Create the admin user and first domain. Mailu exposes a flask CLI 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.

  6. 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
  7. 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"
  8. 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 LoadBalancer Service 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.env file 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 swaks before declaring the deploy complete.
  • ClamAV is disabled by default in Mailu; if compliance requires antivirus, enable it in mailu.env and 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 mailu upgrade command in the admin container; read the release notes before docker 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.