Sub topic 7
DMARC: publishing a policy and reading reports
This chapter assumes you can publish TXT records, that SPF, DKIM and alignment from the earlier chapters are working, and that you can read raw email headers. DMARC (Domain-based Message Authentication, Reporting and Conformance, RFC 7489) adds two things to those checks. It tells receivers what to do when a message fails, and it makes receivers send you data about every source that uses your domain.
What DMARC adds to SPF and DKIM
SPF and DKIM each authenticate a domain, but neither one requires that domain to match the address people see. DMARC closes that gap. A message passes DMARC when at least one of these is true:
- SPF passes and the SPF domain (the envelope sender) aligns with the From domain.
- DKIM passes and the
d=signing domain aligns with the From domain.
One aligned pass is enough. This is why the sample header in the spine shows dmarc=pass even though the SPF domain is bounce.example.com. DKIM passed with header.d=example.com, which matches the From domain.
Gmail and Yahoo require a published DMARC record for bulk senders. The minimum is p=none. Microsoft's rules for high-volume mail to Outlook.com, Hotmail and Live also require a DMARC record with alignment. Microsoft's announced enforcement sends non-compliant mail to Junk first and then rejects it, with errors such as 550 5.7.515. The provider chapter compares these in detail. Here, treat p=none plus working alignment as the floor.
Anatomy of the record
A DMARC record is a TXT record at _dmarc.<your domain>. It is a list of tag=value pairs separated by semicolons. v must come first and p second.
| Tag | Meaning | Notes |
|---|---|---|
| `v=DMARC1` | Version | Required, must be first |
| `p` | Policy for the domain | `none`, `quarantine`, or `reject` |
| `sp` | Policy for subdomains | Defaults to `p` if absent |
| `rua` | Where aggregate reports go | Comma-separated `mailto:` URIs |
| `ruf` | Where failure reports go | Few receivers send them; do not rely on them |
| `pct` | Percent of failing mail the policy applies to | Default 100 |
| `adkim`, `aspf` | Alignment mode | `r` relaxed (default) or `s` strict |
| `fo` | Failure report options | Only matters if you use `ruf` |
Here is a starting record, matching the one in the spine:
_dmarc.example.com. TXT "v=DMARC1; p=none; rua=mailto:[email protected]"Check it the same way as the other records:
dig +short TXT _dmarc.example.comEdge cases that break records
- Only one record. If a domain has two TXT records starting with
v=DMARC1, receivers ignore both. Edit the existing record instead of adding a second. - Syntax errors. A misspelled tag or a missing semicolon can make a receiver discard the whole record. Then you have no policy, and bulk-sender checks fail.
- Subdomains. If
_dmarc.news.example.comhas no record, receivers fall back to the record at the organizational domain (example.com) and applyspif it is set. A subdomain with its own record uses that record instead. - Third-party reporting addresses. If
ruapoints to a mailbox in a different domain, the receiving side must authorize it. Otherwise receivers will not send reports there. The destination domain publishes a record that names your domain:
example.com._report._dmarc.reports.example.net. TXT "v=DMARC1"Most DMARC report-processing services handle this for you. If you use your own mailbox on a different domain, add this record yourself.
Choosing a policy
The policy only matters when a message fails DMARC.
p=noneis monitoring mode. Failing mail is delivered as usual, but you still receive reports. This satisfies the Gmail and Yahoo bulk-sender requirement.p=quarantineasks receivers to treat failing mail as suspicious, usually by placing it in spam.p=rejectasks receivers to refuse failing mail during the SMTP conversation.
A common rollout looks like this:
- Publish
p=nonewithrua. Collect reports for two to four weeks. - Fix each legitimate source that fails: add it to SPF, enable DKIM signing with your domain, or set a custom return-path domain.
- Move to
p=quarantine; pct=10, then raisepctin steps (25, 50, 100) while watching reports. - Move to
p=rejectonce failures come only from sources you do not recognize.
Moving past p=none is not required by the three providers' bulk-sender rules. It protects your domain from spoofing, but it also breaks forwarded mail and mailing-list posts that fail alignment. The ARC chapter covers that trade-off.
Reading aggregate reports
Receivers send aggregate reports to your rua address, usually once a day per receiver. Each one is an XML file, normally compressed with gzip or zip, attached to an email. The file has three parts:
report_metadata: who sent the report and for what time range.policy_published: the record the receiver saw when it evaluated your mail. If this differs from what you think you published, check your DNS.- One
recordper combination of source IP and result. It holds thecountof messages, thepolicy_evaluatedresults (dkim,spf,disposition), theheader_fromdomain, and anauth_resultssection that lists the raw SPF and DKIM results with their domains.
The distinction between policy_evaluated and auth_results is useful for debugging. auth_results can show spf=pass for bounce.vendor.example, while policy_evaluated shows spf=fail, because that domain does not align with your From domain. That combination means SPF is working but alignment is not.
Here is a trimmed sample report:
<feedback>
<report_metadata>
<org_name>example.net</org_name>
<report_id>12345</report_id>
</report_metadata>
<policy_published>
<domain>example.com</domain>
<p>none</p>
</policy_published>
<record>
<row>
<source_ip>203.0.113.25</source_ip>
<count>4200</count>
<policy_evaluated>
<disposition>none</disposition>
<dkim>pass</dkim>
<spf>fail</spf>
</policy_evaluated>
</row>
<identifiers><header_from>example.com</header_from></identifiers>
</record>
<record>
<row>
<source_ip>198.51.100.77</source_ip>
<count>35</count>
<policy_evaluated>
<disposition>none</disposition>
<dkim>fail</dkim>
<spf>fail</spf>
</policy_evaluated>
</row>
<identifiers><header_from>example.com</header_from></identifiers>
</record>
</feedback>Save it as report.xml. This script totals messages by source IP and result. It reads .xml and .xml.gz files. It does not unpack .zip attachments, so extract those first.
import gzip
import sys
import xml.etree.ElementTree as ET
from collections import defaultdict
def load(path):
opener = gzip.open if path.endswith(".gz") else open
with opener(path, "rb") as f:
return ET.parse(f).getroot()
def summarize(root):
totals = defaultdict(int)
for rec in root.findall("record"):
row = rec.find("row")
pe = row.find("policy_evaluated")
key = (
row.findtext("source_ip"),
rec.find("identifiers").findtext("header_from"),
pe.findtext("dkim"),
pe.findtext("spf"),
)
totals[key] += int(row.findtext("count"))
return totals
if __name__ == "__main__":
totals = summarize(load(sys.argv[1]))
print("source_ip header_from dkim spf messages")
for (ip, hf, dkim, spf), n in sorted(totals.items(), key=lambda kv: -kv[1]):
verdict = "PASS" if "pass" in (dkim, spf) else "FAIL"
print(f"{ip:<16} {hf:<13} {dkim:<5} {spf:<5} {n:>8} {verdict}")Run python summarize.py report.xml. In the sample, 203.0.113.25 sends 4,200 messages and passes DMARC through DKIM alone. The line 198.51.100.77 fails both checks, with only 35 messages. Look up that IP. It could be a forgotten tool you own or someone spoofing your domain.
Common mistakes
- Reports go to a mailbox nobody reads. Without review,
p=noneis only a checkbox. - Alignment assumed from a pass. A source can show
spf=passand still fail DMARC. Checkpolicy_evaluated. - A vendor sends from a subdomain you did not cover. Check
spand the vendor's DKIM setup. - Treating
rufas a data source. Major receivers rarely send failure reports, partly for privacy reasons.
Exercise
A report shows source IP 192.0.2.10 with 900 messages, headerfrom example.com, authresults spf=pass for bounce.vendor.example and dkim=fail, and policy_evaluated dkim=fail, spf=fail. Your policy is p=none. What happens to these messages, and what do you fix?
Show answer
The messages are delivered normally, because p=none applies no action, but they fail DMARC. SPF passes only for bounce.vendor.example, which does not align with example.com, and DKIM fails. Fix it by having the vendor sign with DKIM using d=example.com (or a subdomain that aligns under relaxed mode), or by setting a custom return-path domain under example.com. Then confirm in later reports that policy_evaluated shows a pass before you tighten the policy.