Skip to main content

Crate mailrs_dmarc

Crate mailrs_dmarc 

Source
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:

The original 1.0 surface (aggregate reporting, store trait, XML builder, mailto extraction) is unchanged:

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§

DmarcResultRecord
One verified DMARC result, recorded per inbound message.
PgDmarcStore
Postgres-backed DmarcStore. Expects a table:

Traits§

DmarcStore
Pluggable storage for DMARC verification results.

Functions§

extract_rua_from_dmarc_record
Extract the rua mailbox 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).