=============================== django-disposable-email-checker
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 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.
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
DEC_LOADER = "my.package.custom_email_domain_loader"
If you would like to use the BDE integration add your API key to your Django settings
BDEA_APIKEY = "abcnotarealkey123"
optionally you can configure the BDE API timeout in seconds (default 5)
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.')):
BDEA_MESSAGE = '<blocked email message>'
Adding to your models
Once you have completed setup add the DisposableEmailField to your models.
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
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
Metadata
Release files for django-disposable-email-checker 2.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-disposable-email-checker-2.0.4.tar.gz | 15.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_disposable_email_checker-2.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.9 kB
Release files / django-disposable-email-checker-2.0.4.tar.gz
| Download URL | django-disposable-email-checker-2.0.4.tar.gz |
|---|---|
| Size | 15.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
63c47f35590ab5fcf964ac00a72ebe34ff61f21e3bcbb7e1ba934e8b2c35587c
|
|
BLAKE2b-256 checksum How to use checksums |
21bf82b82ef31b9d8c3ecc3edb9ede46b1ccdf916d49fd4d1b2ed735f437650a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.7
|
Release files / django_disposable_email_checker-2.0.4-py3-none-any.whl
| Download URL | django_disposable_email_checker-2.0.4-py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
182291fc0afd34bdf5e18a30062a4207dc44f9094a3c9f8f947c14b5700cb7d2
|
|
BLAKE2b-256 checksum How to use checksums |
906ffbc1409fc79be2e5b29d4a73877331dbef8f3212d9cb1b9271881f486083
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.7
|