FA Dev Tools

English中文

Self-Hosted Mail Server with Webmail — Effort, RAM and Hardware

infra/self-hosted-mail-server · By Derek Lam · Updated · 24 views · Tags: infra, email, self-hosting, docker, oracle-cloud, aws, stalwart, mailu, mailcow, docker-mailserver

Written with claude-opus-5-5


TL;DR

  • A container mail stack with webmail needs 0.3–1 GB RAM (Stalwart or Mailu), and 4–6 GB for Mailcow.
  • Pick Stalwart + SnappyMail for a lean or shared VM: 2 containers, a JMAP API and CalDAV/CardDAV. Its 1.0 only shipped on 2026-10-26.
  • Pick Mailu for webmail plus an admin UI from one wizard, and Mailcow only for a web calendar and ActiveSync phone push.
  • Hardware: 1–2 vCPU, 2 GB RAM, 20 GB+ disk and a static public IPv4 cover everything except Mailcow.
  • Most clouds block outbound port 25, so plan on a relay (Amazon SES, OCI Email Delivery) or an unblock request.
  • Setup takes about a day. The real cost is ongoing maintenance: spam, blacklists, backups.
  • Verdict: Stalwart + SnappyMail on an Oracle Always Free Arm VM ($0), or on AWS t4g.small / Lightsail 2 GB (about $12–21/mo) if you want paid and reliable.

Contents

How much work, by goal

"Mail server" covers very different jobs. Pick the smallest one that does what you need.

GoalWhat it takesEffortOngoing work
Receive only to a few addressesA forwarding service such as Cloudflare Email Routing (forward, or an Email Worker that POSTs the message to your app)10–30 minNone
Send only (app and alert mail)A relay such as Amazon SES or OCI Email Delivery: verified sender, SMTP credentials, SPF + DKIM recordsAbout 1 hLow
Send as your domain from GmailForwarding to Gmail + Gmail "Send mail as"15 minNone
Full mailbox (receive, send, IMAP, webmail)A container mail stack, a VM, DNS, ports, and a relay or port-25 unblockAbout 1 dayHigh

The rest of this doc is about the last row.

RAM by stack

Typical idle use for a handful of mailboxes, from each project's docs and common reports. Expect short spikes during spam scanning and search indexing. All four publish both amd64 and arm64 images.

Stack (containers)WebmailRAM, no ClamAVRAM, with ClamAVNotes
Stalwart + SnappyMailSnappyMail, a separate container (~50 MB)~0.3–0.5 GBn/a (built-in spam filter, no AV)One Rust binary for SMTP, IMAP, JMAP, CalDAV/CardDAV, DKIM and spam. Web admin, but no webmail of its own. Fewest moving parts
MailuRoundcube or SnappyMail, built in~1 GB~2.5–3 GBCompose file from its setup wizard. Admin UI included. Good middle ground
docker-mailserver + RoundcubeRoundcube, separate (~100 MB)~0.5–0.8 GB~2 GBPostfix + Dovecot + Rspamd. Configured by files and CLI, no admin UI
MailcowSOGo (plus calendar, contacts, ActiveSync)~3–4 GB (SKIP_CLAMD=y)6 GB + 1 GB swap (documented minimum)Most features, heaviest

Virus scanning keeps its whole signature database in memory. For a personal mailbox it roughly triples the footprint of the lighter stacks, and Rspamd or Stalwart's own filter already rejects most malicious mail.

Which stack to choose

All four are open-source mail servers that run in Docker. Stalwart is a new single Rust binary that also does calendars, contacts and files, but needs a separate webmail. Mailu is an all-in-one compose stack with webmail and an admin UI. docker-mailserver is one container configured by files, with no UI. Mailcow is the full groupware suite: 18 containers, SOGo webmail, ActiveSync and the richest admin UI.

The core split: Stalwart is a new, integrated, API-first server, while the other three package the classic Postfix + Dovecot + Rspamd combination with more or less UI on top.

