Skip to main content

DMARC library and milter module implemented in Python.

Project description

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

Project details


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.0.tar.gz (36.9 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.0-py3-none-any.whl (42.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dmarc-1.2.0.tar.gz
  • Upload date:
  • Size: 36.9 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.0.tar.gz
Algorithm Hash digest
SHA256 09b806e282ae56ddaf2539a4cb83300e6a5d0192b79d87a2bcb8df039c590ad4
MD5 e7dc66dfb0b4174dba4187a68fd9470f
BLAKE2b-256 f739d77c75ec051af57220d81b7a4eaa12351d0fbf6d15f6aaaf2d7bedd2a7d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dmarc-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 42.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4056babb8cce9812d5f412811a29cc1916ca4dc9db9668e1ab10d31a1668ae23
MD5 919d0646928c5f21787c3c7932912807
BLAKE2b-256 07785a8f009eb80279126d8d7149d275f454e775be561f34fcee503a02b5f155

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page