Stalwart mail server
Stalwart is the mail server that hosts JBRH Mail, the business mailboxes Connect provides. It runs on Connect's production host and receives and stores mail over SMTP, IMAP and JMAP. Its webhooks tell Connect about new mail and bounces at once. The ops/mail scripts back it up, check its health, and configure domains and DNS.
What it is#
Stalwart is an open-source mail and collaboration server written in Rust by Stalwart Labs. One binary provides SMTP for sending and receiving, IMAP and JMAP for mail clients, spam filtering, and DKIM signing.
It is dual-licensed. The open-source edition is under the GNU AGPL-3.0, and enterprise features come under the Stalwart Enterprise License.
- Category
- Mail server (SMTP, IMAP, JMAP)
- Operations
ops/mail/(bootstrap, backup, restore, health, DNS, admin) andops/mail-relay/- Where it runs
- On the production host, as a systemd service
- Official site
- stalw.art
Where Connect uses it#
| Place in Connect | What it does there |
|---|---|
| JBRH Mail mailboxes | Business addresses on their own domains, synced into Connect's inbox |
| Signed webhooks | /api/webhooks/jbrh-mail/{domain}: instant sync and bounce notices |
ops/mail/backup-mail.sh | Configuration export and message store archives to the private bucket |
ops/mail/mail_dns.py | The MX, SPF, DKIM and DMARC records a domain needs |
How it connects#
- Mail arrives at the domain's MX: Stalwart
- Stalwart stores it and posts a signed webhook to Connect
- Connect fetches the message over IMAP with the mailbox's stored credential
- Replies leave through Stalwart's SMTP, signed with the domain's DKIM key
- Bounces and delivery events return through the same webhook
Benefits and limits#
What it gives Connect:
- Mailboxes on the business's own domain, with no third-party mailbox provider in between.
- Webhooks mean new mail appears without polling delays.
- A single binary with a scriptable configuration export makes backup and restore rehearsable.
Where it stops, and what Connect does about it:
- Running a mail server means owning reputation, DNS correctness and abuse handling.
- AGPL-3.0 has obligations if Stalwart itself is modified and offered over a network. Connect runs it unmodified.
- It shares one host with the rest of the stack, so host capacity covers both.
Security and privacy#
- Account passwords are root-only files on the host, and the admin account's secret is read from a file, never the environment.
- Webhooks are signed per domain and verified before use.
- Backups exclude passwords, and each archive is checked by SHA-256 on both ends.
Licence, cost and versions#
| Question | Answer |
|---|---|
| Licence | AGPL-3.0, or the Stalwart Enterprise License (dual-licensed) |
| Cost | No licence fee for the AGPL edition. The cost is host capacity and operations |
| Version | Not pinned in the repository. The installed version is recorded on the host |
| Compatibility | Standard SMTP, IMAP4rev2 and JMAP clients |
Troubleshooting#
- New mail appears late
- The webhook to Connect failed, so sync fell back to polling. Check the domain's webhook secret.
- Mail to a new domain bounces
- MX or SPF is missing or wrong. Compare with
mail_dns.py's plan. - A client cannot sign in
- The mailbox's app password changed. Re-issue it in Connect and update the client.
Official references#
Questions#
Is JBRH Mail the same as Amazon SES?
No. Stalwart hosts the mailboxes, receiving and storing mail. SES is a sending service that some identities use. They meet in DNS and in Connect's inbox.
Can I use my own mail client with a JBRH Mail mailbox?
Yes, over IMAP and SMTP with the mailbox's app password.