StackBest for — choose it whenAdvantageDon't use it if you need…
🟩 Stalwart + SnappyMailthe VM is shared with other apps, or code (AI agents, automation) will read and send the mail2 containers · JMAP + REST API · CalDAV/CardDAV · AI spam classifier❌ webmail in the same package❌ antivirus scanning❌ a long track record (1.0 shipped 2026-10-26)
🟦 Mailuyou want webmail and an admin UI working after one wizardsetup wizard · Roundcube or SnappyMail built in · REST admin API❌ calendars or contacts❌ fast feature development (still on the 2024.06 major)❌ a small footprint (about 9 containers)
🟨 docker-mailserver + Roundcubeyou like config in git and the CLI, and want the most-proven coreMIT · 1 container · 19.8k stars, the most of the four · LDAP❌ any admin web UI❌ calendars or contacts❌ a mail API for code
🟪 Mailcowyou want Exchange-style groupware: web calendar, phone push, shared mailboxesSOGo + ActiveSync · richest admin UI · update.sh and backup scripts❌ a lean or shared VM (6 GiB minimum)❌ few moving parts (18 containers)❌ a short issue list (525 open)

Stalwart 1.0 (2026-10-26) changed the database layout, so 0.16 installs could not be upgraded in place. A fresh install is fine, but if a long track record matters more than RAM and container count, pick Mailu.

Status (2026-11-23)

Measured from the GitHub and Docker Hub APIs. All six projects released this month, so none is an abandonment risk.

StalwartMailudocker-mailserverMailcowSnappyMailRoundcube
Latest releasev1.1.1 (2026-11-16)2024.06.72 (2026-11-22)v17.0.0 (2026-11-05)2026-11b (2026-11-19)v3.1.4 (2026-11-20)1.7.6 (2026-11-09)
GitHub stars16.1k7.6k19.8k13.9k1.8k7.3k
Stars per year since created~4.4k (since 2023)~0.7k~1.7k~1.4k~0.3k~0.5k
Open issues436781525134503
Docker Hub pulls4.2Mn/a (ghcr)12.7Mn/a (ghcr)0.76M23.4M

Stalwart has the momentum, docker-mailserver the biggest following. Mailu is maintained but has stayed on its 2024.06 major for about 2.4 years.

Features

CapabilityStalwartMailudocker-mailserverMailcow
SMTP, IMAP, POP3, Sieve✅✅✅✅
JMAP✅❌❌❌
Webmail❌ (add one)✅ Roundcube / SnappyMail❌ (add one)✅ SOGo
Admin web UI✅✅❌ CLI + files✅ richest
CalDAV / CardDAV✅❌❌✅
ActiveSync (phone push)❌❌❌✅
WebDAV file storage✅❌❌❌
Spam filterBuilt in: statistical, AI classifier, PyzorRspamdRspamd or SpamAssassinRspamd
Antivirus❌ (milter or hooks only)✅ ClamAV✅ ClamAV✅ ClamAV
Brute-force blocking✅ built-in auto-ban✅ rate limits✅ Fail2ban✅ netfilter
Outbound relay host✅✅✅✅ per domain
Let's Encrypt, DKIM, DMARC, MTA-STS✅✅ (+ DANE)✅✅
Passkey sign-in✅✅❌✅ WebAuthn
API for code✅ JMAP + RESTREST (admin)❌REST (admin)
StorageRocksDB, SQLite, PostgreSQL, MySQL, S3Maildir + SQLite/PostgreSQL/MySQLMaildir, plain filesMaildir + MariaDB
Containers1 (+1 webmail)~91 (+1 webmail)18
arm64 images✅✅✅✅
LicenseAGPL-3.0 (enterprise extras for big hosts)MITMITGPL-3.0

Pros and cons

DimensionStalwartMailudocker-mailserverMailcow
Footprint✅ 2 containers, ~0.4 GB~9 containers, ~1 GB✅ 1 container❌ 18 containers, 6 GiB minimum
Features✅ JMAP, CalDAV/CardDAV, WebDAV, AI spam❌ no webmail or antivirus✅ webmail + admin together❌ no calendar or contacts✅ LDAP, Fetchmail, Postscreen❌ no webmail, UI or API✅ groupware + ActiveSync
Operations✅ one binary to update❌ 1.0 broke in-place upgrades✅ setup wizard❌ major version unchanged since 2024.06✅ config files in git❌ env vars and CLI only✅ update.sh + backup script❌ many parts to debug
Community✅ fastest growth❌ 3.7 years old❌ slowest growth (~0.7k stars/yr)✅ most stars (19.8k)✅ large user base❌ 525 open issues

