Skip to content

Repository files navigation

python-disposable

A lightweight Python package to detect disposable/temporary email addresses. Bundles 72,000+ domains from disposable/disposable-email-domains, updated daily — no network calls at runtime.

Installation

pip install python-disposable

Usage

Basic check

fromdisposable_emailimportis_disposable, is_validis_disposable("user@mailinator.com") # Trueis_disposable("user@gmail.com") # False# Works with bare domains toois_disposable("guerrillamail.com") # True# Inverseis_valid("user@gmail.com") # True

Strict mode

Strict mode also flags greylisted domains — services that allow anonymous signups but aren't purely disposable (e.g. some free email providers).

is_disposable("example.com", strict=True)
is_valid("example.com", strict=True)

Subdomain handling

Subdomains are automatically resolved to their parent domain.

is_disposable("mail.mailinator.com") # Trueis_disposable("a.b.guerrillamail.com") # True

Get the full domain set

fromdisposable_emailimportget_domainsdomains=get_domains() # frozenset of 72k+ domainsdomains_strict=get_domains(strict=True) # frozenset of strict list

Domain count

fromdisposable_emailimportdomain_countdomain_count() # 72170domain_count(strict=True) # 26468

Django example

fromdjangoimportformsfromdisposable_emailimportis_disposableclassRegisterForm(forms.Form):
email=forms.EmailField()
defclean_email(self):
email=self.cleaned_data["email"]
ifis_disposable(email):
raiseforms.ValidationError("Disposable email addresses are not allowed.")
returnemail

API reference

FunctionDescription
is_disposable(email_or_domain, strict=False)Returns True if the email/domain is disposable
is_valid(email_or_domain, strict=False)Returns True if the email/domain is not disposable
get_domains(strict=False)Returns the full frozenset of known disposable domains
domain_count(strict=False)Returns the number of bundled domains

Data source

Domain lists are sourced from disposable/disposable-email-domains and bundled at release time. The upstream list is updated daily via automated scraping of 40+ sources.

This package checks for upstream updates every 4 hours and automatically publishes a new version to PyPI when changes are detected.

License

MIT — see LICENSE.

About

Detect disposable/temporary email addresses with a curated 72k+ domain list plus nightly MX/IP cluster OSINT. Auto-updated. No network calls at runtime.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages