Skip to main content

Parse and evaluate DMARC email authentication policy

Project description

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

This module allows an application to parse and evaluate email authentication policy, to application supplied TXT RR, SPF and DKIM results.


Use the package manager pip to install dmarc.

pip install dmarc


>>> import dmarc

# represent verified SPF and DKIM status
>>> aspf = dmarc.SPF(domain='', result=dmarc.SPF_PASS)

>>> adkim = dmarc.DKIM(domain='', result=dmarc.DKIM_PASS)

>>> d = dmarc.DMARC()

# parse policy TXT RR
>>> p = d.parse_record(record='v=DMARC1; p=reject;', domain='')

# evaluate policy
>>> r = d.get_result(p, spf=aspf, dkim=adkim)

# check result
>>> r.result == dmarc.POLICY_PASS

# check disposition
>>> r.disposition == dmarc.POLICY_DIS_NONE

>>> r.as_dict()
{'record': {'identifiers': {'header_from': ''}, 'auth_results': {'dkim': {'domain': '', 'result': 'pass'}, 'spf': {'domain': '', 'result': 'pass'}}, 'row': {'count': 1, 'policy_evaluated': {'spf': 'pass', 'dkim': 'pass', 'disposition': 'none'}}}, 'policy_published': {'adkim': 'r', 'domain': '', 'aspf': 'r', 'pct': 100, 'p': 'reject'}}



Project details

Download files

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

Files for dmarc, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size dmarc-1.0.2-py3-none-any.whl (6.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size dmarc-1.0.2.tar.gz (5.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page