django-email-disposable-checker


Namedjango-email-disposable-checker JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/jheld/DisposableEmailChecker
SummaryDjango package to detect ~890 domains used by disposable email services
upload_time2023-06-08 06:32:48
maintainer
docs_urlNone
authorJason Held
requires_python
licenseBSD
keywords disposableemailchecker
VCS
bugtrack_url
requirements django wheel
Travis-CI
coveralls test coverage No coveralls.
            ===============================
django-disposable-email-checker
===============================

[![PyPI version](https://badge.fury.io/py/django-disposable-email-checker.png)](https://pypi.python.org/pypi/django-disposable-email-checker/)
[![PyPI version](https://travis-ci.org/jheld/DisposableEmailChecker.png?branch=master)](https://travis-ci.org/jheld/DisposableEmailChecker)
[![Requirements Status](https://requires.io/github/jheld/DisposableEmailChecker/requirements.svg?branch=master)](https://requires.io/github/jheld/DisposableEmailChecker/requirements/?branch=master)

Django package to detect between ~890 & ~8,600 domains used by disposable email services.
You can validate any email against our internal list of ~890 domains used by
disposable email services. Optionally you can also check each domain against
the [Block-Disposable-Email.com](http://block-disposable-email.com) API,
covering ~8,600 domains.

This code was initially developed at: https://github.com/aaronbassett/DisposableEmailChecker
However PyPI ownership has been transferred to https://github.com/jheld/DisposableEmailChecker and as such
all future contributions are expected to be made to the new github repo.

Setup
-----

Install the disposable email checker from PyPI

    pip install django-disposable-email-checker

The disposable email checker comes with a list of ~890 emails. If you would like
to provide your own email list create a function which returns a list of domains
to block.

```python
from disposable_email_checker.emails import email_domain_loader

def custom_email_domain_loader():
    # Anyone still using AOL will be too much of a customer service burden
    return [
        "aol.com",
    ] + email_domain_loader()
```

Then add the complete path including function name to your settings

```python
DEC_LOADER = "my.package.custom_email_domain_loader"
```

If you would like to use the [BDE](http://block-disposable-email.com)
integration add your API key to your Django settings

```python
BDEA_APIKEY = "abcnotarealkey123"
```

optionally you can configure the BDE API timeout in seconds (default 5)

```python
BDEA_TIMEOUT = 2
```

A default error message can be set globally for the validation checking (this is optional and if 
left blank it will default to `_('Blocked email provider.')`):

```python
BDEA_MESSAGE = '<blocked email message>'
```

Adding to your models
---------------------

Once you have completed setup add the `DisposableEmailField` to your models.

```python
from django.db import models
from disposable_email_checker.fields import DisposableEmailField

class MyModel(models.Model):
    email = DisposableEmailField()
```

The `DisposableEmailField` has a few optional arguments

* **whitelist** - A list of emails which will always be allowed. Defaults
to `[]`
* **message** - The error message used by ValidationError if validation
fails. Defaults to `_('Blocked email provider.')`
* **code** - The error code used by ValidationError if validation fails.
Defaults to "invalid".

Using the validator
-------------------

If you want to use the validator by itself

```python
from django.core.exceptions import ValidationError
from disposable_email_checker.validators import validate_disposable_email
email = "emailaddress@readmetest.com"  # replace with your own value

try:
    validate_disposable_email(email)
except ValidationError:
    pass
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jheld/DisposableEmailChecker",
    "name": "django-email-disposable-checker",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "DisposableEmailChecker",
    "author": "Jason Held",
    "author_email": "jasonsheld@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f7/fa/104abd7099dd78ed39336ba5833f12d6bff8af6963df2a34bf2dae919471/django-email-disposable-checker-0.0.1.tar.gz",
    "platform": null,
    "description": "===============================\ndjango-disposable-email-checker\n===============================\n\n[![PyPI version](https://badge.fury.io/py/django-disposable-email-checker.png)](https://pypi.python.org/pypi/django-disposable-email-checker/)\n[![PyPI version](https://travis-ci.org/jheld/DisposableEmailChecker.png?branch=master)](https://travis-ci.org/jheld/DisposableEmailChecker)\n[![Requirements Status](https://requires.io/github/jheld/DisposableEmailChecker/requirements.svg?branch=master)](https://requires.io/github/jheld/DisposableEmailChecker/requirements/?branch=master)\n\nDjango package to detect between ~890 & ~8,600 domains used by disposable email services.\nYou can validate any email against our internal list of ~890 domains used by\ndisposable email services. Optionally you can also check each domain against\nthe [Block-Disposable-Email.com](http://block-disposable-email.com) API,\ncovering ~8,600 domains.\n\nThis code was initially developed at: https://github.com/aaronbassett/DisposableEmailChecker\nHowever PyPI ownership has been transferred to https://github.com/jheld/DisposableEmailChecker and as such\nall future contributions are expected to be made to the new github repo.\n\nSetup\n-----\n\nInstall the disposable email checker from PyPI\n\n    pip install django-disposable-email-checker\n\nThe disposable email checker comes with a list of ~890 emails. If you would like\nto provide your own email list create a function which returns a list of domains\nto block.\n\n```python\nfrom disposable_email_checker.emails import email_domain_loader\n\ndef custom_email_domain_loader():\n    # Anyone still using AOL will be too much of a customer service burden\n    return [\n        \"aol.com\",\n    ] + email_domain_loader()\n```\n\nThen add the complete path including function name to your settings\n\n```python\nDEC_LOADER = \"my.package.custom_email_domain_loader\"\n```\n\nIf you would like to use the [BDE](http://block-disposable-email.com)\nintegration add your API key to your Django settings\n\n```python\nBDEA_APIKEY = \"abcnotarealkey123\"\n```\n\noptionally you can configure the BDE API timeout in seconds (default 5)\n\n```python\nBDEA_TIMEOUT = 2\n```\n\nA default error message can be set globally for the validation checking (this is optional and if \nleft blank it will default to `_('Blocked email provider.')`):\n\n```python\nBDEA_MESSAGE = '<blocked email message>'\n```\n\nAdding to your models\n---------------------\n\nOnce you have completed setup add the `DisposableEmailField` to your models.\n\n```python\nfrom django.db import models\nfrom disposable_email_checker.fields import DisposableEmailField\n\nclass MyModel(models.Model):\n    email = DisposableEmailField()\n```\n\nThe `DisposableEmailField` has a few optional arguments\n\n* **whitelist** - A list of emails which will always be allowed. Defaults\nto `[]`\n* **message** - The error message used by ValidationError if validation\nfails. Defaults to `_('Blocked email provider.')`\n* **code** - The error code used by ValidationError if validation fails.\nDefaults to \"invalid\".\n\nUsing the validator\n-------------------\n\nIf you want to use the validator by itself\n\n```python\nfrom django.core.exceptions import ValidationError\nfrom disposable_email_checker.validators import validate_disposable_email\nemail = \"emailaddress@readmetest.com\"  # replace with your own value\n\ntry:\n    validate_disposable_email(email)\nexcept ValidationError:\n    pass\n```\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Django package to detect ~890 domains used by disposable email services",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/jheld/DisposableEmailChecker"
    },
    "split_keywords": [
        "disposableemailchecker"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f7fa104abd7099dd78ed39336ba5833f12d6bff8af6963df2a34bf2dae919471",
                "md5": "f314dafbbf616740fcf2be033149283b",
                "sha256": "877d9d899c5e768ddaac0365a46c53cb6e63b8e02f9db74f65d1d2eab631eec9"
            },
            "downloads": -1,
            "filename": "django-email-disposable-checker-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "f314dafbbf616740fcf2be033149283b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 16350,
            "upload_time": "2023-06-08T06:32:48",
            "upload_time_iso_8601": "2023-06-08T06:32:48.168334Z",
            "url": "https://files.pythonhosted.org/packages/f7/fa/104abd7099dd78ed39336ba5833f12d6bff8af6963df2a34bf2dae919471/django-email-disposable-checker-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-08 06:32:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jheld",
    "github_project": "DisposableEmailChecker",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "django",
            "specs": [
                [
                    "<=",
                    "3.2"
                ],
                [
                    ">=",
                    "2.2"
                ]
            ]
        },
        {
            "name": "wheel",
            "specs": [
                [
                    ">=",
                    "0.30.0"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "django-email-disposable-checker"
}
        
Elapsed time: 0.24046s