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 SPF, DKIM, SPFResult, DKIMResult, DMARCPolicy
>>> # Represent verified SPF and DKIM status
>>> spf = SPF(domain='news.example.com', result=SPFResult.PASS)
>>> dkim = DKIM(domain='example.com', result=DKIMResult.PASS)
>>> dmarc = DMARCPolicy(record='v=DMARC1; p=reject;', domain='example.com')
>>> dmarc.verify(auth_results=[spf, dkim, DKIM('mailer.example.net', DKIMResult.PASS)])
>>> adict = dmarc.result.as_dict()
>>>
>>> # 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
>>> from dmarc.tests.report.test_report import TEST_XML_DOCUMENT
>>> adict = DMARCRelaxedSchema.to_dict(TEST_XML_DOCUMENT)
>>>
Milter configuration with Postfix
- Start
dmarc.milter
module or run via Systemd — seecontrib/
. - Start a Postfix instance with a configuration like
smtpd_milters = inet:127.0.0.1:9000
License
Project details
Release history Release notifications | RSS feed
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.1.2.tar.gz
(30.3 kB
view details)
Built Distribution
dmarc-1.1.2-py3-none-any.whl
(35.4 kB
view details)
File details
Details for the file dmarc-1.1.2.tar.gz
.
File metadata
- Download URL: dmarc-1.1.2.tar.gz
- Upload date:
- Size: 30.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
50021d12667a9a5cb504dc7249f991a37da122b545dba19d24a5918e9fedba9b
|
|
MD5 |
c32d6450c24b292ad638298af52566e0
|
|
BLAKE2b-256 |
d6559f430b64629982bc3dace44c47e6084bb490899dac28a3872eb0aa5676cc
|
File details
Details for the file dmarc-1.1.2-py3-none-any.whl
.
File metadata
- Download URL: dmarc-1.1.2-py3-none-any.whl
- Upload date:
- Size: 35.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
d0c15df3820f5a122798da274f243edd046045b430d80c386a0a27e91feafd2b
|
|
MD5 |
1bd589bf60d418111ae6b1d0bd311873
|
|
BLAKE2b-256 |
2c69a6612cbd68b6008b351fd8b34814c1d3212e6b28ba32d52b068943c50f93
|