Skip to content

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-Results and Received-SPF) are added at the top of the stored email. The file output and the raw storage of the aws and gcp outputs keep them.

On a server that receives email from the internet for your domains, to drop spoofed emails before they reach your outputs.

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.

OptionTypeDescription
enforceDmarcstring

DMARC record used for every domain instead of its published _dmarc record, e.g. v=DMARC1; p=reject;

mailauthobject

Options of the mailauth authenticate call

mailauth.disableArcboolean

Disable ARC checks

mailauth.disableBimiboolean

Disable Bimi checks

mailauth.disableDmarcboolean

Disable Dmarc checks

mailauth.maxResolveCountnumber
default 10

DNS lookup limit for SPF. RFC7208 requires this limit to be 10.

mailauth.maxVoidCountnumber
default 2

DNS lookup limit for SPF that produce an empty result. RFC7208 requires this limit to be 2.

mailauth.minBitLengthnumber
default 1024

Minimum allowed bits of RSA public keys. If a DKIM or ARC key has fewer bits, then validation is considered as failed

namestring

Name of the component, used in the logs and the output metrics, defaults to <type>_<position in the list>

typerequired"mail-auth"

Type of the component

Accept emails for auto.loopingz.com that pass DMARC, and log them:

configs/mailauth-filter.jsonc
{
"$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
}
}