===============================
django-disposable-email-checker
===============================
[](https://pypi.python.org/pypi/django-disposable-email-checker/)
[](https://travis-ci.org/jheld/DisposableEmailChecker)
[](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-disposable-email-checker",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "DisposableEmailChecker",
"author": "Jason Held",
"author_email": "jasonsheld@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/21/bf/82b82ef31b9d8c3ecc3edb9ede46b1ccdf916d49fd4d1b2ed735f437650a/django-disposable-email-checker-2.0.4.tar.gz",
"platform": null,
"description": "===============================\ndjango-disposable-email-checker\n===============================\n\n[](https://pypi.python.org/pypi/django-disposable-email-checker/)\n[](https://travis-ci.org/jheld/DisposableEmailChecker)\n[](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": "2.0.4",
"project_urls": {
"Homepage": "https://github.com/jheld/DisposableEmailChecker"
},
"split_keywords": [
"disposableemailchecker"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "906ffbc1409fc79be2e5b29d4a73877331dbef8f3212d9cb1b9271881f486083",
"md5": "20ec68262a73d03945c6254de52397a1",
"sha256": "182291fc0afd34bdf5e18a30062a4207dc44f9094a3c9f8f947c14b5700cb7d2"
},
"downloads": -1,
"filename": "django_disposable_email_checker-2.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "20ec68262a73d03945c6254de52397a1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 14005,
"upload_time": "2024-10-30T15:10:41",
"upload_time_iso_8601": "2024-10-30T15:10:41.022081Z",
"url": "https://files.pythonhosted.org/packages/90/6f/fbc1409fc79be2e5b29d4a73877331dbef8f3212d9cb1b9271881f486083/django_disposable_email_checker-2.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "21bf82b82ef31b9d8c3ecc3edb9ede46b1ccdf916d49fd4d1b2ed735f437650a",
"md5": "762f87d9e6a6726556c3f45642ade889",
"sha256": "63c47f35590ab5fcf964ac00a72ebe34ff61f21e3bcbb7e1ba934e8b2c35587c"
},
"downloads": -1,
"filename": "django-disposable-email-checker-2.0.4.tar.gz",
"has_sig": false,
"md5_digest": "762f87d9e6a6726556c3f45642ade889",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 15944,
"upload_time": "2024-10-30T15:10:42",
"upload_time_iso_8601": "2024-10-30T15:10:42.266075Z",
"url": "https://files.pythonhosted.org/packages/21/bf/82b82ef31b9d8c3ecc3edb9ede46b1ccdf916d49fd4d1b2ed735f437650a/django-disposable-email-checker-2.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-30 15:10:42",
"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": [
[
">=",
"2.2"
],
[
"<=",
"4.2.9"
]
]
},
{
"name": "wheel",
"specs": [
[
">=",
"0.30.0"
]
]
}
],
"tox": true,
"lcname": "django-disposable-email-checker"
}