What doesn't differ: all four run on arm64, support an outbound relay host, handle Let's Encrypt, DKIM and DMARC, and are free and open source.

Webmail for Stalwart or docker-mailserver

Stalwart and docker-mailserver don't include webmail. Add a client in its own container, or skip webmail entirely and read mail in Thunderbird, iOS Mail or the Gmail app over IMAP.

WebmailBest for — choose it whenProsCons
SnappyMailyou want a light, modern client with nothing else to run~50 MB · no database · fast UI · PGP1.8k stars · smaller plugin set
Roundcubeyou want plugins or the most familiar UI23.4M pulls · large plugin ecosystem~100 MB · older-feeling UI · 503 open issues

How to choose

flowchart TD
  A{Need a web calendar<br/>or ActiveSync push?} -- yes --> MC[Mailcow]
  A -- no --> B{VM shared with other apps,<br/>or code reads the mail?}
  B -- yes --> ST[Stalwart + SnappyMail]
  B -- no --> C{Want an admin web UI?}
  C -- yes --> MU[Mailu]
  C -- no --> DMS[docker-mailserver + Roundcube]

Stalwart's AI classifier sends message content to the model you configure. Point it at a local model (Ollama) if you don't want mail leaving the server.

Hardware requirements

Size the VM for the stack, plus about 0.5 GB for the OS and Docker. Mail is idle most of the time, so a burstable CPU is fine.

StackvCPURAM: minimum / comfortableDisk
Stalwart + SnappyMail11 GB / 2 GB10 GB + mail
Mailu (no ClamAV)11.5 GB / 2 GB15 GB + mail
docker-mailserver + Roundcube (no ClamAV)11 GB / 2 GB10 GB + mail
Mailcow (SKIP_CLAMD=y)24 GB / 6 GB20 GB + mail
Any of the above with ClamAV2+1.5 GB+1 GB for signatures

Every option also needs:

  • A static public IPv4 address. Mail servers refuse to deliver to, or accept from, IPv6-only hosts often enough to matter.
  • Reverse DNS (PTR) you can set on that IP to mail.example.com, unless all outbound mail goes through a relay.
  • A disk you can snapshot or back up: the mail volume is the only thing you can't rebuild.

A personal mailbox with years of mail fits in 20–50 GB.

Cloud VMs that fit: Oracle Cloud and AWS

Prices are USD, Sydney, Linux, on-demand unless noted, as of 2026-11-02. EC2 adds about $5.60/mo for a 20 GB gp3 disk plus a public IPv4 address. Lightsail bundles disk, transfer and IPv4.

VMCPU / RAMFitsPrice / month
Oracle VM.Standard.E2.1.Micro, Always Free1/8 OCPU x86 / 1 GBStalwart only, tight$0
Oracle VM.Standard.A1.Flex, Always Freeup to 2 OCPU Arm / 12 GBEverything, Mailcow with ClamAV included$0
AWS EC2 t4g.micro2 vCPU Arm / 1 GBStalwart only, tight$7.74 + $5.60
AWS EC2 t4g.small2 vCPU Arm / 2 GBStalwart, Mailu, docker-mailserver$15.48 + $5.60 ($5.83 + $5.60 on a 3-yr RI)
AWS EC2 t4g.medium2 vCPU Arm / 4 GBAll of them, Mailcow without ClamAV$30.95 + $5.60 ($11.67 + $5.60 on a 3-yr RI)
AWS EC2 t4g.large2 vCPU Arm / 8 GBMailcow with ClamAV$61.90 + $5.60
AWS Lightsail 2 GB2 vCPU / 2 GBStalwart, Mailu, docker-mailserver$12, everything included
AWS Lightsail 4 GB2 vCPU / 4 GBAll of them, Mailcow without ClamAV$24, everything included

