bk99.de entertain the web since 1997

Stalwart 1.0: the Rust mail server goes stable and asks for one last migration

Summary

In a post by its project maintainer, Stalwart Labs announces version 1.0 of the mail and collaboration server written in Rust, five years after the first commit. The focus is a final database schema, meant to let future updates run without data migration, and a performance push with rewritten parsers, fewer database round trips and a new full-text search. This post shows what operators need to check when moving from 0.16, how robust the comparison with Postfix and Dovecot is and why the project no longer publishes its tests.

Version 1.0 means one last migration

Stalwart combines SMTP, IMAP, POP3, JMAP, CalDAV, CardDAV and WebDAV with a spam filter and clustering in a single program. The Community edition is licensed under the AGPL-3.0, and a commercial Enterprise edition adds features. It all started on 3 October 2021 with the Rust library mail-parser.

For operators, the most important news is not a new feature: version 1.0 uses a new database layout and will not open a store created by an earlier version. Replacing the binary is therefore not enough. Around a hundred configuration keys were renamed, and some objects (OIDC directories, AI models, Azure storage, forwarded headers) were restructured. The project promises that this is the last migration of its kind and that later versions will upgrade in place.

For 0.16 installations there is the stalwart-migrate tool. It requires 0.16.27, converts the settings and copies all data into a new, empty store; it only reads the old one. The first copy runs while the old server keeps serving, later runs only copy changes, and only the short final run needs the old server stopped. Account and message identifiers, IMAP UIDs and change history are preserved, so clients download nothing again. OAuth users have to sign in again, and the full-text index is rebuilt in the background.

Anyone running 0.15 or older, or wanting to move accounts one at a time, uses the migration proxy and the Vandelay tool: the proxy routes each user to the server holding their account, and each account is switched by changing one entry in a mapping table. The same route is meant to support moving from Postfix and Dovecot to Stalwart.

Check before upgrading

Clusters now need a Redis-based in-memory store (Redis, Redis Cluster or Sentinel); falling back to the data store is no longer possible. Single-node deployments get a built-in local store instead.

Stalwart now fully enforces the “OAuth Profile for Open Public Clients”, an emerging standard that lets any mail client sign in to any mail server via OAuth without prior registration. Many external identity providers do not meet it yet, for example regarding dynamic client registration. Compatibility settings on the OIDC directory relax individual checks at your own risk, but cannot replace a provider that lacks the profile. According to the project, popular clients such as Apple Mail are adopting the profile; their users could then no longer sign in against non-conformant providers.

The web interface no longer identifies itself to the identity provider with a fixed client ID but via a Client ID Metadata Document. If the provider does not support this, register a client there and enter its ID in oauthClientId.

Where the speed comes from

A mail server constantly searches for single bytes: the end of a header line, a MIME boundary, an equals sign in quoted-printable. mail-parser 1.0 was rewritten for this and uses SIMD, i.e. the wide vector registers (SSE2, SSSE3, AVX2, NEON) that compare 16 or 32 bytes with one instruction. Where that does not fit, SWAR takes over: a few arithmetic and bitwise operations let an ordinary 64-bit register test eight bytes at once, without any special instructions. The matching kernel is chosen at runtime, and each one is fuzzed against a plain reference. The new encodify library handles Base64, Base32, quoted-printable and IMAP UTF-7.

On the storage side, Stalwart assigns identifiers inside the same write transaction that uses them, saving whole round trips per delivered message. Objects are compressed with zstd using dictionaries trained on mail, calendar and contact data, and each backend (RocksDB, PostgreSQL, MySQL, FoundationDB, SQLite) is tuned individually. A new cache keeps every account's message index compactly in memory, so IMAP sorting, threading and flag queries hardly need the database any more.

Full-text search now stores word positions and therefore supports real phrase searches. It also indexes text from PDF, Office, OpenDocument, EPUB and RTF files, in attachments as well as in file storage, with its own extractor written in Rust and fixed limits on size and complexity so that crafted files cannot exhaust the server.

Reading the comparison with Postfix and Dovecot correctly

