Open-source Gmail alternatives you can self-host

Mailcow, docker-mailserver, Mailu and Stalwart compared: what each needs to run, the DNS setup, and why self-hosted email is riskier than it looks.

This guide contains advertising for blitz.cloud. Links to it are marked as ads.

Running your own mail server gives you full control over your inbox and your domain's address. It also makes you responsible for the part Gmail hides from you: keeping your IP address off spam blocklists, rotating certificates and reading logs when a delivery fails. Mailcow and Mailu give you a web admin panel and webmail out of the box; docker-mailserver and Stalwart ask more of you but ask less of your server.

Should you run your own mail server at all?

Google has spent two decades building a reputation system that decides whether your email lands in an inbox or a spam folder, and it trusts its own servers more than yours by default. A new mail server with no sending history starts at a disadvantage, and most residential and many cloud IP ranges block outgoing port 25 anyway. None of this is a reason to give up, but it is a reason to set SPF, DKIM, DMARC and reverse DNS correctly from day one and to warm up slowly instead of sending a newsletter to 500 people on day two.

If you only want one mailbox for yourself and don't mind an occasional message landing in someone's spam folder while your reputation builds, self-hosting is a reasonable project. If your business depends on every invoice reaching a customer, keep that address on a provider with an established sending reputation and self-host the parts that matter less.

Mailcow

Mailcow bundles Postfix, Dovecot, Rspamd, SOGo, ClamAV and ddns support behind a web admin panel, with about 13,600 GitHub stars (October 2026). Release 2026-09a came out on 6 October 2026, and the project is licensed under the GPL-3.0.

Everything runs through Docker Compose and the admin UI: domains, mailboxes, aliases, quarantine, DKIM keys and TLS all get a page instead of a config file. SOGo adds webmail, a calendar and contacts, so users get something closer to a full Google Workspace replacement than a bare inbox. The project documents minimum requirements of 2 CPU cores and 4 GB RAM, and recommends more if you run several domains.

Who it is for: anyone who wants a complete mail suite with a web interface and is fine running close to a dozen containers to get it.

docker-mailserver

docker-mailserver takes the opposite approach: SMTP, IMAP, LDAP, anti-spam and anti-virus in one container, configured through environment variables and files rather than a database, version 16.0.1 from September 2026. It has about 19,600 GitHub stars (October 2026), the most of any mail server here, and uses the MIT license.

There is no admin panel and no webmail. Setup means editing the Compose file and a config file, then running the bundled setup script for day-to-day tasks such as adding a mailbox or generating DKIM keys. That trade keeps the stack light and lets you drop the exact configuration into version control, which a database-backed admin panel does not let you do as cleanly.

