# DMARC (Domain-based Message Authentication, Reporting & Conformance)
DMARC email authentication module implemented in Python.
## Installation
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install dmarc.
```console
$ pip install dmarc
```
## Usage
```python
>>> 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
>>> from dmarc.tests.report.test_report import TEST_XML_DOCUMENT
>>> adict = DMARCRelaxedSchema.to_dict(TEST_XML_DOCUMENT)
>>>
```
### Milter configuration with Postfix
1. Start `dmarc.milter` module or run via Systemd — see
[`contrib/`](contrib/dmarcmilter.service).
2. Start a Postfix instance with a configuration like
`smtpd_milters = inet:127.0.0.1:9000`
Described here 👉 [Run DMARC Milter with Postfix](https://gitlab.com/duobradovic/pydmarc/-/blob/master/dmarc/milter/README.md).
## License
[MIT](https://choosealicense.com/licenses/mit/)
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/duobradovic/pydmarc",
"name": "dmarc",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "dkim, spf, dmarc, email, authentication, milter, rfc7489, rfc8601",
"author": "Dusan Obradovic",
"author_email": "dusan@euracks.net",
"download_url": "https://files.pythonhosted.org/packages/d6/46/ae4561951fb3cd41d7af3f0d9978de619b4a51b56ad1c136ebf6dbb0d51e/dmarc-1.1.3.tar.gz",
"platform": null,
"description": "# DMARC (Domain-based Message Authentication, Reporting & Conformance)\n\nDMARC email authentication module implemented in Python.\n\n## Installation\n\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install dmarc.\n\n```console\n$ pip install dmarc\n```\n\n## Usage\n\n```python\n>>> from dmarc import SPFAuthResult, DKIMAuthResult, SPFResult, DKIMResult, DMARCPolicy\n>>> # Represent verified SPF and DKIM identifiers\n>>> spf = SPFAuthResult('news.example.com', SPFResult('pass'))\n>>> dkim = DKIMAuthResult('example.com', DKIMResult('pass'))\n>>> policy = DMARCPolicy(record='v=DMARC1; p=reject;', domain='example.com')\n>>> policy.verify(auth_results=[spf, dkim])\n>>> \n>>> # RR resolver example\n>>> from dmarc.resolver import resolve, RecordNotFoundError, RecordMultiFoundError\n>>> from dmarc.psl import get_public_suffix\n>>> domain = 'news.example.com'\n>>> try:\n... record = resolve(domain)\n... except (RecordNotFoundError, RecordMultiFoundError):\n... org_domain = get_public_suffix(domain)\n... if org_domain != domain:\n... record = resolve(org_domain)\n... \n>>> # Aggregate report xml document to dict example\n>>> from dmarc.report import DMARCRelaxedSchema\n>>> from dmarc.tests.report.test_report import TEST_XML_DOCUMENT\n>>> adict = DMARCRelaxedSchema.to_dict(TEST_XML_DOCUMENT)\n>>> \n```\n\n### Milter configuration with Postfix\n\n1. Start `dmarc.milter` module or run via Systemd \u2014 see\n [`contrib/`](contrib/dmarcmilter.service).\n2. Start a Postfix instance with a configuration like\n `smtpd_milters = inet:127.0.0.1:9000`\n\nDescribed here \ud83d\udc49 [Run DMARC Milter with Postfix](https://gitlab.com/duobradovic/pydmarc/-/blob/master/dmarc/milter/README.md).\n\n## License\n[MIT](https://choosealicense.com/licenses/mit/)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "DMARC library and milter module implemented in Python.",
"version": "1.1.3",
"project_urls": {
"Homepage": "https://gitlab.com/duobradovic/pydmarc"
},
"split_keywords": [
"dkim",
" spf",
" dmarc",
" email",
" authentication",
" milter",
" rfc7489",
" rfc8601"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "90905b1c91da76452b9a62bf323481730f242bff61ca3580d86b3fdfac6dd5f9",
"md5": "a9c8c09ef4b39b19b4a3b045898b458c",
"sha256": "0c070c97594e63d8601b0f1ada842abc0b8b5cd0475e77b805acbf029fc32912"
},
"downloads": -1,
"filename": "dmarc-1.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a9c8c09ef4b39b19b4a3b045898b458c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 37771,
"upload_time": "2025-08-07T13:36:29",
"upload_time_iso_8601": "2025-08-07T13:36:29.630254Z",
"url": "https://files.pythonhosted.org/packages/90/90/5b1c91da76452b9a62bf323481730f242bff61ca3580d86b3fdfac6dd5f9/dmarc-1.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d646ae4561951fb3cd41d7af3f0d9978de619b4a51b56ad1c136ebf6dbb0d51e",
"md5": "84d1228fba30705bd4a9c585a6ea26e9",
"sha256": "cbbfc955ab9cb719a997075c89371c07c81909a8ca688e3079477d23986849d0"
},
"downloads": -1,
"filename": "dmarc-1.1.3.tar.gz",
"has_sig": false,
"md5_digest": "84d1228fba30705bd4a9c585a6ea26e9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 33429,
"upload_time": "2025-08-07T13:36:31",
"upload_time_iso_8601": "2025-08-07T13:36:31.127933Z",
"url": "https://files.pythonhosted.org/packages/d6/46/ae4561951fb3cd41d7af3f0d9978de619b4a51b56ad1c136ebf6dbb0d51e/dmarc-1.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-07 13:36:31",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "duobradovic",
"gitlab_project": "pydmarc",
"lcname": "dmarc"
}