mail-auth
Once an email is received (DATA), the mail-auth filter checks its SPF, DKIM, DMARC, ARC and BIMI with the
mailauth library, from the client address, the HELO name, the
envelope sender and the email itself.
- If DMARC fails and the sender domain’s DMARC policy is
reject, the email is refused for the flow. - Otherwise the email is accepted, and the result headers (such as
Authentication-ResultsandReceived-SPF) are added at the top of the stored email. Thefileoutput and therawstorage of theawsandgcpoutputs keep them.
When to use it
Section titled “When to use it”On a server that receives email from the internet for your domains, to drop spoofed emails before they reach your outputs.
How it fits in a flow
Section titled “How it fits in a flow”mail-auth accepts every email that DMARC does not reject. Alone in a flow, it makes the flow take every
recipient, whatever the address. Combine it with a whitelist on to, with the default AND operator, so only
your addresses are accepted, and refused ones get 550 at RCPT TO.
enforceDmarc replaces the DMARC record of every domain with the one you give. "v=DMARC1; p=reject;" refuses
every email that fails DMARC, even from domains that publish a weaker policy or none.
SPF is checked against the client address the server sees. Behind a load balancer or a proxy, that address is
the proxy’s: use options.useProxy (PROXY protocol) or options.useXClient so the server knows the real client.
Options
Section titled “Options”Example
Section titled “Example”Accept emails for auto.loopingz.com that pass DMARC, and log them:
{ "$schema": "https://raw.githubusercontent.com/loopingz/smtp-relay/main/config.schema.json", "flows": { "localhost": { "filters": [ { // Ensure that the email is from a valid domain "type": "mail-auth", // We enforce DMARC policy to avoid shady domains "enforceDmarc": "v=DMARC1; p=reject;" }, { "type": "whitelist", "to": ["regexp:.*@auto.loopingz.com"] } ], "outputs": [ { // We just log to the console "type": "log" } ] } }, // Listen on every interface so the server is reachable from outside its container "bind": "0.0.0.0", "options": { "disableReverseLookup": false, "authOptional": true, "allowInsecureAuth": true }}