Who it is for: people comfortable with config files and git who want one lean container rather than a suite, and who already have (or don't need) a separate webmail client.

Mailu

Mailu sits between the two: a web admin panel and a choice of two webmail clients, built as a set of Docker images, with about 7,600 GitHub stars (October 2026) under the MIT license. The latest release landed on 15 October 2026.

Setup runs through an interactive configuration generator that writes your Compose file and environment settings, then you fill in your DNS records. Mailu's own documentation calls out enforced TLS, DANE, MTA-STS, DKIM and an anti-spam pipeline with greylisting and auto-learn as built in. The project describes itself as free software with no tracker included, which matters if you specifically want to avoid a vendor's telemetry.

Who it is for: people who want Mailcow's admin panel and webmail without SOGo's extra weight, and who don't mind a slightly younger ecosystem with fewer tutorials.

Stalwart

Stalwart is the newest and most ambitious of the four, an all-in-one server written in Rust with about 15,200 GitHub stars (October 2026) under the AGPL-3.0 license, and a release from 18 October 2026. Where the others wrap Postfix and Dovecot, Stalwart replaces them with its own implementation of SMTP, IMAP, POP3 and JMAP, plus CalDAV, CardDAV and WebDAV for calendars, contacts and file storage.

It ships a web admin dashboard, supports pluggable storage backends including PostgreSQL, MySQL and S3, and has been through an independent security audit. Because it is a single Rust binary rather than a collection of C-based daemons glued together, it needs less memory for the same mailbox count, though its newer codebase means fewer third-party guides exist if something goes wrong.

Who it is for: people who want calendars and contacts alongside email in one server, and who are comfortable running newer, less battle-tested software for the lower resource use.

Smaller options worth knowing about

Three more Go-based servers take the "one binary, low maintenance" idea further than docker-mailserver does. Mox stores everything in a single embedded database and generates its own DNS records during setup, aimed at individuals who want low-maintenance email for one or two domains. Maddy consolidates SMTP, IMAP and the usual authentication checks into one daemon with simpler configuration than a Postfix and Dovecot pair, though its own documentation still recommends Dovecot for production IMAP storage rather than its built-in option. Modoboa wraps Postfix and Dovecot in an installer that the project says handles about 95 percent of setup automatically, with webmail, calendars and contacts included; it is used by installations with several hundred thousand mailboxes, so the scale is proven even if the interface looks dated next to Mailcow's. Mail-in-a-Box takes a different route: one script turns a fresh Ubuntu server into a complete mail service, with Roundcube webmail, Nextcloud calendars and contacts, and a control panel that manages your DNS records for you. The trade-off is that it ties you to one Ubuntu release and a single-server design, with no option to split services across machines.

Comparison table

Mailcowdocker-mailserverMailuStalwart
Admin UIYesNo (setup script)YesYes
Webmail includedYes (SOGo)NoYesNo (JMAP for compatible clients)
Built onPostfix, Dovecot, RspamdPostfix, DovecotPostfix, DovecotOwn implementation (Rust)
Calendars and contactsYes (SOGo)NoNoYes (CalDAV, CardDAV)
Config styleWeb panelFiles and variablesGenerated compose fileWeb panel
LicenseGPL-3.0MITMITAGPL-3.0

The DNS records every setup needs

Whichever server you pick, your domain's DNS has to carry the same records: an MX record pointing at your mail server, SPF naming which servers may send for your domain, a DKIM key your server signs outgoing mail with, DMARC telling other servers what to do with mail that fails those checks, and a reverse DNS (PTR) record on your server's IP matching its hostname. Mailu and Mox generate most of these for you during setup; with docker-mailserver and Mailcow you add them by hand. Get the reverse DNS wrong and large providers will quietly drop your mail without telling you why.

How to run one

All four run on your own server with Docker: Mailcow and Mailu through their setup scripts, docker-mailserver and Stalwart from a Compose file you write yourself. Open ports 25, 465, 587 and 993, point your domain's MX record at the server, and get the DNS records above right before you send a single real email. None of these are in blitz.cloud's App Store, mostly because a mail server needs a fixed IP with clean sending history and ports that stay open around the clock, which doesn't fit a free plan built around apps that sleep. If self-hosting is new to you, start with self-hosting for beginners.

More alternatives, including hosted options, are listed under Gmail alternatives.

FAQ

Yes. Running a mail server is not restricted, but your mail is only as safe as the server it runs on: keep it updated, use TLS everywhere and don't open the admin panel to the open internet without a strong password.

Will my email end up in spam folders?

It can, especially in the first weeks on a new IP address. Correct SPF, DKIM, DMARC and reverse DNS records cut the risk a lot, but a brand-new domain with no sending history still has to earn trust from the big providers over time.

Which one is easiest to set up?

Mailu's configuration generator and Mailcow's installer are the most guided. docker-mailserver and Stalwart ask you to write more configuration yourself in exchange for a lighter stack.

Can I migrate my existing Gmail mailbox to one of these?

Yes, with an IMAP migration tool such as imapsync, which most of these projects document in their own wikis. Expect to run it more than once to catch mail that arrives during the migration.

Do I need a static IP address?

You need an IP address with a working reverse DNS entry that doesn't change, which in practice means either a static IP from your hosting provider or a dynamic DNS setup some of these projects (Mox, in particular) support directly.