Mailchecker
Mailchecker is a cross-language library designed for detecting temporary (disposable/throwaway) email addresses. It prevents users from signing up with such addresses by validating emails against a vast, continuously updated database of known fake email providers. The Python version is actively maintained with frequent updates to its domain list, with version 6.0.20 being the latest stable release.
Warnings
- breaking The API for Python was normalized in a major update (between v1.x and v3.x). Previously, you might have instantiated `m = MailChecker.MailChecker()`. The current recommended usage directly calls the class method `MailChecker.is_valid(email)`.
- gotcha Mailchecker primarily focuses on identifying temporary/disposable email domains and basic email format validation. It does *not* perform full SMTP validation to confirm if a mailbox actually exists or is active. An email might pass `is_valid()` but still not be deliverable.
- gotcha Older documentation or examples might suggest copying `MailChecker.py` directly into your project. While this might still work for some versions, the recommended and most reliable installation method for the Python package is `pip install mailchecker`.
Install
-
pip install mailchecker
Imports
- MailChecker
import MailChecker
Quickstart
import MailChecker
# Check a valid, non-disposable email
is_valid_real = MailChecker.is_valid('test@example.com')
print(f"'test@example.com' is valid: {is_valid_real}")
# Check a disposable email (yopmail.com is a common one)
is_valid_temp = MailChecker.is_valid('temp@yopmail.com')
print(f"'temp@yopmail.com' is valid: {is_valid_temp}")
# Check an invalid format email
is_valid_format = MailChecker.is_valid('invalid-email')
print(f"'invalid-email' is valid: {is_valid_format}")