Skip to main content

Django package to detect ~890 domains used by disposable email services

Project description

=============================== django-disposable-email-checker

PyPI version PyPI version Requirements Status

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-disposable-email-checker-2.0.1.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-disposable-email-checker-2.0.1.tar.gz.

File metadata

  • Download URL: django-disposable-email-checker-2.0.1.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.5

File hashes

Hashes for django-disposable-email-checker-2.0.1.tar.gz
Algorithm Hash digest
SHA256 61dbae45e48c2a1b20582526058adcd5a205161a6bce63bdef5b2b2a3f1442c3
MD5 f5f1caf345728ff1b0ba249b9fadb8b9
BLAKE2b-256 f5050b07d615fd5362b12b01529081371d51159e0959726ab0a0517ee6107855

See more details on using hashes here.

File details

Details for the file django_disposable_email_checker-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_disposable_email_checker-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.5

File hashes

Hashes for django_disposable_email_checker-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 570dc6099193cde650749858e70cc3a288fc751ee726bfed4d94a8d568d4490c
MD5 b8c0693b4cb5f59250d339ace860f1c6
BLAKE2b-256 49f55b5ea9d9a108b937748c5ba2ab569c6c4f48f1634559011c97bc3991761a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page