Self-host docker-mailserver
v17.0.0Fullstack mail server in a single Docker container
- Stars
- 19 730
- CPU
- 1 vCore
- RAM
- 512MB RAM
- Ports
- 25 (SMTP transfer (explicit TLS / STARTTLS)), 143 (IMAP4, explicit TLS via STARTTLS), 465 (ESMTP submission, implicit TLS), 587 (ESMTP submission, explicit TLS via STARTTLS), 993 (IMAP4, implicit TLS)
ghcr.io/docker-mailserver/docker-mailserverWhat is docker-mailserver?
Docker Mailserver (DMS) packs a complete production mail stack into one container image, aimed at operators who want SMTP and IMAP for their own domains without a database: everything is plain config files that can be bind-mounted, versioned and backed up. Postfix serves SMTP while Dovecot delivers mailboxes over IMAP and POP3, with Sieve filtering and quotas. Accounts are provisioned from local files or an LDAP directory, and login can be handed to an external identity provider using OAuth2 bearer tokens. Filtering covers Rspamd, Amavis, SpamAssassin and ClamAV, while OpenDKIM, OpenDMARC, Postgrey, Postsrsd and Fail2ban harden the server; the docs also walk through SPF, DKIM, DMARC and MTA-STS DNS records. Certificates may come from Let's Encrypt, Traefik's acme.json, manual paths or self-signed files. The bundled setup command inside the container manages accounts, aliases and relay credentials, Fetchmail or Getmail6 can collect mail from other providers, and outbound delivery can be delegated to an SMTP relay host such as AWS SES or Gmail. Self-hosting means downloading the project's compose.yaml and mailserver.env, editing them, then starting the container with docker compose up -d. Linux hosts only (Windows and macOS are officially unsupported), and a static IP with matching MX, A and PTR DNS records is expected. Config is largely environment variables, and the docs note that advanced tasks may require reading the whole documentation and inspecting the running container.
docker-mailserver alternatives
Stalwart Mail ServerSelf-hosted, open-source Rust mail server with calendars, contacts and shared files over JMAP, IMAP, POP3, SMTP and the DAV protocols, plus built-in anti-spam.CompareStalwart Mail Server with docker-mailserver
boxwatchrboxwatchr is a self-hosted, open-source email filtering daemon for IMAP mailboxes with rspamd spam scoring, custom rules, and a web dashboard.Compareboxwatchr with docker-mailserver
docker-smtpA self-hosted Docker image running Exim4 that lets containers send outgoing email directly or relay through a smart host like Gmail or SendGrid.Comparedocker-smtp with docker-mailserver
tempmail-serverSelf-hosted disposable email backend with SMTP server and REST API. Features auto-expiring addresses, multi-domain support, and PostgreSQL storage.Comparetempmail-server with docker-mailserver
plMailSelf-hosted, open-source mail client unifying IMAP, Gmail, and Outlook with calendar, file integrations, and optional AI features.CompareplMail with docker-mailserver
wildduckWildDuck is a self-hosted, open-source IMAP/POP3 mail server backed by sharded MongoDB, with stateless instances, 2FA and full REST API control.Comparewildduck with docker-mailserver
SimpleRelayA self-hosted multi-tenant SMTP relay routing email through upstream providers with a web dashboard for DNS validation and access control.CompareSimpleRelay with docker-mailserver
Should you self-host docker-mailserver?
docker-mailserver scores 78/100 on selfhost.directory (how scoring works) and ranks #2 of 16 in Mail Server. It has 19 730 GitHub stars, +841 in the last 30 days.
It shipped 3 stable releases in the past year. The latest, v17.0.0, came out on 5 November 2026. New versions land roughly every 5 weeks.
Setup is advanced: plan for several services and some ongoing maintenance. An official Docker image is available. It is MIT-licensed and written mostly in Shell.
Its closest alternative on selfhost.directory is Stalwart Mail Server (79/100, 15 780 stars). It scores higher overall, so compare the two before you pick. See docker-mailserver vs Stalwart Mail Server side by side.
Features
- Admin setup CLI
- Aliases, catch-all and multi-domain
- Antivirus ScanningEnabled via ENABLE_CLAMAV=1; disabled by default.
- DKIM / DMARC signing
- External mail gathering
- Fail2ban brute-force protectionENABLE_FAIL2BAN defaults to 0.
- IMAP and POP3 mailboxes
- LDAP account provisioner
- OAuth2 / OIDC delegated loginOIDC account provisioning is not yet implemented.
- Outbound SMTP relay
- Sieve mail filtering
- SMTP mail server
- Spam Filtering
- TLS certificate support
- Update check notification
docker-mailserver README
A production-ready fullstack but simple containerized mail server (SMTP, IMAP, LDAP, Anti-spam, Anti-virus, etc.).
- Only configuration files, no SQL database. Keep it simple and versioned. Easy to deploy and upgrade.
- Originally created by @tomav, this project is now maintained by volunteers since January 2021.
FAQ
How can I send quarantined mail to a mailbox?
Create an account for it and set the Amavis quarantine_to options in docker-data/dms/config/amavis.cf to that mailbox.
What to do in case of SPF/Forwarding problems?
Enable SRS (Sender Rewriting Scheme) with ENABLE_SRS=1.
How to ban custom IP addresses with Fail2ban?
Run the setup command to ban the address; the default bantime is 180 days and can be customized.
How can I delete all the emails for a specific user?
Create a devnull alias pointing at /dev/null and map that address to it in postfix-virtual.cf.
How can I configure my email client?
Log in with the full email address; IMAP on 143 or 993 with TLS, and SMTP submission on 587 or the preferred 465.
How do I update DMS?
Read the CHANGELOG first, then pull the new image and recreate the container with docker compose pull, down and up -d.
What kind of SSL certificates can I use?
Both RSA and ECDSA certificates, provided manually or from a mounted Let's Encrypt directory, with Traefik's acme.json also supported.
Can I use a naked/bare domain (i.e. no hostname)?
Yes, but you have to change Postfix's mydestination in postfix-main.cf and set the hostname accordingly.
Do you support multiple domains?
Yes, multiple domains work out of the box by adding accounts for each domain.
What are the system requirements?
Minimum is 1 vCore and 512MB RAM with some services such as ClamAV left disabled; recommended is 1 vCore with 2GB RAM and swap enabled.
Which operating systems are supported?
Linux is officially supported; Windows and macOS are not supported and problems have been reported there.
Where are emails stored?
In the mailbox path /var/mail/${domain}/${username}; since v9.0.0 custom user attributes can give accounts different mailbox layouts.
What kind of database are you using?
None — DMS requires no database; mail and configuration live on the filesystem, persisted with bind mounts or Docker volumes.
More in Mail Server
DovecotSelf-hosted open-source IMAP/POP3 mail server for Linux with LMTP, ManageSieve, LDAP/PAM/OAuth2 auth, Sieve filtering, full-text search and official Docker images.
emailwizSelf-hosted mail server installer: one script sets up Postfix, Dovecot, SpamAssassin, OpenDKIM and fail2ban on Debian/Ubuntu and emits DKIM, SPF and DMARC records.- EximExim is a message transfer agent (MTA) developed at the University of Cambridge for use on Unix systems connected to the Internet. It is freely available under the terms of the GNU General Public License.
HarakaA self-hosted, open-source Node.js SMTP server with a JavaScript plugin system: filtering MTA or submission host with DKIM signing, DNSBL checks and virus scanning.
Hermes-Secure-Email-GatewaySelf-hosted email security gateway and mail server with spam filtering, encryption, DKIM/DMARC/ARC, Dovecot mailboxes, Nextcloud, and Authelia SSO in one Docker stack.
hestiaOpen-source, self-hosted control panel for Debian and Ubuntu servers: manage web domains, mail, DNS zones, databases and free SSL from one dashboard.
iRedMailiRedMail is a self-hosted, open-source mail server bundling Postfix, Dovecot, Roundcube, SOGo, and anti-spam tools into a reproducible installer for Linux and BSD.
jolimailSelf-hosted open-source alternative to SendGrid and Mailgun. Create and preview email templates in the browser using MJML, with PostgreSQL storage and SMTP integration.
Maddy Mail Server✉️ Composable all-in-one mail server.
Mail HubSelf-hosted temporary email aggregator unifying 10+ providers behind one REST API with auto-polling and code extraction.
Mail-in-a-BoxOpen-source, self-hosted mail server appliance: one script turns a fresh Ubuntu 22.04 VPS into a full mail stack with webmail, spam filtering, DNS and a control panel.
MailuSelf-hosted open-source Docker-based mail server providing IMAP/SMTP services, webmail access, and admin interface. Replaces complex groupware setups.
0 comments