Full Stack Secure Deployment: docker-mailserver + Traefik + SnappyMail
A modern, highly secure implementation based on the official docker-mailserver, tailored to provide a fully functional Web GUI out-of-the-box without compromising the strict security mandates of the original project.
The original docker-mailserver is incredibly robust but intentionally lacks a graphical user interface (GUI) or database to minimize the attack surface.
However, users often need a Webmail interface to check emails without configuring a desktop client. Attempting to force a Webmail client (like Roundcube or SOGo) into the same Docker container violates containerization best practices and introduces severe security risks.
docker-mailserver-gui solves this by introducing a microservices-based, Zero Trust architecture.
While the upstream docker-mailserver is a stellar mail engine, deploying it with a web interface typically requires hours of manual integration, reverse proxy configuration, and certificate mapping. Here is how docker-mailserver-gui elevates the deployment experience:
| Feature / Aspect | Upstream docker-mailserver |
docker-mailserver-gui Stack |
|---|---|---|
| Web Mail Access | ❌ CLI only. User must manually deploy and connect a webmail app. | ✉️ Ready-to-use, db-less SnappyMail client. |
| SSL/TLS Sync | 🔄 Automated cert-dumper sidecar reloads postfix/dovecot on new certs. |
|
| Network Security | 🔓 Port exposure depends entirely on manual host rules. | 🔒 Isolated private Docker network. Webmail has no direct internet exposure. |
| Reverse Proxy | ❌ None. Manual SSL/HTTPS provisioning required. | 🛡️ Integrated Traefik v3 proxy with automatic Let's Encrypt. |
| Persistence | 💾 Explicitly mapped, permission-hardened ./snappymail-data directory. |
|
| Default Credentials | 🚫 Strictly enforced Zero Fallback Credentials security model. |
- DB-less, High-Performance Webmail (SnappyMail): Unlike heavy webmail clients (e.g. SOGo, Roundcube) that require Postgres/MySQL and extensive CPU/RAM overhead, our stack integrates SnappyMail. It runs entirely without a database, saving system memory while delivering a lightning-fast, modern SPA web interface.
- Automated SSL/TLS Certificate Synchronization: Upstream DMS leaves SSL configuration to the user. In our stack,
dms-cert-dumpermonitors the reverse proxy'sacme.jsonfile. When Let's Encrypt renews a certificate, the sidecar extracts it, updates the mail server directories, and safely reloads Postfix/Dovecot daemons in real-time with zero downtime. - True Container Isolation (Zero Trust): Webmail clients are common targets for remote exploits. By separating the web server (
dms-traefik), webmail engine (dms-snappymail), and mail delivery agent (dms-core), an exploit in the web client cannot compromise your mail storage or private key directories. - Hardened for Production Out-of-the-Box: Includes built-in workarounds for modern Docker engines (Docker 29+
DOCKER_API_VERSIONadjustments), instant inbound delivery configuration (bypassable greylisting), and GPG-signed release integrity.
We strictly adhere to a Zero Fallback Credentials mandate. This project is orchestrated using Docker Compose to ensure strict container isolation.
Below is a visual representation of how traffic flows securely through the system:
flowchart LR
classDef internet fill:#2d3436,stroke:#f5f6fa,stroke-width:2px,color:#f5f6fa,rx:10px
classDef proxy fill:#e17055,stroke:#c0392b,stroke-width:2px,color:#fff,rx:10px
classDef core fill:#0984e3,stroke:#0984e3,stroke-width:2px,color:#fff,rx:10px
classDef gui fill:#00b894,stroke:#00cec9,stroke-width:2px,color:#fff,rx:10px
classDef volume fill:#fdcb6e,stroke:#e17055,stroke-width:2px,color:#2d3436,rx:10px
classDef sidecar fill:#6c5ce7,stroke:#6c5ce7,stroke-width:2px,color:#fff,rx:10px
Users((🌐 Internet\nUsers & Clients)):::internet
subgraph Secure Network ["🔒 Secure Docker Network (Zero Trust)"]
Traefik["🛡️ dms-traefik\n(Reverse Proxy & SSL)"]:::proxy
SnappyMail["✉️ dms-snappymail\n(Webmail UI)"]:::gui
DMSCore["⚙️ dms-core\n(Postfix, Dovecot, Anti-Spam)"]:::core
CertDumper["🔄 dms-cert-dumper\n(SSL Sync Sidecar)"]:::sidecar
VolData[("💾 Mail Data\n& Configs")]:::volume
end
Users -- "HTTPS (443)\nWebmail Access" --> Traefik
Users -- "SMTP (25/587)\nIMAP (993)" --> DMSCore
Traefik -- "Internal HTTP (80)" --> SnappyMail
SnappyMail -- "Internal IMAP (143)\nInternal SMTP (587)" --> DMSCore
Traefik -. "acme.json" .-> CertDumper
CertDumper -. "Extracted .crt/.key" .-> DMSCore
DMSCore --- VolData
dms-core(The Core Engine): The hardeneddocker-mailserver. It only exposes standard email ports (25, 587, 993) to the outside world. IMAPS (993) is strictly protected by certificates synced from Traefik.dms-traefik(The Shield): A Traefik v3.1+ reverse proxy. It automatically provisions Let's Encrypt certificates and enforces HTTPS. It is the only entry point for web traffic.dms-snappymail(The GUI): A blazing-fast, DB-less PHP webmail client (SnappyMail). It is completely isolated from the public internet.dms-cert-dumper(The Bridge): A specialized sidecar that monitors Traefik'sacme.jsonand automatically injects valid certificates into the Postfix/Dovecot engine, ensuring mobile clients never see "Invalid Certificate" errors.
Deploying your secure mail server takes less than 5 minutes.
git clone https://github.com/weby-homelab/docker-mailserver-gui.git
cd docker-mailserver-gui/secure-stackRun the setup script to create necessary volumes and set strict permissions:
chmod +x setup-gui.sh
./setup-gui.shEdit the generated .env file:
MAIL_HOSTNAME=mail.yourdomain.com
WEBMAIL_HOSTNAME=webmail.yourdomain.com
ACME_EMAIL=admin@yourdomain.comdocker compose up -d
# Wait 30s for SSL to generate, then:
./setup-snappymail.shdocker exec -ti dms-core setup email add user@yourdomain.com <password>- Instant Inbound:
Postgrey(greylisting) is disabled by default to allow immediate email delivery without the standard 10-minute delay. - Docker 29+ Compatibility: Explicitly configured Traefik with
DOCKER_API_VERSION=1.41to support modern container engines. - No Hardcoded Passwords: The Supervisor UNIX socket credentials have been removed to prevent local privilege escalation.
- Automatic SSL Sync: SSL certificates are monitored and reloaded automatically by the
dms-cert-dumpersidecar using a highly robustalpine:3.18-based image equipped withdocker-cli. - Persistent Webmail Config: SnappyMail data is explicitly persisted to
./snappymail-dataon the host, preventing the loss of settings/accounts across restarts. - Dual Registry Publishing: Automatic package deployment publishes container images to both GitHub Container Registry (GHCR) and Docker Hub (
webyhomelab/docker-mailserver-gui).
All product names, logos, brands, and trademarks referenced in this repository are the property of their respective owners. All company, product, and service names used in this project are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.
Built in Ukraine under air raid sirens & blackouts ⚡
© 2026 Weby Homelab



