Concepts · authentication
Forwarding breaks every check receivers make. Here is each repair.
A forwarded message arrives at its destination from your server, carrying someone else's From: address. Every anti-forgery mechanism in mail is designed to catch exactly that. Four features exist to make honest forwarding survive them.
What each check sees, and why it fails
| Check | What breaks when you forward | The repair |
|---|---|---|
| SPF | The destination checks the envelope sender's domain against your IP. The original sender never authorised your host, so it fails. | SRS — rewrite the envelope sender into a domain you control and have authorised. |
| DKIM | The signature covers specific bytes. Change a signed header or a byte of the body and it is invalid. | Touch nothing. mxhop prepends its trace and alters nothing else, so the original signature still verifies. |
| DMARC | Needs SPF or DKIM to pass and align with the From: domain. SRS fixes SPF but aligns it to your domain, not the sender's — so DMARC rests entirely on DKIM surviving. | Keep DKIM intact, and add ARC so a receiver that trusts you can honour what you saw even when it did not. |
| Reverse DNS | Nothing to do with forwarding — but receivers check that your sending IP's PTR resolves back to the name you gave in EHLO. | A PTR record at whoever owns the IP. See DNS. |
The uncomfortable part: SRS makes SPF pass, but aligned to your domain rather than the sender's, so it does not rescue DMARC. If a sender's DKIM signature is broken before it reaches you, or absent, that message will fail DMARC at the destination no matter what mxhop does. ARC is the mechanism for telling the destination what you saw; whether it acts on that is its choice, not yours.
Checking, and the time budget
With [auth] enabled = true (the default), every message is checked at end of DATA, before mxhop answers. SPF, DKIM and DMARC each run against the message and the result is stamped into an Authentication-Results header.
Each stage has its own clock, not a share of one pool:
| SPF | 8 seconds | DNS lookups, bounded by the SPF specification's own limit of ten. |
| DKIM | 6 seconds | One key lookup per signature, and a message may carry many. |
| DMARC | the remainder | The policy lookup plus the alignment decision. |
This split is a defence, not tuning. With one shared timeout, a message carrying forty DKIM signatures pointing at a deliberately slow nameserver spends the entire budget on DKIM, DMARC never runs, and the check fails open — which is to say the forgery gets forwarded. Per-stage clocks mean the expensive stage can only starve itself.
A stage that runs out is treated as a temporary failure, never a pass. The sender gets 451 4.7.1 and retries; the forgery does not get through because the check was slow.
The two enforcement modes
enforce = "off"
Checks run, the verdict is stamped into the header, nothing is ever refused. Every verdict is logged, so you can see what your mail looks like without risking a single legitimate message.
Start here. Run it for a few days and read the logs before tightening.
enforce = "dmarc"
Everything above, plus: a message that fails DMARC when its From: domain publishes p=reject is refused at end of DATA while the sending server still holds it.
The default, and the right setting in public.
Only p=reject triggers a refusal. A domain publishing p=quarantine or p=none has not asked for rejection, so mxhop forwards the message and lets the destination apply its own judgement.
# a forgery claiming to be from a p=reject domain . 550 5.7.1 message from paypal.com fails DMARC and that domain asks for failures to be rejected # the same, but a check could not finish in its budget 451 4.7.1 could not finish checking the signatures on this message from paypal.com, which asks for failures to be rejected (p=reject); try again
Refusing at end of DATA is the whole point. The sending server still has the message, so the refusal is its problem to report to its user. Accept the forgery and forward it instead, and Gmail refuses it with your envelope on it — which counts against your reputation, every time.
SRS — Sender Rewriting Scheme
The envelope sender of a forwarded message is rewritten into a signed address at your SRS domain. The destination then checks SPF against that domain, which authorises your host, and it passes.
# what arrived MAIL FROM:<alice@sender.example> # what mxhop sends onward MAIL FROM:<SRS0=a1b2c3=TW=sender.example=alice@example.com>
The encoded part carries a signature, a timestamp and the original address. Three things follow from that, and all three matter:
- Bounces come back to you, at that address, and mxhop verifies the signature before accepting one. A bounce to an address it cannot verify is refused — otherwise the rewritten address is a relay anyone who has seen one can use.
- The signature expires after
max_age_days(default 7, ceiling 365). An address that never expires is a permanent open relay. - Keys rotate. The secret file holds one key per line: the first signs new addresses, the rest are still accepted. Add a new line at the top, and old bounces keep working while new ones use the new key.
The SRS domain's MX must point at this host and its SPF must authorise it. Rewriting into a domain whose mail goes elsewhere means bounces land somewhere that cannot verify them; rewriting into one whose SPF does not cover you means you have changed which SPF check fails, not fixed it.
The secret file must be 0600. Anyone who can read it can forge an address this host relays.
ARC — sealing what this hop saw
ARC (RFC 8617) is the answer to a specific problem: when forwarding breaks DMARC, the destination has no way to know the message was fine when it reached you. An ARC seal is a signed statement of what authentication found at this hop, which a receiver that trusts you can act on.
mxhop adds three headers per hop — the authentication results it found, a signature over the message, and a seal over the chain so far — and validates any existing chain before extending it, so a forged chain is not silently carried forward.
# what Gmail reported on a message forwarded through mxhop arc=pass (i=1 spf=pass spfdomain=sender.example dkim=pass dkdomain=sender.example dmarc=pass fromdomain=sender.example) # and Gmail then extended the chain itself i=2; cv=pass
That is real output from a production message, not an example. arc=pass means Gmail accepted the seal; i=2; cv=pass means it validated the existing chain and added its own link.
Setting it up is a key and a DNS record. check prints the exact record name:
openssl genrsa -out /etc/mxhop/arc.key 2048 chmod 600 /etc/mxhop/arc.key && chown mxhop:mxhop /etc/mxhop/arc.key mxhop check /etc/mxhop/mxhop.toml: publish the ARC public key as a TXT record at arc1._domainkey.example.com
RSA only. An Ed25519 key is refused with a message saying exactly that, rather than failing somewhere obscure at signing time. 2048 bits is right; a longer key makes a TXT record that needs splitting for no benefit.
ARC is only as useful as the receiver's trust in you. A seal from a host with no sending history buys little. It is not a way around DMARC; it is a way to tell the truth about a hop, in a form large receivers have agreed to read.
What ends up in the message
mxhop adds headers and removes none. Original headers, including any Authentication-Results from an earlier hop, are left exactly as they arrived.
| Received | always | One trace line, prepended. The only header mxhop adds unconditionally, and the reason the hop can be counted. |
| Authentication-Results | when [auth] enabled | What SPF, DKIM and DMARC found here, authority-stamped with this host's name. |
| ARC-Authentication-ResultsARC-Message-SignatureARC-Seal | when [arc] is set | The three-header set for this hop's link in the chain. |