Skip to main content

Email validation with syntax checking and normalization.

Project description

philiprehberger-email-validate

Tests PyPI version License

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"

API

Function / Class Description
EmailResult Dataclass with valid, normalized, domain, and error 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

Development

pip install -e .
python -m pytest tests/ -v

License

MIT

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

philiprehberger_email_validate-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file philiprehberger_email_validate-0.1.0.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_email_validate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2b84703857b40a21664370847ffff1878bbad089de7c45499f02212a0c2a83fe
MD5 035a884e10b90ed8842ff8264243f625
BLAKE2b-256 150090073b7ecc4172bcfd32bf2bbc9ff7868ff4a48c33fb95c7205c665d1fdb

See more details on using hashes here.

File details

Details for the file philiprehberger_email_validate-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_email_validate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fcaa2fd1aec6bcba52b4f504d5cc131837699af55c1ac70772cc4f3de23f788f
MD5 4887d68be2b16e3289855aa3b2e5eb6e
BLAKE2b-256 83ccf2e9d8b8fc3d08f9d8df8e4b47b4c60781b6bc08b38d51076197709d5688

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page