Skip to content

OpenDMARC validation for Postfix — policies, alignment, and reports

Install OpenDMARC as a Postfix milter, configure SPF + DKIM alignment checks, publish a DMARC TXT record with a sensible policy progression, and route aggregate reports.

DMARC is the only one of SPF / DKIM / DMARC that actually tells receivers what to do with a failed message. This article is the OpenDMARC install we run after opendkim-signing-postfix and spf-policy-records-deep — wire OpenDMARC as a milter, configure header alignment, publish a DMARC TXT record that starts at p=none for observation and graduates to quarantine/reject, and route the aggregate XML reports to a mailbox you actually read.

How to verify

Before publishing any DMARC record, confirm DKIM and SPF both produce pass on a probe message. DMARC compounds the two — if either is broken, DMARC will be too.

dig +short TXT _dmarc.example.com
dig +short TXT example.com   # for the SPF record
dig +short TXT sh2026q2._domainkey.example.com
echo "test" | mail -s "dmarc probe" check-auth@verifier.port25.com
sudo journalctl -u opendmarc -n 50 --no-pager

Run the probe through the submission port (so OpenDKIM signs), wait for the verifier’s reply, and read the Authentication-Results. You want spf=pass, dkim=pass, and dmarc=pass — the last line is what proves alignment works.

What’s happening

DMARC sits on top of SPF and DKIM and adds two things that neither has on its own: a policy (what to do on failure) and alignment (the From: header domain must match either the SPF MAIL FROM domain or the DKIM d= domain). A message that passes SPF for bounces.example.com but has From: alice@example.com will fail DMARC alignment under the default relaxed mode unless the org domain matches.

The policy progression is operational doctrine:

  1. p=none — receivers report but do not act. Run this for at least 4 weeks while you collect aggregate reports and identify every legitimate sender of your domain (CRM, ticketing, internal mailers, the CEO’s personal SaaS).
  2. p=quarantine; pct=10 — receivers spam-folder a percentage of failing mail. Bump pct quarterly.
  3. p=quarantine (pct=100) — full quarantine.
  4. p=reject — receivers refuse failing mail at SMTP time.

OpenDMARC is again a milter — same pattern as OpenDKIM, on a different socket. Order matters: OpenDKIM must be in the milter chain before OpenDMARC, because OpenDMARC reads the Authentication-Results header OpenDKIM produces.

