Overview: Stalwart is an open-source, all-in-one mail and collaboration server built in Rust that provides comprehensive support for modern email and groupware protocols including IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV. Designed for both small deployments and large-scale enterprise use, it eliminates the need for multiple disparate services by integrating email delivery, calendaring, contacts, file storage, and collaboration features into a single secure system. Its memory-safe architecture, built-in spam/phishing filters, and support for encryption at rest make it a robust alternative to proprietary solutions like Microsoft Exchange or Google Workspace. Stalwart is ideal for organizations seeking full control over their communication infrastructure while maintaining compliance, scalability, and modern protocol standards.
With support for multi-tenancy, Kubernetes, Docker, and pluggable backends like PostgreSQL, RocksDB, and S3-compatible storage, Stalwart caters to DevOps teams and system administrators who need a self-hosted, standards-compliant email platform that can grow with their infrastructure. The project is actively maintained, has undergone security audits, and offers enterprise-grade features such as OpenID Connect authentication, TLS certificate automation via ACME, and real-time monitoring—all without licensing fees.
What You Get
- Full protocol support - Stalwart implements IMAP4rev1/rev2, JMAP (Mail, Calendars, Contacts, File Storage), SMTP with DMARC/DKIM/SPF/ARC, POP3 with STLS/SASL, CalDAV, CardDAV, and WebDAV—all in a single server.
- Built-in spam & phishing protection - Includes LLM-driven analysis, Pyzor collaborative filtering, DNSBL checks, greylisting, spam traps, sender reputation monitoring, and homographic URL detection.
- Pluggable storage backends - Supports RocksDB, FoundationDB, PostgreSQL, MySQL, SQLite, S3-compatible storage, Azure Blob, and Redis for flexible data persistence.
- Automatic TLS certificate provisioning - Uses ACME (Let’s Encrypt) with TLS-ALPN-01, DNS-01, and HTTP-01 challenges to auto-manage SSL certificates.
- Multi-tenancy and domain isolation - Host multiple domains with separate users, quotas, and configurations without cross-tenant leakage.
- JMAP protocol implementation - Modern JSON-based email and calendar API with WebSocket, blob management, and quotas support per RFC standards.
- OpenID Connect & OAuth 2.0 authentication - Supports OIDC, LDAP, SQL, and built-in auth backends with 2FA-TOTP and application passwords.
- Web-based administration dashboard - Real-time monitoring, SMTP queue management, DMARC/TLS-RPT report visualization, log viewer, and full server configuration UI.
- Kubernetes & Docker support - Official Helm charts and Docker images available for containerized deployments with automated scaling.
- Full-text search in 17 languages - Built-in engine or integration with Meilisearch, Elasticsearch, OpenSearch, PostgreSQL, or MySQL.
- Observability stack - OpenTelemetry tracing and metrics, Prometheus integration, webhooks, and alerting via email or HTTP endpoints.
Common Use Cases
- Building a self-hosted email and calendar service for a small business - A company replaces Google Workspace with Stalwart to retain full control over employee emails, calendars, and contacts using IMAP, CalDAV, and CardDAV with S/MIME encryption.
- Deploying a secure mail server for compliance-heavy industries - A healthcare provider uses Stalwart’s built-in DMARC, DKIM, SPF, and encryption-at-rest to meet HIPAA requirements while avoiding third-party cloud providers.
- Scaling a multi-tenant SaaS platform with custom email domains - A B2B SaaS company hosts email for 500+ customer domains using Stalwart’s multi-tenancy, domain isolation, and per-user quotas—all managed via the web UI.
- DevOps teams managing hybrid cloud mail infrastructure - Engineers deploy Stalwart on Kubernetes with PostgreSQL backend and S3 blob storage to handle 10k+ users across AWS, Azure, and on-premises nodes with automated TLS and spam filtering.
- Replacing legacy mail servers like Postfix + Dovecot - Administrators consolidate IMAP, SMTP, Sieve scripting, and CalDAV into a single Rust-based service to reduce maintenance overhead and improve security.
- Creating an open-source alternative to Microsoft Exchange - Organizations seeking a standards-compliant, libre replacement for Exchange Server use Stalwart’s full JMAP and WebDAV support to enable Outlook and Apple Mail clients without proprietary protocols.
Under The Hood
The Stalwart project is a Rust-based, modular mail server platform designed to support a wide range of email protocols and enterprise-grade functionality. It emphasizes extensibility, performance, and robustness through a well-structured crate-based architecture that enables seamless integration of services like IMAP, SMTP, and JMAP.
Architecture
Stalwart follows a layered, modular architecture centered around a monorepo structure that promotes clear separation of concerns and maintainable development.
- The system is organized into distinct crates, each handling specific aspects such as authentication, configuration, and scripting
- It adopts a protocol-agnostic design that allows flexible integration of email services without tight coupling
- The architecture supports role-based access control and extensible plugin systems for dynamic behavior
Tech Stack
Built entirely in Rust, the project leverages system-level performance and memory safety to deliver a high-throughput mail server solution.
- Rust’s type system and concurrency model are central to ensuring correctness and efficiency across email operations
- The ecosystem includes key crates for networking, database support, and scripting capabilities to enable enterprise features
- Docker and cargo-chef are used for containerization and optimized builds, supporting multi-platform deployment
- Comprehensive test suites and linting tools ensure code quality and consistency across modules
Code Quality
Code quality is reflected in the project’s mature structure, extensive testing practices, and adherence to Rust best practices.
- A strong emphasis on testing is evident with a wide range of test coverage across core modules
- Error handling is implemented through custom error types and structured try/catch patterns for robustness
- The codebase demonstrates consistency in naming, structure, and modular design principles
What Makes It Unique
Stalwart stands out through its innovative approach to mail server architecture, combining protocol support with extensibility and enterprise features.
- Native scripting and plugin support allow runtime message processing without requiring server restarts
- The platform integrates LLM-powered capabilities and license management, offering a modern unified mail infrastructure
- Its modular design enables easy adaptation to various enterprise needs and protocol extensions
- Extensive use of Rust’s compile-time guarantees ensures memory safety and high performance in concurrent operations