6.7 KiB
Stalwart setup
Mail Tester reads incoming test mail over JMAP. Stalwart must accept every mail untouched: no rejects, no spam moves, no rewritten headers. Mail Tester does all validation itself.
Written for Stalwart 1.0, where settings are objects in the web admin (not
config.toml). Field names were checked against the official docs: https://stalw.art/docs
1. Accept all mail for the test domain
Goal: every address anything@mail-test.example.org is accepted and lands in one mailbox, and no other
domain on the server is affected.
- DNS: point the MX of the test domain (
MAIL_DOMAIN, e.g.mail-test.example.org) at your Stalwart host, and make sure port 25 is reachable from the internet.mail-test.example.org. IN MX 10 mail.example.org. - Domain: Management › Domains › Domains ✔, add
mail-test.example.org. - Account: create one account, e.g.
catchall@mail-test.example.org. It only needs access to JMAP. Its credentials areJMAP_USER/JMAP_PASSWORD(or use an API key asJMAP_TOKEN). - Catch-all: open the domain you created and set
catchAllAddress✔ tocatchall@mail-test.example.org. Stalwart resolves recipients in this order: sub-address, masked address, account/alias, catch-all ✔. Unknown addresses of this domain are now delivered to the catch-all mailbox instead of being rejected with550 5.1.1 Mailbox does not exist. - Do not enable
allowRelayingon the domain: that would accept unknown recipients but forward them to another server instead of delivering them locally.
Check it from any machine:
swaks --to random-1234@mail-test.example.org --server mail.example.org
Then look for the message in the catch-all mailbox. A 550 means step 4 or the domain in step 2 is missing.
2. Disable validation for the test domain only
Mail Tester does the DKIM, DMARC, SPF, rDNS and blacklist checks itself, so for the test domain Stalwart must not reject, tag or move mail. Other domains on the server keep their normal protection.
Stalwart evaluates most of these settings as expressions, and the recipient domain is only known at the RCPT TO stage, so which settings can be limited to one domain depends on the stage they run at:
| Setting (object) | Stage | Per domain? |
|---|---|---|
dkimVerify, dmarcVerify, arcVerify (SenderAuth) |
per recipient | yes, rcpt_domain |
enableSpamFilter (MtaStageData) |
DATA | yes, rcpt_domain |
spfEhloVerify, spfFromVerify, reverseIpVerify (SenderAuth) |
connection / MAIL FROM | no, recipient unknown yet |
require, rejectNonFqdn (MtaStageEhlo) |
EHLO | no |
2.1 Per-domain settings
In each expression, replace mail-test.example.org with your MAIL_DOMAIN. Every else branch below is the
Stalwart default, so other domains behave exactly as before.
Settings › MTA › Inbound › Sender Authentication (SenderAuth):
{
"dkimVerify": {
"match": { "0": { "if": "rcpt_domain == 'mail-test.example.org'", "then": "disable" } },
"else": "relaxed"
},
"dmarcVerify": {
"match": {
"0": { "if": "rcpt_domain == 'mail-test.example.org'", "then": "disable" },
"1": { "if": "local_port == 25", "then": "relaxed" }
},
"else": "disable"
},
"arcVerify": {
"match": { "0": { "if": "rcpt_domain == 'mail-test.example.org'", "then": "disable" } },
"else": "disable"
}
}
Settings › MTA › Session › Data Stage (MtaStageData), spam filter off for the test domain:
{
"enableSpamFilter": {
"match": { "0": { "if": "rcpt_domain == 'mail-test.example.org'", "then": "false" } },
"else": "is_empty(authenticated_as)"
}
}
Keep SpamSettings.enable (Settings › Spam Filter › General) on, it is the global switch for all domains.
Check the defaults of your instance first and keep them in the else branches if they differ from the ones above.
rcpt_domain is the last recipient of the message. A mail addressed to the test domain and another local
domain at the same time is therefore treated by the last recipient. Test mails have one recipient, so this does not matter.
2.2 Settings that cannot be limited to one domain
SPF and reverse-DNS checks run before the recipient is known. At their defaults (relaxed on port 25) they only
record a result and never reject, and the spam filter that would act on it is off for the test domain (2.1),
so leave spfEhloVerify, spfFromVerify and reverseIpVerify at their defaults.
The EHLO stage can reject before the recipient is known: rejectNonFqdn (default: on port 25) refuses a sender
whose HELO name is not a valid hostname, and the sender gets a bounce instead of a report. If you want the report
anyway, set rejectNonFqdn and require to false (Settings › MTA › Session › EHLO Stage). This applies to
all domains on the server, so for a shared server prefer a dedicated Stalwart instance or listener for the test domain.
2.3 Everything else
- Remove rate limits / auto-ban rules that affect the sending IPs (Settings › Security), otherwise your own repeated tests may get blocked.
- Do not disable the
Receivedheader: Mail Tester reads the sender IP, HELO name and TLS usage from it. - Test: send a mail with a broken DKIM signature or from an IP without SPF to the test domain. It must arrive and show up in the report. The same mail to a normal domain must still be treated by your usual rules.
Older Stalwart (0.11 / 0.15, config.toml)
session.ehlo.require = false
session.ehlo.reject-non-fqdn = false
session.rcpt.catch-all = true
auth.spf.verify.ehlo = "disable"
auth.spf.verify.mail-from = "disable"
auth.dkim.verify = "disable"
auth.dmarc.verify = "disable"
auth.arc.verify = "disable"
auth.iprev.verify = "disable"
spam-filter.enable = false
Catch-all in these versions is an address alias @mail-test.example.org on the account.
3. Auto-delete after 24 hours
Mail Tester purges every message older than 24h via JMAP (Email/set destroy) every 10 minutes and deletes
its reports at the same time. Nothing to configure in Stalwart.
As a safety net you can additionally set an auto-expunge / retention of 1 day in Stalwart for that account.
4. SpamAssassin
compose.yaml and the Helm chart run a spamd sidecar (Dockerfile.spamassassin) and set SPAMD_ADDR for you.
Without SPAMD_ADDR the check is skipped. Stalwart's own spam filter is not used.
5. DNS resolver for blacklists
Spamhaus and others refuse queries from big public resolvers (answer 127.255.255.x; Mail Tester then
reports "query refused" and ignores that list). Run the container with a local recursive resolver (unbound).