Skip to main content

DMARC (Domain-based Message Authentication, Reporting & Conformance)

DMARC email authentication module implemented in Python.

Installation

Use the package manager pip to install dmarc.

$ pip install dmarc

Usage

>>> from dmarc import SPFAuthResult, DKIMAuthResult, SPFResult, DKIMResult, DMARCPolicy
>>> # Represent verified SPF and DKIM identifiers
>>> spf = SPFAuthResult('news.example.com', SPFResult('pass'))
>>> dkim = DKIMAuthResult('example.com', DKIMResult('pass'))
>>> policy = DMARCPolicy(record='v=DMARC1; p=reject;', domain='example.com')
>>> policy.verify(auth_results=[spf, dkim])
>>> 
>>> # RR resolver example
>>> from dmarc.resolver import resolve, RecordNotFoundError, RecordMultiFoundError
>>> from dmarc.psl import get_public_suffix
>>> domain = 'news.example.com'
>>> try:
...     record = resolve(domain)
... except (RecordNotFoundError, RecordMultiFoundError):
...     org_domain = get_public_suffix(domain)
...     if org_domain != domain:
...         record = resolve(org_domain)
... 
>>> # Aggregate report XML document to dict example
>>> from dmarc.report import DMARCRelaxedSchema, DMARC2Schema
>>> from dmarc.tests.report.test_report import TEST_XML_DOCUMENT, TEST_XML_DOCUMENT_2
>>> relaxed = DMARCRelaxedSchema.to_dict(TEST_XML_DOCUMENT)
>>> rfc9990 = DMARC2Schema.to_dict(TEST_XML_DOCUMENT_2)
>>> 

Milter configuration with Postfix

  1. Start dmarc.milter module or run via Systemd — see contrib/.
  2. Start a Postfix instance with a configuration like smtpd_milters = inet:127.0.0.1:9000

Described here 👉 Run DMARC Milter with Postfix.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dmarc-1.2.1.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dmarc-1.2.1-py3-none-any.whl (34.2 kB view details)

Uploaded Python 3

File details

Details for the file dmarc-1.2.1.tar.gz.

File metadata

  • Download URL: dmarc-1.2.1.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for dmarc-1.2.1.tar.gz
Algorithm Hash digest
SHA256 f620ab69102a4be060f5e6fcf7ad93e6c1bf17807ab36f9a44df188c2191a43d
MD5 b25da7e7cc14d2b3632e668902ad83c6
BLAKE2b-256 10a2d511e02a693c33d8cc66c197485ffc6d3094524f1b2e75d3682f8b90902c

See more details on using hashes here.

File details

Details for the file dmarc-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: dmarc-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 34.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for dmarc-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ad5132e19a118aa2c7edaeff151f4d2eef2da853a68df4a3cab23402b1c8e351
MD5 fdabb4c5623896d15cff6ffb31bba810
BLAKE2b-256 6c4f488922dd2710a392e78f7abc662c222cff74b10bcfbca861e25f801418f3

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 files

1.2.0

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

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