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
- RAM by stack
- Which stack to choose
- Hardware requirements
- Cloud VMs that fit: Oracle Cloud and AWS
- Port 25 and reverse DNS
- Setup checklist
- Sources
How much work, by goal
"Mail server" covers very different jobs. Pick the smallest one that does what you need.
| Goal | What it takes | Effort | Ongoing work |
|---|---|---|---|
| Receive only to a few addresses | A forwarding service such as Cloudflare Email Routing (forward, or an Email Worker that POSTs the message to your app) | 10–30 min | None |
| Send only (app and alert mail) | A relay such as Amazon SES or OCI Email Delivery: verified sender, SMTP credentials, SPF + DKIM records | About 1 h | Low |
| Send as your domain from Gmail | Forwarding to Gmail + Gmail "Send mail as" | 15 min | None |
| Full mailbox (receive, send, IMAP, webmail) | A container mail stack, a VM, DNS, ports, and a relay or port-25 unblock | About 1 day | High |
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) | Webmail | RAM, no ClamAV | RAM, with ClamAV | Notes |
|---|---|---|---|---|
| Stalwart + SnappyMail | SnappyMail, a separate container (~50 MB) | ~0.3–0.5 GB | n/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 |
| Mailu | Roundcube or SnappyMail, built in | ~1 GB | ~2.5–3 GB | Compose file from its setup wizard. Admin UI included. Good middle ground |
| docker-mailserver + Roundcube | Roundcube, separate (~100 MB) | ~0.5–0.8 GB | ~2 GB | Postfix + Dovecot + Rspamd. Configured by files and CLI, no admin UI |
| Mailcow | SOGo (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.
| Stack | Best for — choose it when | Advantage | Don't use it if you need… |
|---|---|---|---|
| 🟩 Stalwart + SnappyMail | the VM is shared with other apps, or code (AI agents, automation) will read and send the mail | 2 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) |
| 🟦 Mailu | you want webmail and an admin UI working after one wizard | setup 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 + Roundcube | you like config in git and the CLI, and want the most-proven core | MIT · 1 container · 19.8k stars, the most of the four · LDAP | ❌ any admin web UI❌ calendars or contacts❌ a mail API for code |
| 🟪 Mailcow | you want Exchange-style groupware: web calendar, phone push, shared mailboxes | SOGo + 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.
| Stalwart | Mailu | docker-mailserver | Mailcow | SnappyMail | Roundcube | |
|---|---|---|---|---|---|---|
| Latest release | v1.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 stars | 16.1k | 7.6k | 19.8k | 13.9k | 1.8k | 7.3k |
| Stars per year since created | ~4.4k (since 2023) | ~0.7k | ~1.7k | ~1.4k | ~0.3k | ~0.5k |
| Open issues | 43 | 67 | 81 | 525 | 134 | 503 |
| Docker Hub pulls | 4.2M | n/a (ghcr) | 12.7M | n/a (ghcr) | 0.76M | 23.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
| Capability | Stalwart | Mailu | docker-mailserver | Mailcow |
|---|---|---|---|---|
| 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 filter | Built in: statistical, AI classifier, Pyzor | Rspamd | Rspamd or SpamAssassin | Rspamd |
| 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 + REST | REST (admin) | ❌ | REST (admin) |
| Storage | RocksDB, SQLite, PostgreSQL, MySQL, S3 | Maildir + SQLite/PostgreSQL/MySQL | Maildir, plain files | Maildir + MariaDB |
| Containers | 1 (+1 webmail) | ~9 | 1 (+1 webmail) | 18 |
| arm64 images | ✅ | ✅ | ✅ | ✅ |
| License | AGPL-3.0 (enterprise extras for big hosts) | MIT | MIT | GPL-3.0 |
Pros and cons
| Dimension | Stalwart | Mailu | docker-mailserver | Mailcow |
|---|---|---|---|---|
| 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.
| Webmail | Best for — choose it when | Pros | Cons |
|---|---|---|---|
| SnappyMail | you want a light, modern client with nothing else to run | ~50 MB · no database · fast UI · PGP | 1.8k stars · smaller plugin set |
| Roundcube | you want plugins or the most familiar UI | 23.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.
| Stack | vCPU | RAM: minimum / comfortable | Disk |
|---|---|---|---|
| Stalwart + SnappyMail | 1 | 1 GB / 2 GB | 10 GB + mail |
| Mailu (no ClamAV) | 1 | 1.5 GB / 2 GB | 15 GB + mail |
| docker-mailserver + Roundcube (no ClamAV) | 1 | 1 GB / 2 GB | 10 GB + mail |
Mailcow (SKIP_CLAMD=y) | 2 | 4 GB / 6 GB | 20 GB + mail |
| Any of the above with ClamAV | 2 | +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.
| VM | CPU / RAM | Fits | Price / month |
|---|---|---|---|
Oracle VM.Standard.E2.1.Micro, Always Free | 1/8 OCPU x86 / 1 GB | Stalwart only, tight | $0 |
Oracle VM.Standard.A1.Flex, Always Free | up to 2 OCPU Arm / 12 GB | Everything, Mailcow with ClamAV included | $0 |
AWS EC2 t4g.micro | 2 vCPU Arm / 1 GB | Stalwart only, tight | $7.74 + $5.60 |
AWS EC2 t4g.small | 2 vCPU Arm / 2 GB | Stalwart, Mailu, docker-mailserver | $15.48 + $5.60 ($5.83 + $5.60 on a 3-yr RI) |
AWS EC2 t4g.medium | 2 vCPU Arm / 4 GB | All of them, Mailcow without ClamAV | $30.95 + $5.60 ($11.67 + $5.60 on a 3-yr RI) |
AWS EC2 t4g.large | 2 vCPU Arm / 8 GB | Mailcow with ClamAV | $61.90 + $5.60 |
| AWS Lightsail 2 GB | 2 vCPU / 2 GB | Stalwart, Mailu, docker-mailserver | $12, everything included |
| AWS Lightsail 4 GB | 2 vCPU / 4 GB | All 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:
| Provider | Outbound port 25 | Reverse DNS (PTR) | Relay to use instead |
|---|---|---|---|
| Oracle Cloud | Blocked. Lifting it needs a support request, rarely granted on free or trial accounts | No self-service PTR for public IPs | OCI Email Delivery (free monthly quota) |
| AWS EC2 | Blocked by default. Request removal with the AWS form; usually granted for a real use case | Set it yourself on an Elastic IP (the A record must match) | Amazon SES (about $0.10 per 1,000 emails) |
| AWS Lightsail | Blocked by default. Request removal through AWS Support | Request it through AWS Support for a static IP | Amazon 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
- 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.
- Stack. Run Stalwart + SnappyMail or Mailu with Docker Compose, with mail data on its own disk or volume and ClamAV off.
- DNS. Add a
mail.example.comArecord 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. - 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 atp=none. - TLS. Get a Let's Encrypt certificate for
mail.example.com. The stacks above can request and renew it themselves. - 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. - Test. Send to a Gmail address and to a mail-tester service. Check the score, then tighten DMARC.
- 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
- Stalwart Mail Server · GitHub · upgrade from 0.16 · free vs enterprise
- Mailu · GitHub · setup wizard
- docker-mailserver · GitHub
- Mailcow: prerequisites · GitHub
- SnappyMail · GitHub
- Roundcube
- GitHub and Docker Hub APIs, queried 2026-11-23
- OCI: Always Free Resources
- OCI: Email Delivery overview
- AWS: Amazon EC2 pricing
- AWS: Amazon Lightsail pricing
- AWS: Amazon SES pricing
- AWS: remove the port 25 restriction on EC2
Disclaimer: These documents are personal notes. The information may be incomplete, out of date or wrong, so check it before you rely on it.