Overview
rmail is a self-contained mail server implemented entirely in Python 3 standard library. It handles inbound and outbound email via SMTP, exposes mailboxes over IMAP4rev1, delivers messages to external domains through direct MX resolution or a configured smarthost, and provides a REST/JSON Exchange-style API for programmatic access.
There are no third-party dependencies. Storage is shard-based, using the filesystem with metadata encoded in filenames for lock-free flag operations and atomic updates under concurrent access.
Highlights
- Full SMTP stack — EHLO, AUTH PLAIN/LOGIN, STARTTLS, SMTPS, SIZE enforcement, FROM spoofing detection, per-IP rate limiting
- Outbound relay — authenticated users send to any domain; direct MX delivery (raw DNS UDP) or smarthost; retry schedule up to ~37.5h; DSN bounce generation
- IMAP4rev1 — SELECT, EXAMINE, FETCH, STORE, COPY, MOVE, SEARCH, APPEND, EXPUNGE, IDLE, NAMESPACE, ID, ENABLE, UNSELECT, LITERAL+, SPECIAL-USE
- Exchange HTTP API — stateless JWT authentication, folder and message management, alias management, Thunderbird autoconfig and Exchange autodiscover
- Shard-based storage — lock-free flag changes via
os.rename(),fcntl.flock()only for UID allocation, O(1) message operations - TLS everywhere — auto-generated self-signed certificate on first start, STARTTLS and implicit TLS on all ports, AUTH hidden on cleartext connections
- Zero dependencies — pure Python 3.8+ stdlib, runs on any POSIX system with no package installation
- Aliases and catch-all — per-domain regex rules, exact-match priority, Postfix-style resolution order
- Diagnostics — 8-phase diagnostic suite covering all server components end-to-end
Documentation
Getting Started
Prerequisites, installation from source, initial configuration, and first-run example.
Usage
SMTP, IMAP, Exchange API, and CLI usage patterns with copy-pasteable examples.
Architecture
Module breakdown, data flow, storage model, and key design patterns.
Configuration
All configuration options grouped by subsystem with defaults and descriptions.
Advanced
Outbound relay internals, scaling, TLS operations, diagnostics, and storage migration.
Service Ports
| Port | Protocol | TLS |
|---|---|---|
| 25 | SMTP | STARTTLS |
| 465 | SMTPS | Implicit |
| 587 | Submission (authenticated) | STARTTLS |
| 143 | IMAP | STARTTLS |
| 993 | IMAPS | Implicit |
| 9002 | Exchange HTTP API | None |
| 9003 | Exchange HTTPS API | Implicit |