Verify email addresses via DNS and SMTP, with disposable/temp-mail domain detection.
Project description
mailValidator
Version: 0.2.7.0
Python package to verify email addresses using DNS and SMTP checks, with disposable/temp-mail domain detection, catch-all detection, and a CLI.
Features
- DNS verification — resolves MX records (with A/AAAA fallback per RFC 5321)
- SMTP verification — validates mailboxes without sending email
- Disposable/temp-mail detection — bundled blocklist (~72k domains); early
202response skips DNS/SMTP for known domains - Catch-all detection — status
201when a domain accepts all addresses - Organization policy blocks — status
203when SMTP servers block external verification - Whitelist/blacklist — configurable email and domain lists
- CLI — batch validation with grouped or table output; export to
.txtor.xlsx - Python API —
verify_email()andverify_emails_list()
Installation
pip install mailValidator
For development:
git clone <repository-url>
cd emailValidator
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
Quick start
CLI
mailValidator --emails user@example.com,test@mailinator.com --format table
mailValidator --emails emails.txt --output results.txt --timeout 10
mailValidator --emails emails.txt --format table --output results.xlsx
Python
from mailValidator import verify_email
print(verify_email("user@example.com"))
# {'status': '200', 'message': 'Valid email'}
print(verify_email("test@mailinator.com"))
# {'status': '202', 'message': 'Valid email but domain is temporary/disposable.'}
CLI reference
| Option | Description |
|---|---|
--emails |
Comma-separated emails or path to a .txt file (one email per line) |
--timeout |
SMTP timeout in seconds (default: 5) |
--output |
Save results to .txt or .xlsx |
--format |
grouped (default) or table (Email | Status | Message) |
Response model
Every validation returns a dict:
{"status": "<code>", "message": "<description>"}
| Status | Meaning |
|---|---|
| 200 | Valid email (SMTP accepted or whitelisted) |
| 201 | Valid email, but domain is a catch-all |
| 202 | Disposable/temp-mail domain (checked early; DNS/SMTP skipped for blocklisted domains) |
| 203 | Organization blocks external email verification |
| 400 | Invalid email format or mailbox unavailable |
| 403 | Email or domain is blacklisted |
| 404 | Mail server not found (no MX/A/AAAA) |
| 500 | Internal or SMTP server error |
| 502 | IP blocked by Spamhaus |
| 503 | Network connection error |
Configuration
Pass a config dict to verify_email() or verify_emails_list():
from mailValidator import verify_email
config = {
"timeout": 10,
"whitelisted_emails": ["allowed@example.com"],
"blacklisted_emails": ["blocked@example.com"],
"whitelisted_domains": ["trusted.com"],
"blacklisted_domains": ["spam.com"],
"additional_disposable_domains": ["custom-temp.example"],
"additional_org_block_patterns": ["custom policy pattern"],
}
result = verify_email("user@example.com", config)
Disposable detection notes
- Domains in the bundled blocklist or
additional_disposable_domainsreturn202immediately (no DNS/SMTP). - Domains not in the blocklist are validated normally and may return
200or201even if they are temp-mail providers in the real world. - Add missing domains via
additional_disposable_domainsor extenddisposable_domains.txtin source.
Programmatic usage
from mailValidator import verify_email, verify_emails_list
# Single email
result = verify_email("user@example.com")
# Batch
results = verify_emails_list(
["valid@company.com", "invalid@bad.com"],
config={"timeout": 5},
)
# {'valid@company.com': {'status': '200', 'message': '...'}, ...}
Development
pip install -e ".[dev]"
pytest -v
Build a wheel locally:
pip install build
python -m build
pip install ./dist/mailvalidator-0.2.7.0-py3-none-any.whl
See test-case.md for the full test catalog.
Changelog
See CHANGELOG.md.
License
Proprietary — see LICENSE.txt.
Copyright (c) 2024 Anu T
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mailvalidator-0.3.0.0-py3-none-any.whl.
File metadata
- Download URL: mailvalidator-0.3.0.0-py3-none-any.whl
- Upload date:
- Size: 420.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d1073ee4e98daab43653d6fff119887fa5c8976acae921a1864afe70706f4e5
|
|
| MD5 |
dafe15e0386249e1be4f283d8d8af488
|
|
| BLAKE2b-256 |
a13f7a27bbbdbaaabd0df66130fb332d102b4369f2d4393ee62b2bb7394b37b6
|