Email validation with syntax checking and normalization.
Project description
philiprehberger-email-validate
Email validation with syntax checking and normalization.
Installation
pip install philiprehberger-email-validate
Usage
from philiprehberger_email_validate import validate_email
result = validate_email("user@example.com")
print(result.valid) # True
print(result.normalized) # "user@example.com"
print(result.domain) # "example.com"
Quick Syntax Check
from philiprehberger_email_validate import is_valid
is_valid("user@example.com") # True
is_valid("not-an-email") # False
Normalization
from philiprehberger_email_validate import normalize
normalize(" User@Example.COM ") # "user@example.com"
MX Lookup
from philiprehberger_email_validate import validate_email
result = validate_email("user@example.com", check_mx=True)
if not result.valid:
print(result.error) # "MX lookup failed for domain: example.com"
Bulk Validation
from philiprehberger_email_validate import validate_many
results = validate_many(["user@example.com", "bad@@email", "test@gmail.com"])
for r in results:
print(r.normalized, r.valid)
Disposable Email Detection
from philiprehberger_email_validate import validate_email
result = validate_email("user@mailinator.com")
print(result.is_disposable) # True
result = validate_email("user@gmail.com")
print(result.is_disposable) # False
API
| Function / Class | Description |
|---|---|
EmailResult |
Dataclass with valid, normalized, domain, error, and is_disposable fields |
normalize(email) |
Strip whitespace and lowercase an email address |
is_valid(email) |
Quick boolean syntax check |
validate_email(email, check_mx=False) |
Full validation returning an EmailResult |
validate_many(emails, check_mx=False) |
Validate multiple emails with optional parallel MX lookups |
DISPOSABLE_DOMAINS |
Set of ~50 known disposable email domains |
Development
pip install -e .
python -m pytest tests/ -v
Support
If you find this package useful, consider starring the repository.
License
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
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 philiprehberger_email_validate-0.2.0.tar.gz.
File metadata
- Download URL: philiprehberger_email_validate-0.2.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f35bed79cbfe2c73974f484219ddc53917742aaec9ddd317a133971b4d9441b8
|
|
| MD5 |
50a81bd4c13d7aa9460585b04121689f
|
|
| BLAKE2b-256 |
69fb0ed637192a9835c57e612cfb1449d5406a732e4b30af5f3915afb706d4cb
|
File details
Details for the file philiprehberger_email_validate-0.2.0-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_email_validate-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9abab35ed55659192322180e4eebf4a150805efe3c6f95668af126f1e222e35
|
|
| MD5 |
3c32abcc4c39e3ca74e714fbef03b4ba
|
|
| BLAKE2b-256 |
d28e77ce4a2ed0c7323b260c80cb8110f9b79575178c3dd20b1c72fe1c578bf6
|