Skip to main content

dmarc-check

Checks a domain's mail authentication records (SPF, DMARC, DKIM, MX, MTA-STS and TLS-RPT) in CI. It is a GitHub Action and a command line tool, and both use the same engine.

All checks are local DNS lookups made with dnspython, plus one HTTPS request for the MTA-STS policy. The tool sends nothing to Lookproof or anyone else and has no telemetry. Each finding links to a page on lookproof.dev/findings that explains it and how to fix it.

What it checks

Area Checks
SPF A record exists and there is exactly one. Syntax is valid. At most 10 DNS lookups, counted recursively through include: and redirect=. At most 2 void lookups. Includes that are missing or loop. +all (error) and ?all (warning).
DMARC A record exists at _dmarc.<domain> and there is exactly one. p, sp and np are valid, with a warning for p=none and for sp=none or np=none under an enforcing p. Warns when pct is below 100 or t=y is set. Notes a missing rua (info).
DKIM Only the selectors you pass in. The key exists, there is one record and it parses. RSA keys under 2048 bits warn; keys under 1024 bits are an error. Revoked keys (p=) and testing mode (t=y). Ed25519 is supported.
MX MX records exist. Null MX (0 ., RFC 7505) is recognised: the domain counts as accepting no mail, and MTA-STS and TLS-RPT are skipped. Null MX mixed with other records, MX targets that are IP addresses, and MX hosts without A/AAAA records.
MTA-STS The _mta-sts TXT record (v=STSv1, id). The policy is fetched from https://mta-sts.<domain>/.well-known/mta-sts.txt with certificate and host name validation. Redirects are not followed, and the response must be text/plain and at most 64 KiB. Checks the policy syntax, mode, a max_age of at least one day, and that every MX host matches an mx: line.
TLS-RPT _smtp._tls has one v=TLSRPTv1 record with a rua of mailto: or https: URIs.

DNS timeouts and resolver failures are reported as errors, so a check that could not run never passes silently.

Quick start

Check on pull requests

# .github/workflows/mail-auth.yml
name: Mail authentication
on:
  pull_request:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  dmarc-check:
    runs-on: ubuntu-latest
    steps:
      - uses: lookproof/dmarc-check@v1
        with:
          domains: example.com, example.org
          dkim-selectors: google, s1
          fail-on: error

Daily check that opens an issue

The action opens one issue while the check fails, updates it on later runs, and closes it once the check passes. Issues are matched on their exact title.

# .github/workflows/mail-auth-daily.yml
name: Mail authentication (daily)
on:
  schedule:
    - cron: "23 5 * * *"
  workflow_dispatch:

permissions:
  contents: read
  issues: write

jobs:
  dmarc-check:
    runs-on: ubuntu-latest
    steps:
      - uses: lookproof/dmarc-check@v1
        with:
          domains: example.com
          dkim-selectors: google
          fail-on: warn
          create-issue: true

Inputs

Input Default Description
domains (required) Comma-separated domains.
dkim-selectors "" Comma-separated DKIM selectors, checked on every domain. DKIM is skipped when this is empty.
fail-on error error, warn, info or none, and/or a comma list of finding ids. A severity fails on that severity or worse. Ids fail on that finding whatever its severity. You can combine them, e.g. error,dmarc-policy-none.
resolver "" Comma-separated DNS server IPs. Defaults to the runner's resolver.
create-issue false Open, update and close one tracking issue. Needs issues: write.
issue-title dmarc-check: mail authentication problems Title used to find the tracking issue.
github-token ${{ github.token }} Token for create-issue.
python-version 3.12 Python used to run the tool. It is not added to PATH for later steps.

Outputs

Output Description
json Every finding as JSON (same format as dmarc-check --json).
exit-code 0 when nothing matches fail-on, 1 when something does, 2 on invalid input.

The step exits with the same code, so a failing check fails the job. To keep going and read the result yourself, set continue-on-error: true on the step and read steps.<id>.outputs.json.

Summary output

The action writes a table to the job summary. Findings that match fail-on are shown in bold:

dmarc-check

❌ Failed (fail-on: error): 1 error, 2 warnings, 1 info

Domain Severity Finding Details
example.com error spf-too-many-lookups SPF needs 13 DNS lookups (limit 10)
example.com warn dmarc-policy-none DMARC policy is p=none: spoofed mail is reported but still delivered
example.com warn dkim-weak-key Selector s1: 1024-bit RSA key; use 2048 bits
example.com info tlsrpt-not-found No TLS-RPT record at _smtp._tls.example.com; you will not hear about inbound TLS failures
example.org ok No findings

Want daily monitoring, alerts and DMARC report parsing? → https://senderward.com

Findings that match fail-on are also added to the run as error annotations.

Command line

pip install dmarc-check
dmarc-check example.com --dkim-selector s1 --json
usage: dmarc-check [-h] [--dkim-selector SELECTOR] [--fail-on FAIL_ON] [--resolver IP]
                   [--timeout TIMEOUT] [--json] [--version]
                   domains [domains ...]

--dkim-selector and --resolver can be repeated or comma-separated. The exit codes are the same as the action's: 0 passed, 1 a finding matched --fail-on, 2 invalid arguments.

Text output:

example.com
  error  spf-too-many-lookups *
         SPF needs 13 DNS lookups (limit 10)
         https://lookproof.dev/findings/spf-too-many-lookups
  warn   dmarc-policy-none
         DMARC policy is p=none: spoofed mail is reported but still delivered
         https://lookproof.dev/findings/dmarc-policy-none

FAILED (fail-on: error): 1 error, 1 warning, 0 info
* = matches fail-on

JSON output:

