Sub topic 6
Alignment: tying authentication to the visible From domain
This chapter assumes you can read raw email headers, publish DNS TXT records, and already know what SPF and DKIM check. It covers the step that connects those checks to the address a recipient sees. The three providers expect that connection from bulk senders, and DMARC is built on it.
Why passing SPF and DKIM is not enough
SPF and DKIM each authenticate a domain, but neither one authenticates the domain in the visible From: header.
- SPF checks the envelope sender, also called the
MAIL FROM,Return-Path, or bounce address. The recipient never sees it in a normal mail client. - DKIM checks the domain in the
d=tag of theDKIM-Signatureheader. Any domain that holds a key can sign any message, and the signature can name a domain that has nothing to do with theFrom:address.
A phisher can therefore send a message with From: [email protected], an envelope sender at attacker.example, and a DKIM signature from attacker.example. SPF passes for attacker.example. DKIM passes for attacker.example. Both results are true, and the message is still a forgery from the reader's point of view.
Alignment closes this gap. A check is aligned when the domain it authenticated matches the domain in the visible From: header. DMARC passes only if at least one of SPF or DKIM both passes and aligns.
The two identifiers being compared
| Mechanism | Domain it authenticates | Where to find it in headers |
|---|---|---|
| SPF | Envelope sender (`MAIL FROM`) domain | `smtp.mailfrom=` in `Authentication-Results`, or the `Return-Path` header |
| DKIM | Signing domain, the `d=` tag | `header.d=` in `Authentication-Results`, or `d=` in `DKIM-Signature` |
| DMARC | Visible From domain (RFC 5322 `From:`) | `header.from=` in `Authentication-Results` |
Alignment compares the first two rows against the third.
Strict and relaxed alignment
DMARC defines two alignment modes, set separately for each mechanism with the aspf and adkim tags in the DMARC record.
- Relaxed (
r, the default): the two domains must share the same organizational domain.mail.example.comaligns withexample.com, and so doesnews.example.com. - Strict (
s): the domains must match exactly.mail.example.comdoes not align withexample.com.
The organizational domain is the registrable part of a name, such as example.com or example.co.uk. Receivers determine it with the Public Suffix List.
| From domain | Authenticated domain | Relaxed | Strict |
|---|---|---|---|
| `example.com` | `example.com` | Aligned | Aligned |
| `example.com` | `bounce.example.com` | Aligned | Not aligned |
| `news.example.com` | `example.com` | Aligned | Not aligned |
| `example.com` | `esp.example.net` | Not aligned | Not aligned |
| `example.co.uk` | `other.co.uk` | Not aligned | Not aligned |
Leave both tags at relaxed unless you have a specific reason. Relaxed alignment lets you use subdomains such as bounce.example.com for the envelope sender while keeping example.com in the From: line. Strict mode mainly makes mistakes more likely.
Reading an alignment result
The sample header below comes from the Topic Spine example.
Authentication-Results: mx.example.net;
spf=pass smtp.mailfrom=bounce.example.com;
dkim=pass header.d=example.com header.s=mail1;
dmarc=pass (p=NONE) header.from=example.comWork through it in three steps:
- The visible From domain is
example.com(header.from). - SPF passed, but for
bounce.example.com. Under relaxed alignment this shares the organizational domainexample.com, so it would align. The point of the example is that DMARC does not need it. - DKIM passed with
d=example.com, which matches the From domain exactly. DKIM alone is enough fordmarc=pass.
If the envelope domain were bounce.esp.example.net and the DKIM d= were esp.example.net, both checks would still show pass, but neither would align, and the result would be dmarc=fail.
Why DKIM alignment is the one to rely on
Both paths can work, but they behave differently in practice.
- SPF alignment is fragile. SPF validates the connecting IP against the envelope domain. When a message is forwarded, the forwarder's IP is not in your SPF record, so SPF fails or the envelope sender is rewritten. Alignment then breaks.
- DKIM alignment survives forwarding. The signature travels with the message and stays valid if the signed headers and body are not modified. Mailing lists that add footers or change the subject break it, which is where ARC becomes relevant in a later chapter.
- Many ESPs default to their own domains. An ESP that signs with
d=esp.example.netand uses its own bounce domain gives you passing but unaligned results.
For marketing email, aim for DKIM alignment as the primary path and treat SPF alignment as a second layer. Gmail and Yahoo require that mail from bulk senders pass DMARC, and Microsoft's consumer rules require SPF, DKIM, and DMARC for high-volume senders. In practice that means at least one aligned pass.
Making your mail align
Most alignment failures come from ESP defaults, not from DNS typos. Use this sequence.
- Decide the From domain. Use a domain you control, such as
example.comor a subdomain likenews.example.com. Do not send marketing mail from a free-mail address (@gmail.com). Gmail now rejects or marks those messages for DMARC reasons. - Set up custom DKIM signing at your ESP. This is often called "domain authentication" or "custom signing domain". The ESP gives you a selector and a public key, or CNAME records that point to its keys. Publish them under
selector._domainkey.yourdomain. The result must bed=yourdomainor a subdomain of it. - Set up a custom return-path (bounce) domain. Most ESPs let you use
bounce.example.comwith a CNAME to the ESP. SPF then authenticates a domain that aligns with your From domain. - Send a test message to a mailbox you control and read the result.
- Check the headers for
dkim=pass header.d=matching your domain anddmarc=pass.
The records published in the Topic Spine example show the DKIM and DMARC parts. The DMARC record uses p=none to start, which monitors without affecting delivery:
example.com. TXT "v=spf1 include:_spf.esp.example.net -all"
mail1._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A...(public key from your sender)..."
_dmarc.example.com. TXT "v=DMARC1; p=none; rua=mailto:[email protected]"Note that the SPF record here authorizes the ESP's servers, but SPF alone does not align unless the envelope domain is also yours. The DKIM record under mail1._domainkey.example.com is what supplies alignment in this setup.
Checking alignment with a script
You can test the relaxed rule yourself. The simple version below compares the last two labels, so it is wrong for suffixes such as co.uk. Production code should use the Public Suffix List, for example through the tldextract package.
def org_domain(domain: str) -> str:
# Simplified: last two labels only. Use tldextract for real data.
parts = domain.lower().rstrip(".").split(".")
return ".".join(parts[-2:])
def aligned(from_domain: str, auth_domain: str, mode: str = "relaxed") -> bool:
from_domain = from_domain.lower().rstrip(".")
auth_domain = auth_domain.lower().rstrip(".")
if mode == "strict":
return from_domain == auth_domain
return org_domain(from_domain) == org_domain(auth_domain)
cases = [
("example.com", "example.com"),
("example.com", "bounce.example.com"),
("example.com", "esp.example.net"),
]
for f, a in cases:
print(f, a, "relaxed:", aligned(f, a), "strict:", aligned(f, a, "strict"))Running it prints:
example.com example.com relaxed: True strict: True
example.com bounce.example.com relaxed: True strict: False
example.com esp.example.net relaxed: False strict: FalseCommon errors
- SPF passes, DMARC fails. The envelope domain belongs to the ESP. Configure a custom return-path domain, or rely on DKIM alignment.
- DKIM passes, DMARC fails. The
d=domain is the ESP's, not yours. Enable custom DKIM signing. - Passes in tests, fails after forwarding. SPF alignment broke at the forwarder. Confirm DKIM alignment is in place so the signature carries DMARC through.
- Subdomain surprises. If you send from
news.example.com, DMARC looks for a record at_dmarc.news.example.comfirst and falls back to_dmarc.example.com. Thesp=tag in the parent record sets the policy for subdomains that have no record of their own. - Several systems send as the same domain. The CRM, the billing system, and the marketing platform each need their own aligned DKIM key and selector. A system that is missed will fail DMARC once you tighten the policy.
- Strict mode set by accident.
adkim=soraspf=sbreaks alignment for subdomain signers that would otherwise pass.
Exercise
A marketing email has From: [email protected]. The headers show spf=pass smtp.mailfrom=bounces.vendor-esp.net and dkim=pass header.d=vendor-esp.net. Does DMARC pass, and what is the smallest change that fixes it?
Show answer
DMARC fails. SPF and DKIM both pass, but they authenticate vendor-esp.net, which does not share an organizational domain with example.com, so neither is aligned. The smallest fix is to enable custom DKIM signing at the ESP so messages are signed with d=example.com (publishing the ESP's selector record under _domainkey.example.com). A custom return-path such as bounce.example.com would also give SPF alignment, but DKIM alone is enough and survives forwarding better.
Exercise
Your DMARC record has adkim=s. Your ESP signs with d=mail.example.com, and the From address is [email protected]. Is DKIM aligned? What would change if you removed adkim=s?
Show answer
Not aligned. Strict mode requires an exact domain match, and mail.example.com is not example.com. With the default relaxed mode, both share the organizational domain example.com, so DKIM would align and DMARC would pass.