Skip to main content

Parse and evaluate DMARC email authentication policy

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

>>> import dmarc
>>>
>>> # represent verified SPF and DKIM status
>>> aspf = dmarc.SPF(domain='news.example.com', result=dmarc.SPF_PASS)
>>> adkim = dmarc.DKIM(domain='example.com', result=dmarc.DKIM_PASS)
>>> admarc = dmarc.DMARC() # admarc = dmarc.DMARC(publicsuffix.PublicSuffixList())
>>> try:
...     plc = admarc.parse_record(record='v=DMARC1; p=reject;', domain='example.com') # parse policy TXT RR
...     res = admarc.get_result(policy=plc, spf=aspf, dkim=adkim) # evaluate policy
...     res.verify() # check result
...     adict = res.as_dict() # dict repr
... except dmarc.RecordSyntaxError:
...     'invalid dmarc txt rr'
... except dmarc.PolicyNoneError:
...     'res.result == POLICY_FAIL and res.disposition == POLICY_DIS_NONE'
... except dmarc.PolicyQuarantineError:
...     'res.result == POLICY_FAIL and res.disposition == POLICY_DIS_QUARANTINE'
... except dmarc.PolicyRejectError:
...     'res.result == POLICY_FAIL and res.disposition == POLICY_DIS_REJECT'
... except dmarc.PolicyError:
...     'res.result == POLICY_FAIL and unknown disposition error'
...
>>> res.result == dmarc.POLICY_PASS
True
>>> res.disposition == dmarc.POLICY_DIS_NONE
True

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.0.3.tar.gz (5.8 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.0.3-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dmarc-1.0.3.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8

File hashes

Hashes for dmarc-1.0.3.tar.gz
Algorithm Hash digest
SHA256 d7f1fda346deb07a0c707ba2aee72c04d94b7875e4ab42b21af604be80a356ef
MD5 f36aabb5def28f9d51cc6671764e1bf8
BLAKE2b-256 d9671a7d4a4429ecbc150b91667c24112995b567eef61c90d3f425f4b0cfe124

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dmarc-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8

File hashes

Hashes for dmarc-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1c30b3f3b78b635e6083f4ca64ef0738a35abc035bd8cc75a41096dab13748ea
MD5 681b4427031127f6c8473423920be121
BLAKE2b-256 68a6ddfcd4deb39aaa61b346b934bd19d6a0701ba620325172b057e5a0882263

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