Sub topic 2
Alignment: Tying Authentication to the Visible From Domain
Assume you understand SMTP, DNS TXT records, an email service provider, and raw email headers. This chapter focuses on how authentication connects to the address recipients see.
Alignment and DMARC
SPF authenticates the server named in the SMTP envelope, while DKIM authenticates a domain in the message signature. The visible From header is the domain recipients recognize. Alignment means that an authenticated SPF or DKIM domain matches that visible domain.
DMARC passes when either SPF passes and aligns, or DKIM passes and aligns. Relaxed alignment accepts matching organizational domains. Strict alignment requires exact domain matches.
flowchart TD
A[Visible From: example.com] --> B{Aligned authentication?}
B -->|SPF domain aligns| C[DMARC passes]
B -->|DKIM signing domain aligns| C
B -->|Neither aligns| D[DMARC fails]
C --> E[Receiver applies policy]
D --> EPublishing DMARC and Reading Reports
Publish a DMARC record at _dmarc.example.com. Start with monitoring, then enforce the policy after you understand legitimate senders.
_dmarc.example.com. TXT "v=DMARC1; p=none; rua=mailto:[email protected]"The rua address receives aggregate reports. These reports show sending sources, authentication results, and policy outcomes. After correcting failures, move to p=quarantine or p=reject. Ensure your marketing platform signs with your domain or uses an aligned custom return-path domain.
Sending Infrastructure
Bulk senders should use a stable sending IP or provider configuration with:
- Reverse DNS, or a PTR record, that names the sending host.
- TLS for SMTP connections.
- Valid forward DNS for the hostname.
- Correct MIME structure, headers, and date fields.
- Consistent envelope and visible domains.
These controls do not replace SPF, DKIM, or DMARC. They help receivers identify a legitimate, technically well-formed sender.
One-Click Unsubscribe
Marketing messages should include RFC 8058 headers:
List-Unsubscribe: <https://example.com/unsubscribe/abc123>
List-Unsubscribe-Post: List-Unsubscribe=One-ClickThe endpoint must accept the POST, validate the token, verify the expected form value, and suppress future marketing mail.
from flask import Flask, abort, request
app = Flask(__name__)
@app.post("/unsubscribe/<token>")
def unsubscribe(token):
if request.form.get("List-Unsubscribe") != "One-Click":
abort(400)
if not token_is_valid(token):
abort(404)
mark_opted_out(token)
return "", 200Include these headers in the DKIM signature. Do not require a login or additional confirmation.
Consent and List Hygiene
Send only to people who gave appropriate permission. Record the source, time, and scope of consent. Remove hard bounces, honor unsubscribe requests promptly, and suppress repeatedly inactive recipients. Purchased lists create complaints and damage domain reputation.
Exercise
A message has dkim=pass for mailer.example.net, but its visible From domain is example.com. What must you check?
Show answer
Check whether the domains align under the DMARC mode. If they do not, SPF must pass with an aligned domain for DMARC to pass.