The procedure

  1. Install OpenDMARC. The package ships the milter and a report aggregator:

    sudo apt update
    sudo apt install -y opendmarc
    sudo systemctl status opendmarc --no-pager
  2. Configure OpenDMARC. Edit /etc/opendmarc.conf:

    AuthservID              mx1.example.com
    TrustedAuthservIDs      mx1.example.com
    Socket                  local:/var/spool/postfix/opendmarc/opendmarc.sock
    PidFile                 /run/opendmarc/opendmarc.pid
    UserID                  opendmarc:opendmarc
    UMask                   0002
    IgnoreAuthenticatedClients true
    RejectFailures          false
    FailureReports          false
    FailureReportsBcc       postmaster@example.com
    HistoryFile             /var/lib/opendmarc/opendmarc.dat
    Syslog                  true
    SoftwareHeader          false
    SPFSelfValidate         true

    RejectFailures false matters during the p=none and early p=quarantine phases — let the policy in DNS drive enforcement, not the milter; this avoids surprise drops while you collect telemetry.

  3. Create the socket directory in Postfix’s chroot:

    sudo mkdir -p /var/spool/postfix/opendmarc
    sudo chown opendmarc:postfix /var/spool/postfix/opendmarc
    sudo chmod 750 /var/spool/postfix/opendmarc

    Then /etc/default/opendmarc:

    SOCKET="local:/var/spool/postfix/opendmarc/opendmarc.sock"
  4. Wire OpenDMARC into Postfix after OpenDKIM. The order in smtpd_milters is the order milters run; OpenDMARC needs OpenDKIM’s verdict first:

    smtpd_milters = unix:opendkim/opendkim.sock, unix:opendmarc/opendmarc.sock
    non_smtpd_milters = $smtpd_milters
  5. Publish the DMARC TXT record at _dmarc.example.com. Start at p=none with a reporting address you control:

    _dmarc.example.com.  3600  IN  TXT  "v=DMARC1; p=none; rua=mailto:dmarc-rua@example.com; ruf=mailto:dmarc-ruf@example.com; fo=1; adkim=r; aspf=r; pct=100"

    Verify:

    dig +short TXT _dmarc.example.com

    adkim=r and aspf=r are relaxed alignment — mail.example.com aligns with example.com. Use s (strict) only when subdomain identity needs to be enforced.

  6. Reload Postfix and tail both milter logs:

    sudo systemctl restart opendmarc
    sudo systemctl reload postfix
    sudo journalctl -u opendmarc -u opendkim -f
  7. Run the external probe and confirm full alignment. Same swaks command as in the OpenDKIM article, but check the dmarc= line specifically:

    swaks --to check-auth@verifier.port25.com \
          --from user@example.com --server mx1.example.com:587 -tls \
          --auth LOGIN --auth-user user@example.com --auth-password 'pw'

    The reply should contain dmarc=pass action=none p=none — pass on alignment, action none because policy is p=none.

  8. Set up aggregate (RUA) report ingestion. Major providers (Google, Microsoft, Yahoo) will send daily XML aggregates to the rua= address. Use a tool to parse them: open-source options are parsedmarc (the one we run for clients) and dmarc-srg. Install minimally:

    sudo apt install -y python3-pip
    sudo pip3 install parsedmarc[elastic]
    parsedmarc --version

    Pipe the mailbox through parsedmarc daily; the output is per-source-IP pass/fail counts and the raw XML for the audit trail.

The DMARC progression — operational notes

  • Run p=none for at least 4 weeks. Use the RUA reports to find every sender of your domain — including the CEO’s personal newsletter tool, the ticketing system that pretends to be support@example.com, and the marketing automation platform with its own SPF includes.
  • Add the legitimate senders to SPF and DKIM. Only move to p=quarantine; pct=10 when the RUA reports show >99% pass on a 7-day window.
  • Bump pct by 20-30 per quarter. Hold at pct=100; p=quarantine for one quarter, then move to p=reject.
  • A subdomain that sends mail and doesn’t have its own DMARC record inherits the org-domain policy via the sp= tag. Default behavior is “the same policy”; set sp=none if a subdomain hasn’t been audited yet.

Common pitfalls

  • The milter chain has OpenDMARC before OpenDKIM — OpenDMARC reads an empty Authentication-Results and every check fails; order in smtpd_milters is significant.
  • p=reject is published before SPF and DKIM are fully aligned across every legitimate sender — Gmail and Microsoft hard-bounce mail, including from the CFO; never publish reject without 4+ weeks of RUA evidence.
  • The rua= mailbox has a quota and silently drops daily aggregates from large receivers — use a dedicated account with generous storage, or pipe directly into a database via parsedmarc.
  • A third-party sender (Mailgun, SendGrid, Mailchimp) appears in RUA reports failing alignment because the message goes out as From: user@example.com but the DKIM d= is mg.mailgun.org — the fix is per-vendor (CNAME the DKIM selector under your domain).
  • The DMARC record uses tag=value; with semicolons but a copy-paste from a blog post imports curly quotes — the record is silently invalid; dig +short TXT _dmarc.example.com will show the right characters.

Stack Harbor runs DMARC as a quarterly program in the engagements we run — p=none with RUA ingestion at month one, telemetry-driven progression to quarantine, and reject only after evidence shows zero legitimate failure. If you have a domain stuck at p=none because nobody owns the telemetry, that program is part of our Managed Operations practice.