Expand description
DMARC (RFC 7489) — policy parsing, identifier alignment, message evaluation, and aggregate-report generation.
§1.1 — full mail-auth replacement
As of 1.1 this crate fully replaces the DMARC half of
stalwart/mail-auth:
policy::DmarcPolicy::parse— TXT record parser (RFC 7489 §6.3).align::check— identifier alignment, strict + relaxed (RFC 7489 §3.1).eval::evaluate— pure-function DMARC outcome from SPF + DKIM verdicts + policy (RFC 7489 §6.6).
The original 1.0 surface (aggregate reporting, store trait, XML builder, mailto extraction) is unchanged:
- Result recording —
DmarcStoretrait + a Postgres reference impl (PgDmarcStore) behind the defaultpg-storefeature. - Aggregate XML report generation —
generate_dmarc_report_xmlproduces the canonical<feedback>document aruamailbox expects. - Report-mail formatting —
format_report_emailwraps the gzipped XML into the multipart/mixed envelope per §7.2.1. ruaextraction —extract_rua_from_dmarc_recordpulls amailto:URI out of a_dmarc.<domain>TXT record.
The crate is store-agnostic by default: implement DmarcStore over
whatever you have (SQLite, Redis, S3 + flat files), feed verified
results in via DmarcStore::record_result, and at report time
pull a day’s results with DmarcStore::get_results_for_date and
pass them to generate_dmarc_report_xml.
§Example
use mailrs_dmarc::{
DmarcResultRecord, format_report_email, generate_dmarc_report_xml,
};
let results = vec![DmarcResultRecord {
source_ip: "192.0.2.1".into(),
from_domain: "example.com".into(),
spf_result: "pass".into(),
dkim_result: "pass".into(),
dmarc_result: "pass".into(),
disposition: "none".into(),
}];
let xml = generate_dmarc_report_xml(
"Example Inc.", "postmaster@reporter.example",
"example.com!2026-05-20", "example.com",
1715990400, 1716076800, &results,
);
let email = format_report_email(
"postmaster@reporter.example", "rua@example.com",
"example.com", "example.com!2026-05-20",
"2026-05-20", &xml,
);Re-exports§
pub use align::check as align_check;pub use align::organizational_domain;pub use eval::evaluate;pub use eval::DkimSignatureResult;pub use eval::DmarcInput;pub use eval::DmarcOutcome;pub use eval::SpfResult;pub use policy::Alignment;pub use policy::DmarcParseError;pub use policy::DmarcPolicy;pub use policy::PolicyAction;
Modules§
- align
- DMARC identifier alignment (RFC 7489 §3.1).
- eval
- DMARC evaluation (RFC 7489 §6.6).
- policy
- DMARC policy record parser (RFC 7489 §6.3).
Structs§
- Dmarc
Result Record - One verified DMARC result, recorded per inbound message.
- PgDmarc
Store - Postgres-backed
DmarcStore. Expects a table:
Traits§
- Dmarc
Store - Pluggable storage for DMARC verification results.
Functions§
- extract_
rua_ from_ dmarc_ record - Extract the
ruamailbox from a_dmarc.<domain>TXT record. - format_
report_ email - Format a DMARC aggregate report email with a gzipped XML attachment.
- generate_
dmarc_ report_ xml - Generate a DMARC aggregate report XML body (RFC 7489 §12.4).