Stalwart ran against Postfix 3.11.7 and Dovecot 2.4.5 on identical Azure servers (8 vCPU AMD EPYC Zen 5, 32 GiB RAM, local NVMe) and won 35 of 38 headline comparisons. A full-text search across 250,000 messages took 3.75 ms instead of 136 ms. Dovecot's three wins all concern the same operation: marking every message in a folder as read at once.

The benchmark repository publishes scripts, raw data and a list of caveats, and that list is worth reading: Postfix writes every incoming message to disk with fsync before confirming it, while Stalwart and Dovecot do not in the tested configuration. Stalwart is compiled for the exact CPU, Postfix and Dovecot are standard builds. The tests used generated rather than real mail and no replication.

Tests are now private

Ten days before the release, the project moved its test suites to a private repository; new features are no longer developed in public and arrive finished in a single commit. The source code of every release remains public under the AGPL-3.0 and is meant to build without the tests.

The reasoning: AI agents can rebuild existing software, and an extensive test suite serves them as an answer key against which they generate code until everything is green. Stalwart reports cloud providers threatening a rewrite under the MIT licence to get rid of AGPL obligations. The project considered a licence such as PolyForm Shield and explicitly rejected it because it is not open source under the Open Source Definition. It cites SQLite as a model, whose most thorough test suite, TH3, has never been published.

Ideas

  • A stable database schema is worth more to operators than any new feature.
  • Incremental migration keeps the old server as a fallback until the last minute.
  • SWAR tests eight bytes per register and needs no special processor instructions.
  • An in-memory message index spares IMAP queries the trip to the database.
  • Full-text search in attachments needs hard limits against crafted documents.
  • Vendor benchmarks are only useful together with their list of caveats.
  • A test suite captures years of edge cases and so becomes knowledge worth protecting.

Insights

  • With 1.0, the project mainly promises calm operations: the migration is paid for dearly once, after that an update is meant to be just an update again. Only the next major version will show whether that holds.
  • The fastest parts of a mail server are unspectacular: searching bytes, saving database round trips, keeping results in memory. Measuring this consistently gains more than new protocols.
  • The debate about AI clones shifts the question of what is worth protecting in free software from the code to the tests. Freedom of the source and verifiability by third parties drift apart a little as a result.

Quotes

  • “A v1.0 server will not open a store created by an earlier version.” (Stalwart blog on v1.0)
  • “Email is forty years of accumulated edge cases, and you do not find them by reading the RFCs.” (Stalwart blog “Private Tests, Public Code”)

Facts

  • Stalwart 1.0.0 was released on 26 October 2026; the first commit of mail-parser dates from 3 October 2021.
  • stalwart-migrate requires version 0.16.27; older installations migrate via the migration proxy and Vandelay.
  • Compared with Postfix 3.11.7 and Dovecot 2.4.5, Stalwart won 35 of 38 headline comparisons.
  • Full-text search across 250,000 messages: 3.75 ms in Stalwart, 136 ms in Dovecot.
  • From 1.0, clusters need Redis, Redis Cluster or Redis Sentinel as the in-memory store.

References

Critique

  • The SMTP figures (5,445 versus 723 incoming messages per second) do not compare the same work: according to the project's own caveats, only Postfix commits every message with fsync before confirming it, and Stalwart is compiled for the test CPU. The headline “fastest mail server on the planet” also rests on a comparison with exactly one opponent.
  • With private tests, distributions and third parties can no longer check a release against the project's test suite. The project acknowledges this cost itself; what remains verifiable is mainly what Stalwart measures and publishes.

Remarks

  • The mail archive from our own post “120,314 mails from 26 years” runs on Stalwart; the migration path above applies to such installations.
  • heise online (iX) reported on 27 October 2026; this post is based on Stalwart's own announcement, changelog and benchmark repository.

Recommendations

  • Before switching, first update to 0.16.27, then run stalwart-migrate into a new, empty store and keep the old server as a fallback until after the switch.
  • Check your external identity provider against the OAuth Profile for Open Public Clients in advance, especially dynamic client registration; otherwise expect sign-in failures after the upgrade.
  • Provide Redis or Sentinel for clusters before installing 1.0.
  • Do not adopt the benchmarks as they are, but reproduce them with REPRODUCE.md from the repository on your own hardware and with the same fsync behaviour.

Read the original article

Search the Web Archive