A mail server written in Rust, with a React web client and iOS and Android apps. It handles SMTP in and out, IMAP, POP3, JMAP, ManageSieve and CalDAV/CardDAV, and exposes a REST API and an MCP server for agents.
Production runs four processes from one image beside a kevy-server:
| process | role |
|---|---|
mailrs-receiver |
SMTP on 25, 465 and 587; the inbound pipeline (rate limits, DNSBL, greylisting, SPF/DKIM/DMARC/ARC, Bayes, fraud rules); writes accepted mail to a spool |
mailrs-fastcore |
Owns the mailbox: drains the spool, applies Sieve, delivers to Maildir, threads and indexes; IMAP, POP3 and ManageSieve; the core API the others call |
mailrs-webapi |
REST, JMAP, CalDAV/CardDAV, OIDC sign-in, MCP and the realtime WebSocket; serves the web client |
mailrs-fastcore-sender |
Outbound delivery: DKIM signing, MX and STARTTLS, MTA-STS, retries and DSNs |
There is no SQL database in that stack. Message metadata lives in an
embedded kevy store inside fastcore,
state the processes share lives in kevy-server, and mail bodies are
Maildir files.
The workspace has 70 crates. Most of them are libraries that each own one RFC or one concept — SMTP, IMAP, MIME, SPF, DKIM, DMARC, ARC, Sieve, iCalendar, JMAP, MTA-STS and more — published on crates.io and usable on their own. Protocol parsers do no I/O; the process crates own all networking.
ARCHITECTURE.md describes the processes, where each kind of state lives, how mail moves between them, and every crate.
Measured head to head against other implementations (full ledger in
PERFORMANCE.md, cross-language runners in
bench-harness/):
| scenario | mailrs | other | |
|---|---|---|---|
| RFC 5322 message scan + Subject + From | 46 ns | Go net/mail: 1440 ns |
31× |
| iCalendar parse | 1.76 µs | C libical 4.0: 7.03 µs |
4× |
SMTP EHLO parse |
18 ns | Rust smtp-codec: 126 ns |
7× |
| DKIM-Signature parse | 405 ns | Rust mail-auth 0.9: 423 ns |
+4% |
| Rate-limit hot-key check | 13–16 ns | Rust governor 0.10: 14–18 ns |
tied |
Latency-sensitive crates carry tests/perf_gate.rs budgets that fail the
test suite on regression. Parsers of untrusted input have libFuzzer
targets in their fuzz/ directories.
- SMTP — inbound and outbound, STARTTLS and implicit TLS, DKIM signing, SPF/DKIM/DMARC/ARC verification, DSNs; reads incoming DMARC aggregate and TLS-RPT reports and sends TLS-RPT reports
- IMAP — with IDLE, CONDSTORE and Dovecot-compatible UID and keyword files
- POP3, JMAP (RFC 8620/8621), ManageSieve (RFC 5804), CalDAV/CardDAV — calendar and contacts apps connect to
https://<host>/dav/with the account address and password; events and contacts are the same ones the web client shows - Sieve — server-side filtering
- Anti-abuse — greylisting, DNSBL, rate limits, login lockout, Bayesian spam filtering, inbox/notification/promotion triage, scripted fraud rules that can change without a release
- Search — full text over headers, bodies and attachment text, including OCR of images and scanned PDFs; Chinese and Japanese searchable without a dictionary
- Web client — conversation view with realtime updates; React 19, TypeScript, Vite, Tailwind CSS 4, TanStack Query
- Apps — native iOS and Android clients; new mail is announced through APNs on iOS, and on Android through a UnifiedPush distributor the reader installs (see below), or else by a check about every 15 minutes while the app is closed
- MCP — 125 tools for agents to read, triage and send mail
- Accounts — Argon2 passwords, TOTP two-factor sign-in, OIDC
- AI assistance — optional, off unless an OpenAI-compatible endpoint is configured (
MAILRS_AI_ANALYSIS_ENABLED,MAILRS_LLM_URL)
deploy/docker-compose.prod.yml is the deployment mailrs itself runs. It
starts the four processes and kevy-server from
ghcr.io/goliajp/mailrs:$MAILRS_VERSION, and expects on the host:
.envwithMAILRS_VERSIONandMAILRS_CORE_API_SECRET(the shared secret between the processes), plus the DKIM and SRS settings you use;/apps/mailrs/certs— the TLS certificate and key for SMTP, IMAP and POP3;/apps/mailrs/dkim— DKIM private keys;/apps/mailrs/secrets— the APNs key, if iOS push is used;/apps/mailrs/vapid/vapid-private.pem— the Web Push key (PEM PKCS#8 P-256), if browser or Android push is used;/apps/mailrs/fraud-rules/active.lua— the fraud rule set;/apps/mailrs/web— the built web client (cd web && bun run build);/apps/mailrs/kevy.toml— thekevy-serverconfiguration (deploy/kevy.toml).
Domains, hostnames and DKIM identities in that file are the project's own;
replace them with yours. The image is built from the root Dockerfile.
| port | service |
|---|---|
| 25 | SMTP |
| 465 | SMTPS |
| 587 | SMTP submission |
| 143 / 993 | IMAP / IMAPS |
| 110 / 995 | POP3 / POP3S |
| 4190 | ManageSieve |
| 3100 | web client, REST, JMAP, DAV, MCP (put a TLS proxy in front) |
cargo build
cargo test --workspace --no-fail-fast
# the web client (requires Bun)
cd web && bun install && bun run dev./scripts/local-fastcore-smoke.sh boots mailrs-fastcore against a
scratch kevy directory, imports a small sample and probes its routes — the
production shape without Docker.
Every setting is a MAILRS_* environment variable. The ones a deployment
sets first:
| variable | meaning |
|---|---|
MAILRS_HOSTNAME |
The server's hostname (its MX name) |
MAILRS_LOCAL_DOMAINS |
Comma-separated domains this server receives mail for |
MAILRS_KEVY_URL |
The shared kevy-server, e.g. kevy://kevy-server:6379 |
MAILRS_KEVY_DATA_DIR |
fastcore's embedded store |
MAILRS_MAILDIR |
Root of the Maildir tree |
MAILRS_SPOOL_ROOT |
The inbound spool shared by receiver and fastcore |
MAILRS_CORE_RPC_BASE, MAILRS_CORE_API_SECRET |
Where the other processes reach fastcore, and the secret they share |
MAILRS_TLS_CERT, MAILRS_TLS_KEY |
TLS certificate and key, reloaded when the files change |
MAILRS_DKIM_DOMAIN, MAILRS_DKIM_SELECTOR, MAILRS_DKIM_KEYS |
Outbound DKIM signing |
The Android app has no Google push. For notifications as mail arrives,
install a UnifiedPush distributor app on the
phone (for example ntfy, pointed at a ntfy server you trust), then turn it
on in the app under Settings → Instant notifications. The server needs a
Web Push key (MAILRS_VAPID_PRIVATE_KEY_PATH); the same key signs browser
pushes.
What reaches the distributor's server is only that something arrived: no sender, subject or count, encrypted to the phone. The app then fetches the details from your mail server over its own connection and shows the notification. The reader's notification settings (which mail rings, quiet hours, muted conversations) apply as on the other devices; Junk and held mail never push.
A phone is pushed at most once every 5 seconds. When several messages arrive in that time, one more push follows when the 5 seconds are up, so the app always looks again after the last of them.
Without a distributor, the app checks for new mail about every 15 minutes while it is closed, and Android may wait longer when the phone is idle.
An account keeps at most 10 devices for push notifications: iPhones, browsers and Android phones together. Registering one more removes the device that least recently received a push; a device that has never received one counts from when it was registered. The same device registering again does not count twice.
A phone removed from another device's push settings stays removed for 30 days: it does not register itself back, shows that it was removed, and pushes resume only when they are turned on again on that phone. Removing a phone does not sign it out; to sign out a lost phone, end its session under signed-in devices, which also stops its pushes. Signing out, and changing or resetting the password, stop pushes to the devices those sessions registered.
The distributor's endpoint must be https on port 443, and every address
its host resolves to must be public; endpoints on private or loopback
addresses are refused.
Licensed under either of Apache License, Version 2.0 or MIT license, at your option.
© 2026 GOLIA K.K.