dmarc


Namedmarc JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://gitlab.com/duobradovic/pydmarc
SummaryParse and evaluate DMARC email authentication policy
upload_time2024-05-07 11:44:33
maintainerNone
docs_urlNone
authorDusan Obradovic
requires_python>=3.9
licenseMIT
keywords dkim spf dmarc email authentication rfc7489 rfc8601
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

```bash
pip install dmarc
```

## Usage

```python
>>> import dmarc
>>>
>>> # Represent verified SPF and DKIM status
>>> aspf = dmarc.SPF(domain='news.example.com', result=dmarc.SPFResult.PASS)
>>> #aspf = dmarc.SPF.from_authres(SPFAuthenticationResult(result='pass', smtp_mailfrom='email@news.example.com'))
>>> 
>>> adkim = dmarc.DKIM(domain='example.com', result=dmarc.DKIMResult.PASS)
>>> #adkim = dmarc.DKIM.from_authres(DKIMAuthenticationResult(result='pass', header_d='example.com'))
>>>
>>> try:
...     admarc = dmarc.DMARCPolicy(record='v=DMARC1; p=reject;', domain='example.com')
...     admarc.verify(spf=aspf, dkim=adkim)
...     #admarc.verify(auth_results=[aspf, adkim, dmarc.DKIM('news.example.com', dmarc.DKIMResult.FAIL)])
...     adict = admarc.result.as_dict() # dict repr
... except dmarc.PolicyNoneError:
...     pass
... except dmarc.PolicyQuarantineError:
...     raise
... except dmarc.PolicyRejectError:
...     raise
... except dmarc.RecordSyntaxError:
...     raise
...
>>> # dmarc rr resolver example
>>> from dmarc.resolver import resolve, RecordNotFoundError, RecordMultiFoundError, RecordResolverError
>>> from dmarc.psl import get_public_suffix
>>> domain = 'example.com'
>>> try:
...     record = resolve(domain)
... except RecordNotFoundError:
...     org_domain = get_public_suffix(domain)
...     if org_domain != domain:
...             record = resolve(org_domain)
... except RecordMultiFoundError:
...     raise # permerror
... except RecordResolverError:
...     raise # temperror
... 
>>> # dmarc authres header example
>>> from dmarc.ar import authres, AuthenticationResultsHeader
>>> dares = authres(admarc.result) #DMARCAuthenticationResult factory
>>> header = AuthenticationResultsHeader(authserv_id='myhostname', results=[dares])
>>> str(header)
'Authentication-Results: myhostname; dmarc=pass (domain=example.com adkim=r aspf=r p=reject pct=100) header.from=example.com policy.dmarc=none (disposition=none dkim=pass spf=pass)'
```

## 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, rfc7489, rfc8601",
    "author": "Dusan Obradovic",
    "author_email": "dusan@euracks.net",
    "download_url": "https://files.pythonhosted.org/packages/4e/86/3ed95d6995008c4100353528f7f2d0f1e7e01004c0d939236fd0a2fac681/dmarc-1.1.0.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```bash\npip install dmarc\n```\n\n## Usage\n\n```python\n>>> import dmarc\n>>>\n>>> # Represent verified SPF and DKIM status\n>>> aspf = dmarc.SPF(domain='news.example.com', result=dmarc.SPFResult.PASS)\n>>> #aspf = dmarc.SPF.from_authres(SPFAuthenticationResult(result='pass', smtp_mailfrom='email@news.example.com'))\n>>> \n>>> adkim = dmarc.DKIM(domain='example.com', result=dmarc.DKIMResult.PASS)\n>>> #adkim = dmarc.DKIM.from_authres(DKIMAuthenticationResult(result='pass', header_d='example.com'))\n>>>\n>>> try:\n...     admarc = dmarc.DMARCPolicy(record='v=DMARC1; p=reject;', domain='example.com')\n...     admarc.verify(spf=aspf, dkim=adkim)\n...     #admarc.verify(auth_results=[aspf, adkim, dmarc.DKIM('news.example.com', dmarc.DKIMResult.FAIL)])\n...     adict = admarc.result.as_dict() # dict repr\n... except dmarc.PolicyNoneError:\n...     pass\n... except dmarc.PolicyQuarantineError:\n...     raise\n... except dmarc.PolicyRejectError:\n...     raise\n... except dmarc.RecordSyntaxError:\n...     raise\n...\n>>> # dmarc rr resolver example\n>>> from dmarc.resolver import resolve, RecordNotFoundError, RecordMultiFoundError, RecordResolverError\n>>> from dmarc.psl import get_public_suffix\n>>> domain = 'example.com'\n>>> try:\n...     record = resolve(domain)\n... except RecordNotFoundError:\n...     org_domain = get_public_suffix(domain)\n...     if org_domain != domain:\n...             record = resolve(org_domain)\n... except RecordMultiFoundError:\n...     raise # permerror\n... except RecordResolverError:\n...     raise # temperror\n... \n>>> # dmarc authres header example\n>>> from dmarc.ar import authres, AuthenticationResultsHeader\n>>> dares = authres(admarc.result) #DMARCAuthenticationResult factory\n>>> header = AuthenticationResultsHeader(authserv_id='myhostname', results=[dares])\n>>> str(header)\n'Authentication-Results: myhostname; dmarc=pass (domain=example.com adkim=r aspf=r p=reject pct=100) header.from=example.com policy.dmarc=none (disposition=none dkim=pass spf=pass)'\n```\n\n## License\n[MIT](https://choosealicense.com/licenses/mit/)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Parse and evaluate DMARC email authentication policy",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://gitlab.com/duobradovic/pydmarc"
    },
    "split_keywords": [
        "dkim",
        " spf",
        " dmarc",
        " email",
        " authentication",
        " rfc7489",
        " rfc8601"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e33ab14a4795e3a66c28510fbc319b58428d09b8fdf580c5a25445ae4be29dee",
                "md5": "67f53572154964c1586d889ccb5a5855",
                "sha256": "2961e9565b2eb85cca02f62e4273179f2f3ba9e900eb69687a1558812d39167a"
            },
            "downloads": -1,
            "filename": "dmarc-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "67f53572154964c1586d889ccb5a5855",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 21947,
            "upload_time": "2024-05-07T11:44:31",
            "upload_time_iso_8601": "2024-05-07T11:44:31.723889Z",
            "url": "https://files.pythonhosted.org/packages/e3/3a/b14a4795e3a66c28510fbc319b58428d09b8fdf580c5a25445ae4be29dee/dmarc-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4e863ed95d6995008c4100353528f7f2d0f1e7e01004c0d939236fd0a2fac681",
                "md5": "789a7dc2db24766e4f35e0d2dadd935d",
                "sha256": "6c434967b977187c9727bba1c0791a9638b22d41995871970eb3c6d560e827cf"
            },
            "downloads": -1,
            "filename": "dmarc-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "789a7dc2db24766e4f35e0d2dadd935d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 16382,
            "upload_time": "2024-05-07T11:44:33",
            "upload_time_iso_8601": "2024-05-07T11:44:33.633318Z",
            "url": "https://files.pythonhosted.org/packages/4e/86/3ed95d6995008c4100353528f7f2d0f1e7e01004c0d939236fd0a2fac681/dmarc-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-07 11:44:33",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "duobradovic",
    "gitlab_project": "pydmarc",
    "lcname": "dmarc"
}
        
Elapsed time: 0.66934s