{
  "tool": "dmarc-check",
  "version": "1.0.0",
  "fail_on": "error",
  "failed": true,
  "exit_code": 1,
  "counts": { "error": 1, "warn": 1, "info": 0 },
  "domains": [
    {
      "domain": "example.com",
      "findings": [
        {
          "id": "spf-too-many-lookups",
          "severity": "error",
          "check": "spf",
          "domain": "example.com",
          "message": "SPF needs 13 DNS lookups (limit 10)",
          "url": "https://lookproof.dev/findings/spf-too-many-lookups"
        }
      ]
    }
  ]
}

Findings

Id Severity Meaning
spf-not-found error No SPF record.
spf-multiple-records error More than one SPF record on the domain or an included domain.
spf-syntax-error error Unknown mechanism, bad IP or prefix, invalid domain, duplicate modifier.
spf-too-many-lookups error More than 10 DNS-querying terms, counted recursively.
spf-too-many-void-lookups error More than 2 lookups returned NXDOMAIN or no data.
spf-include-not-found error An include: or redirect= target has no SPF record.
spf-include-loop error Includes or redirects form a loop.
spf-pass-all error The record ends in +all (or bare all).
spf-neutral-all warn The record ends in ?all.
spf-ptr-mechanism warn Uses the deprecated ptr mechanism.
spf-no-all info No all and no redirect=.
spf-macro-not-evaluated info Macro terms are counted but not resolved.
dmarc-not-found error No DMARC record at _dmarc.<domain>.
dmarc-multiple-records error More than one DMARC record.
dmarc-syntax-error error Malformed or duplicate tags, bad pct, adkim or aspf.
dmarc-invalid-policy error p is missing, or p, sp or np has an invalid value.
dmarc-policy-none warn p=none.
dmarc-subdomain-policy-none warn sp=none or np=none while p enforces.
dmarc-partial-pct warn pct below 100.
dmarc-testing-mode warn t=y.
dmarc-invalid-report-uri warn A rua or ruf URI is not a valid mailto:.
dmarc-no-rua info No rua tag, so no aggregate reports are sent.
dmarc-unknown-tag info Tags that receivers ignore.
dkim-not-found error No key at <selector>._domainkey.<domain>.
dkim-multiple-records error More than one key record for a selector.
dkim-syntax-error error Malformed tags, or v= that is not DKIM1 or not first.
dkim-invalid-key error The key is not valid base64, cannot be parsed, or has an unknown k=.
dkim-key-too-short error RSA key under 1024 bits.
dkim-weak-key warn RSA key from 1024 up to 2047 bits.
dkim-key-revoked warn Empty p=.
dkim-testing-mode info t=y.
dns-domain-not-found error The domain does not exist (NXDOMAIN).
mx-null-with-others error A null MX next to other MX records.
mx-target-is-ip error An MX points to an IP address.
mx-target-unresolvable error An MX host has no A or AAAA record.
mx-not-found warn No MX records (implicit MX via A/AAAA).
mx-null info Null MX: the domain accepts no mail.
mtasts-multiple-records error More than one _mta-sts record.
mtasts-invalid-record error The _mta-sts record lacks v=STSv1 or a valid id.
mtasts-policy-unavailable error The policy could not be fetched: TLS or certificate error, redirect, or a status other than 200.
mtasts-invalid-policy error Wrong content type, too large, or invalid policy fields.
mtasts-mx-not-covered error An MX host matches no mx: line in an enforce policy.
mtasts-mx-not-covered-testing warn Same, in a testing policy.
mtasts-mode-none warn mode: none.
mtasts-low-max-age warn max_age under 86400 seconds.
mtasts-mode-testing info mode: testing.
mtasts-not-found info No MTA-STS record.
tlsrpt-invalid warn Several records, a missing rua, or a URI that is not mailto: or https:.
tlsrpt-not-found info No TLS-RPT record.
dns-resolver-timeout error A DNS query timed out, so the check is incomplete.
dns-resolver-failure error A DNS query failed (SERVFAIL, refused), so the check is incomplete.
check-internal-error error A bug in dmarc-check. Please open an issue.

Development

pip install -e ".[dev]"
ruff check . && ruff format --check . && mypy && pytest

The unit tests use a fake resolver and need no network. pytest -m network checks that every finding link exists in the lookproof.dev sitemap.

License

MIT

Metadata

Release files for dmarc-check 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dmarc-check 1.0.0
File Size Uploaded Provenance Actions
dmarc_check-1.0.0.tar.gz 36.3 kB With provenance Details for dmarc_check-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dmarc-check 1.0.0
File Interpreter ABI Platform Actions
dmarc_check-1.0.0-py3-none-any.whl Python 3 none any Details for dmarc_check-1.0.0-py3-none-any.whl

Total release size: 67.5 kB

Release files / dmarc_check-1.0.0.tar.gz

Download URL dmarc_check-1.0.0.tar.gz
Size 36.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fc8f476ff0c371e9b0d39bc9afb2177395cf0aae177fa99eb4e47f6202c6d851
BLAKE2b-256 checksum
How to use checksums
a51ba1a1f6737ef26e802bb96862297bbddf9a2e9c1b698d4296609c049f2e9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / dmarc_check-1.0.0-py3-none-any.whl

Download URL dmarc_check-1.0.0-py3-none-any.whl
Size 31.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56f2af8a1522e8dbff0da83a7bc65ada1831fe45640dd54f7b4506a5ac9be781
BLAKE2b-256 checksum
How to use checksums
c4158e46d330fe44d8f07c03f2e299d27f950870bd537919b1fc3757d6ded869
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for dmarc-check 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dmarc_check-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page