Django package to detect ~890 domains used by disposable email services
Project description
=============================
django-disposable-email-checker
=============================
[![PyPI version](https://badge.fury.io/py/django-disposable-email-checker.png)](https://pypi-hypernode.com/pypi/django-disposable-email-checker/)
[![PyPI version](https://travis-ci.org/aaronbassett/DisposableEmailChecker.png?branch=master)](https://travis-ci.org/aaronbassett/DisposableEmailChecker)
[![Requirements Status](https://requires.io/github/aaronbassett/DisposableEmailChecker/requirements.svg?branch=master)](https://requires.io/github/aaronbassett/DisposableEmailChecker/requirements/?branch=master)
Django package to detect ~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. Check out
their free tier for 200 API calls a month.
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
```
Adding to your models
---------------------
Once you have completed setup add the `DisposableEmailField` to your models.
```python
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
try:
validate_disposable_email(email)
except ValidationError:
pass
```
django-disposable-email-checker
=============================
[![PyPI version](https://badge.fury.io/py/django-disposable-email-checker.png)](https://pypi-hypernode.com/pypi/django-disposable-email-checker/)
[![PyPI version](https://travis-ci.org/aaronbassett/DisposableEmailChecker.png?branch=master)](https://travis-ci.org/aaronbassett/DisposableEmailChecker)
[![Requirements Status](https://requires.io/github/aaronbassett/DisposableEmailChecker/requirements.svg?branch=master)](https://requires.io/github/aaronbassett/DisposableEmailChecker/requirements/?branch=master)
Django package to detect ~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. Check out
their free tier for 200 API calls a month.
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
```
Adding to your models
---------------------
Once you have completed setup add the `DisposableEmailField` to your models.
```python
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
try:
validate_disposable_email(email)
except ValidationError:
pass
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-disposable-email-checker-1.2.1.tar.gz
.
File metadata
- Download URL: django-disposable-email-checker-1.2.1.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea557604091df19e3e88a999464bc47bc2a5afd840414d8965bf5b6ed98ea87f |
|
MD5 | 6b02bc8d0a546d226fe85483b156e436 |
|
BLAKE2b-256 | 88a27e739905fa30e618d1e81e5962cfb77220a79fc8f681d533b473a46ba1d1 |
File details
Details for the file django_disposable_email_checker-1.2.1-py2.py3-none-any.whl
.
File metadata
- Download URL: django_disposable_email_checker-1.2.1-py2.py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ca1010f7199c41efa4f8f4fdcfbe5db32166c9d9bb95d75a97924f4469ef0bf |
|
MD5 | 22ab9aa6c095bd7bdc6c03b0337d9790 |
|
BLAKE2b-256 | 3f9bd7ef5f1dd983a4a610b4097a8092010ef95dbf8a3fe780277dfd6c308994 |