Disposable Email Domains
The `disposable-email-domains` Python library provides a collection of known disposable and temporary email address domains. It's designed to help applications identify and block registrations or interactions from email addresses often used for spam, abuse, or privacy-conscious temporary sign-ups. The list is periodically updated, with the current version being 0.0.169, reflecting changes from the primary `disposable-email-domains` project. [1, 4]
Warnings
- gotcha The `blocklist` is a static dataset compiled at release time. New disposable domains appear daily, and existing ones can change status. This means the list can become outdated between releases, potentially leading to false negatives (missing new disposable domains) or false positives (blocking legitimate domains that are no longer disposable). For the most up-to-date and comprehensive checks, consider integrating with a real-time email validation API service. [3, 19]
- gotcha This library only provides a list of disposable domains; it does not perform full email address validation. It will not check for correct email format, valid MX records, or if a mailbox actually exists. Relying solely on this list for email validation can leave your application vulnerable to malformed or non-existent email addresses from non-disposable domains. [18, 19]
- gotcha Domains in the `blocklist` are guaranteed to be fully lowercased. Input domains must also be converted to lowercase before checking against the `blocklist` to ensure accurate matching. Failing to lowercase the input domain will result in an incorrect `False` for disposable domains with mixed-case or uppercase characters. [4]
Install
-
pip install disposable-email-domains
Imports
- blocklist
from disposable_email_domains import blocklist
Quickstart
from disposable_email_domains import blocklist
def is_disposable_email(email_address):
domain = email_address.split('@')[-1].lower()
return domain in blocklist
# Example usage:
email1 = "test@mailinator.com"
email2 = "user@example.com"
print(f"Is '{email1}' from a disposable domain? {is_disposable_email(email1)}")
print(f"Is '{email2}' from a disposable domain? {is_disposable_email(email2)}")