I am configuring Stalwart MTA and want to enforce strict DKIM verification for incoming mail while ensuring authenticated users can submit outbound mail without being rejected.
The Problem
When setting up a rule to reject incoming emails that lack valid DKIM signatures, authenticated outbound messages (sent via JMAP or SMTP submission on port 587) are also being evaluated against the inbound DKIM check before Stalwart attaches the outbound DKIM signature.
As a result, outbound submission fails with:
Plaintext
550 5.7.20 No passing DKIM signatures found
What We Have Tried
We have spent hours testing various combinations in config.toml and the web UI’s expression engine under signature.rules / validation contexts. We tried targeting sender domains, session types, and evaluation scopes to bypass DKIM checks for authenticated users—but every attempt either broke inbound enforcement or completely blocked outbound submission.
Goal
Inbound: Reject any incoming external email that fails or lacks DKIM verification (550 5.7.20).
Outbound: Allow authenticated local users to submit mail, sign it with the domain’s DKIM key, and relay it out.
Question
How do we properly scope the expression engine rule so that DKIM validation enforcement applies only to unauthenticated inbound sessions (rcpt), while bypassing or signing authenticated outbound sessions (submission) first?
What is the idiomatic config.toml (or JEP/JMAP expression) condition to differentiate context.tls / context.authenticated in the validation workflow?
Thanks for any guidance!
I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.
This confirms dkimVerify uses MtaRcptToVariable, which includes authenticated_as, so you can scope the expression on it to distinguish authenticated submission sessions from anonymous inbound ones.
For your case, set dkimVerify to an expression like:
This makes DKIM verification strict (reject on failure) only for sessions that are not authenticated (i.e. external inbound mail), while authenticated users submitting outbound mail (who have authenticated_as set) skip verification entirely, since their outgoing mail hasn’t been signed yet. Outbound signing is handled separately via dkimSignDomain on the same SenderAuth object, which is applied after this check and is unaffected by the verify setting.
Configure this on the SenderAuth singleton, found in the WebUI under Settings › MTA › Inbound › Sender Authentication, or set the dkimVerify field directly via JMAP/CLI with the JSON expression above instead of editing config.toml, since this is JMAP-managed configuration rather than TOML.
Messages are verified at DATA, before anything gets signed for delivery, so a strict policy that applies to every session will also hit your own users. Scope it with authenticated_as, which is empty for unauthenticated sessions; signature.rules and context.* aren’t Stalwart settings. 0.16 doesn’t read these settings from config.toml either. The setting is dkimVerify under Settings › MTA › Inbound › Sender Authentication:
Authenticated sessions skip verification and get signed on the way out as usual, port 25 is strict, and everything else stays relaxed (SenderAuth | Stalwart).
Before you turn this on for real, strict rejects every unsigned message and every message whose signature got broken along the way, mailing lists being the usual case. Plenty of legitimate senders fall into one of those. If what you’re after is enforcing the sender domain’s own policy, DMARC verification does that without rejecting domains that never sign (DMARC | Stalwart).