Madmail-V2
A rust-based mail relay server for Delta Chat, encrypted, federated, one binary. batteries included.
Quick Setup ·
Features ·
Documentation ·
Deployment
Madmail is a server relay for the Delta Chat app, users message through the Chatmail protocol, while Madmail handles delivery, storage, federation, and real-time services on the server side.
A Rust rewrite of Madmail v1: SMTP, IMAP, encryption enforcement, and real-time relay built in.
Email for AI agents
Give each agent a dedicated mailbox on a domain you control. Madmail’s optional
WebSMTP and WebIMAP APIs support PGP-encrypted mail over HTTPS with ordinary
mailbox credentials. The agent email quickstart
covers setup, an encrypted send/receive test, credential handling, and human
approval for sensitive sends.
Project status
Madmail v2 is stable and actively maintained.
Our current focus is on:
- Finding and fixing bugs, including security issues.
- Improving reliability and maintaining existing features.
- Reducing external dependencies.
We may add new features as needs arise.
Supported operating systems
These releases are officially supported.
Linux (x86_64)
A normal Linux install uses systemd.
| Release |
Binary |
| Debian 13 |
madmail-linux-amd64 |
| Debian 12 |
madmail-linux-amd64-legacy |
| Ubuntu 26.04 |
madmail-linux-amd64 |
| Ubuntu 24.04 |
madmail-linux-amd64 |
| Ubuntu 22.04 |
madmail-linux-amd64-legacy |
| AlmaLinux 10 |
madmail-linux-amd64 |
| Rocky Linux 9 |
madmail-linux-amd64-legacy |
Debian 12, Ubuntu 22.04, and Rocky Linux 9 ship glibc older than 2.38. The default madmail-linux-amd64 build does not start there. Use the legacy build from the same release.
RHEL-family hosts often enable firewalld (Rocky Linux 9 does by default). madmail install does not open ports there. Before install requests a certificate, allow HTTP, HTTPS, SMTP, submission, and IMAP. Also allow TURN for calls (3478/udp, 3478/tcp, 49152-65535/udp) and Shadowsocks when on (8388/tcp). See the port list and firewall-cmd commands.
Windows
Windows 10 and Windows 11 (x64) are supported. Use madmail-windows-amd64-setup.exe from a stable release.
Iroh is not available on Windows for now: the installer does not offer it, and turning it on can keep the service from starting. The admin API and the admin token work. The stable installer does not include the admin web panel for now. Prerelease installers with the same file name are Madmail TESTING builds and differ; see Supported operating systems.
Quick Setup
Download the release binary for your architecture, then install and start the service:
ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
curl -fsSL "https://github.com/themadorg/madmail/releases/latest/download/madmail-linux-${ARCH}" \
-o madmail
# Debian 12, Ubuntu 22.04, Rocky Linux 9 (x86_64, glibc older than 2.38): use the legacy build instead
# curl -fsSL "https://github.com/themadorg/madmail/releases/latest/download/madmail-linux-amd64-legacy" \
# -o madmail
chmod +x madmail
With a public IP (no domain)
Trusted TLS via Let’s Encrypt IP certificate (~6-day renewal, port 80 required):
sudo ./madmail install --simple --ip YOUR_IP \
--auto-ip-cert \
--acme-email [email protected] \
--lang en
sudo systemctl enable madmail
sudo systemctl start madmail
Replace YOUR_IP with your server’s public IPv4 or IPv6 address.
Self-signed TLS (testing / internal — omit --auto-ip-cert):
sudo ./madmail install --simple --ip YOUR_IP --lang en
sudo systemctl enable madmail
sudo systemctl start madmail
With a domain
Standard Let’s Encrypt certificate (90-day renewal, DNS must point to your server):
sudo ./madmail install --simple --domain mail.example.org \
--acme-email [email protected] \
--lang en
sudo systemctl enable madmail
sudo systemctl start madmail
Replace mail.example.org with your hostname and [email protected] with a valid contact email.
Custom paths and targeted repair
For a new Unix service at custom paths, select --system explicitly:
sudo ./madmail install --simple --system --domain mail.example.org \
--acme-email [email protected] \
--config-dir /var/xyzzy/etc/madmail --state-dir /var/xyzzy/lib/madmail \
--binary-path /var/xyzzy/bin/madmail --dry-run
Review the plan, rerun without --dry-run, then sudo systemctl enable --now madmail.
Use --local for application bootstrap without host users or systemd changes.
Running as root alone does not select system mode for custom paths.
For an existing installation, avoid rerunning full bootstrap just to fix its
account or unit. Stop the service if present, then run the needed repair:
sudo ./madmail install --user-only \
--config-dir /var/xyzzy/etc/madmail --state-dir /var/xyzzy/lib/madmail
sudo ./madmail install --systemd-only \
--config-dir /var/xyzzy/etc/madmail --state-dir /var/xyzzy/lib/madmail \
--binary-path /var/xyzzy/bin/madmail
Account repair fixes user/group and permissions. Unit repair replaces the unit and
reloads systemd. Both preserve config, database, certificate and binary contents;
start the service explicitly afterward. Use the original executable name and paths.
Complete CLI reference and all flags · Mode comparison · Repair prerequisites
More detail:
Documentation
Documentation is organized by audience and purpose.
For Server Operators and End Users
- User & Operator Guide — Practical, human-friendly documentation covering accounts & registration, privacy model, federation, calls (TURN/Iroh), administration, deployment scenarios, and troubleshooting.
For Developers and Contributors
- Project Documentation — Technical tour of architecture, crates, runtime wiring, data flows, build system, and contribution notes.
- Technical Design Document (TDD) — Design specifications for major components.
- RFC Reference Library — Collection of relevant protocol specifications (SMTP, IMAP, HTTP, TLS, TURN, etc.).
Quick References
Documentation lives in the repository alongside the source code.
Credits
Madmail v2 stands on many open-source projects.
During how we built Madmail v2, dozens of those trees were used as context while implementing the Rust server, for behavior parity with Madmail v1, protocol study, client E2E testing, TLS/ACME patterns, and real-time relay integration. What each repository contributed (and related notes) is in Context & reference projects.
This codebase was also developed with Cursor (coding agent) and Gemini 3.1 Pro (Google AI Studio) for planning and implementation assistance. See AI-assisted development for how those tools fit into the workflow (more detail to be added there).
Disclaimer
The product vision, architecture, phase plan, and acceptance criteria were defined and reviewed by humans. Most of the Rust (and related) source in this repository was written with AI assistance under that direction, not as an unattended dump of generated code, but as an iterative, human-guided process.
Use at your own risk. Madmail v2 is AGPL software; validate it for your threat model and workload before deploying it in production.
We always welcome criticism, bug reports, and discussion, please use GitHub Discussions.
Resources
License
AGPL-3.0-or-later
评论