Multi-master mail clustering built into Dovecot: any number of servers accept deliveries and IMAP changes at the same time and replicate them to each other, normally within a fraction of a second.
This is the dovecotmesh branch of
fragtion/dovecot-core, the
project's main line. The repository keeps its old name so that existing
links keep working.
Coming from the Syncthing setup? That approach is legacy: the
legacy-syncthingbranch of this repository and fragtion/syncthing are no longer developed. See Migrating from the Syncthing setup.Looking for unmodified Dovecot? Go to dovecot/core.
- Built into Dovecot. A
meshservice on each node and ameshmail plugin drive dsync, Dovecot's own incremental mailbox sync. Only what changed is sent: renamed folders aren't copied again, and mails moved or copied between folders are copied locally on the other nodes instead of being transferred. - Any number of nodes. Each user has an anchor node that relays the user's changes to the others. When a node goes down, its users get new anchors automatically.
- Safe deliveries. A delivery is confirmed once the mail is on a
second node, waiting up to
mesh_delivery_sync_timeout(2 s). Optionally, LMTP delivers each user's mail on their anchor (delivery affinity). - Visible. A web UI and
doveadm meshcommands show the nodes, each user's sync status and recent sessions, and can sync, resync, pause and verify. - Self-checking. A verifier compares users' mailboxes across all nodes and repairs differences in the background.
- TLS between nodes.
| Dovecot replicator | Syncthing setup (legacy) | Dovecot Mesh | |
|---|---|---|---|
| Nodes | 2 (removed in Dovecot 2.4) | any | any |
| Replicates | mailboxes, with dsync | Maildir files | mailboxes, with dsync |
| Concurrent changes on two nodes | resolved by dsync | can create duplicates | resolved by dsync |
\Recent flag |
works (per node) | lost (new/ is ignored) |
works (per node) |
| Delivery waits for a second copy | optional | no | yes, up to 2 s |
Build from git (see AGENTS.md for the build dependencies):
autoreconf -vif
./configure --prefix=/opt/dovecot --with-lua=yes # Lua: delivery affinity
make -j$(nproc)
sudo make installThen on every node:
- Use Maildir and deliver mail through Dovecot's LMTP or LDA.
- Add the mesh configuration from
src/mesh/README.md: the
meshplugin,dsync_features = relay-changes reuse-local-mails, the doveadm and mesh HTTP listeners with shared secrets, and onemesh_peerblock per node. Onlyhostnameandmesh_node_namediffer between nodes. - Start Dovecot, then check that every peer is up:
doveadm mesh peers, or the web UI athttp://<node>:8090/.
Tested on one host with the included harness (src/mesh/harness/): 3 to
5 nodes under mixed load (LMTP deliveries plus IMAP flag changes, moves,
copies, expunges and appends on random nodes at once), node crashes, TLS
and delivery affinity, each run ending with all nodes identical and
nothing lost, duplicated or resurrected. Not yet tested on separate
machines, over a real network, or at scale; that's next. Read the
limitations before
using it in production.
| Where | What |
|---|---|
| src/mesh/README.md | How it works, configuration, settings, operation, delivery affinity, monitoring, migration, limitations, test harness |
| docker/README.md | Running it in Docker next to Postfix, migrating from the Syncthing setup |
| src/mesh/HANDOFF.md | The live test plan |
| AGENTS.md | Build environment and running the tests |
| Branch | What it is |
|---|---|
dovecotmesh (default) |
Dovecot Mesh. Upstream changes are merged in regularly. |
main |
An unmodified mirror of dovecot/core main, kept in sync with upstream. |
legacy-syncthing |
The last state of the Syncthing-based fork. Frozen. |
The Dovecot 2.4 development tree (dovecot/core
main), under Dovecot's licenses (see COPYING).
Did this make you happy? I'd love to do more development like this! Please donate to show your support :)
BTC: 1Q4QkBn2Rx4hxFBgHEwRJXYHJjtfusnYfy
XMR: 4AfeGxGR4JqDxwVGWPTZHtX5QnQ3dTzwzMWLBFvysa6FTpTbz8Juqs25XuysVfowQoSYGdMESqnvrEQ969nR9Q7mEgpA5Zm