Free Arm capacity is often unavailable in busy regions such as Sydney ("Out of host capacity"), and Oracle can reclaim idle Always Free VMs on a free-only account. Upgrading the account to pay-as-you-go stops the reclaiming and still costs $0 if you stay at the free sizes.

flowchart TD
  A[Self-hosted mail with webmail] --> B{Need Mailcow features?<br/>calendar, contacts, ActiveSync}
  B -- yes --> C{Free and capacity available?}
  C -- yes --> O1[Oracle A1 Always Free, $0]
  C -- no --> M[EC2 t4g.medium or Lightsail 4 GB, about $24-36/mo]
  B -- no --> D{OK with Oracle free tier risk?}
  D -- yes --> O2[Oracle A1 Always Free, $0]
  D -- no --> E{Flat monthly bill?}
  E -- yes --> L[Lightsail 2 GB, $12/mo]
  E -- no --> T[EC2 t4g.small, about $21/mo, or about $11/mo on a 3-yr RI]

Port 25 and reverse DNS

Receiving on port 25 works anywhere once the firewall allows it. Sending directly to Gmail or Outlook needs outbound port 25 and a matching PTR record, and both clouds restrict that by default:

ProviderOutbound port 25Reverse DNS (PTR)Relay to use instead
Oracle CloudBlocked. Lifting it needs a support request, rarely granted on free or trial accountsNo self-service PTR for public IPsOCI Email Delivery (free monthly quota)
AWS EC2Blocked by default. Request removal with the AWS form; usually granted for a real use caseSet it yourself on an Elastic IP (the A record must match)Amazon SES (about $0.10 per 1,000 emails)
AWS LightsailBlocked by default. Request removal through AWS SupportRequest it through AWS Support for a static IPAmazon SES

Even with port 25 open, a fresh IP has no sending reputation, so a relay is the safer default for personal mail: every stack above supports a relay host on port 587. Without a relay, expect some mail to land in spam until the IP builds a history.

flowchart LR
  S[Other mail servers] -- "SMTP :25" --> M[Your mail stack]
  U[You: browser / phone] -- "HTTPS :443 webmail<br/>IMAP :993, SMTP :587" --> M
  M -- "SMTP :587 relay" --> R[Amazon SES / OCI Email Delivery]
  R -- "SMTP :25" --> D[Gmail / Outlook / ...]

Setup checklist

  1. Ports. Open 25 (inbound SMTP), 465/587 (submission from your clients), 993 (IMAP) and 443 (webmail) in the cloud firewall (security group or security list). Oracle's Ubuntu images also ship host iptables rules, so open the ports there too.
  2. Stack. Run Stalwart + SnappyMail or Mailu with Docker Compose, with mail data on its own disk or volume and ClamAV off.
  3. DNS. Add a mail.example.com A record pointing at the static IP. If the domain is on Cloudflare it must be DNS only (grey cloud), because Cloudflare's proxy does not carry SMTP or IMAP.
  4. Records. Add MX → mail.example.com, plus SPF (include the relay), DKIM (keys from the stack, and the relay's own DKIM), and a DMARC record starting at p=none.
  5. TLS. Get a Let's Encrypt certificate for mail.example.com. The stacks above can request and renew it themselves.
  6. Outbound. Either set the relay host (SES or OCI Email Delivery SMTP on port 587, with its credentials), or get port 25 unblocked and set the PTR to mail.example.com.
  7. Test. Send to a Gmail address and to a mail-tester service. Check the score, then tighten DMARC.
  8. Operate. Back up the mail volume, watch for blacklisted IPs and expiring certificates, and make sure the stack starts again after a reboot.

If the domain already receives mail somewhere (Cloudflare Email Routing, Google Workspace, a forwarder), pointing the root MX at your server switches that off for the whole domain. Either host the new mailboxes on a subdomain (@m.example.com), or recreate the old forwards on the mail server before switching.

Sources

Disclaimer: These documents are personal notes. The information may be incomplete, out of date or wrong, so check it before you rely on it.