Skip to main content

emval is a blazingly fast email validator

Project description

📬 emval

emval is a blazingly fast Python email validator written in Rust, offering performance improvements of 100-1000x over traditional validators.

performance image

Features

  • Drop-in replacement for popular email validators like python-email-validator, verify-email, and pyIsEmail.
  • 100-1000x faster than python-email-validator.
  • Validates email address syntax according to RFC 5322 and RFC 6531.
  • Checks domain deliverability (coming soon).
  • Supports internationalized domain names (IDN) and local parts.
  • Provides user-friendly syntax errors.
  • Normalizes addresses.
  • Rejects invalid and unsafe Unicode characters.

Getting Started

Install emval from PyPI:

pip install emval

Usage

Quick Start

To validate an email address:

from emval import validate_email, EmailValidator

email = "example@domain.com"

try:
    # Check if the email is valid.
    val_email = validate_email(email)
    # Utilize the normalized form for storage.
    normalized_email = val_email.normalized
except Exception as e:
    # Example: "Invalid Local Part: Quoting the local part before the '@' sign is not permitted in this context."
    print(str(e))

Configurations

Customize email validation behavior using the EmailValidator class:

from emval import EmailValidator

emval = EmailValidator(
    allow_smtputf8=False,
    allow_empty_local=True,
    allow_quoted_local=True,
    allow_domain_literal=True,
    deliverable_address=False,
)

email = "user@[192.168.1.1]"

try:
    validated_email = emval.validate_email(email)
    print(validated_email)
except Exception as e:
    print(str(e))

Options

  • allow_smtputf8: Allows internationalized email addresses.
  • allow_empty_local: Allows an empty local part (e.g., @domain.com).
  • allow_quoted_local: Allows quoted local parts (e.g., "user name"@domain.com).
  • allow_domain_literal: Allows domain literals (e.g., [192.168.0.1]).
  • deliverable_address: Checks if the email address is deliverable by verifying the domain's MX records.

Technical Details

Email Address Syntax

emval adheres to the syntax rules defined in RFC 5322 and RFC 6531. It supports both ASCII and internationalized characters.

Internationalized Email Addresses

Domain Names

emval converts non-ASCII domain names into their ASCII "Punycode" form according to IDNA 2008. This ensures compatibility with systems that do not support Unicode.

Local Parts

emval allows international characters in the local part of email addresses, following RFC 6531. It offers options to handle environments without SMTPUTF8 support.

Unsafe Unicode Characters

emval rejects unsafe Unicode characters to enhance security, preventing display and interpretation issues.

Normalization

emval normalizes email addresses to ensure consistency:

  • Lowercasing domains: Domain names are standardized to lowercase.
  • Unicode NFC normalization: Characters are transformed into their precomposed forms.
  • Removing unnecessary characters: Quotes and backslashes in the local part are removed.

Acknowledgements

This project draws inspiration from python-email-validator. While python-email-validator is more comprehensive, emval aims to provide a faster solution.

Getting Help

For questions and issues, please open an issue in the GitHub issue tracker.

License

emval is licensed under the MIT License. See the LICENSE file for more details.

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

emval-0.1.1.tar.gz (27.4 kB view details)

Uploaded Source

Built Distribution

emval-0.1.1-cp310-cp310-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

File details

Details for the file emval-0.1.1.tar.gz.

File metadata

  • Download URL: emval-0.1.1.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.6

File hashes

Hashes for emval-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6c4c594d9501017047a8668373f27c1ca55b0f11bf2f4e973fbb068785e04f54
MD5 a7654839efe9e3d032772874b1fb853d
BLAKE2b-256 08715852b33880f6bf96d628568b7b81a516da7b23bf0b9e9a83d8c61c55af4d

See more details on using hashes here.

File details

Details for the file emval-0.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for emval-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2159c9124ee4e38b0aa33dac491981df8f33689760d3ab86a322921403e75beb
MD5 a7c5d75e5c119160455f2cd113b461d2
BLAKE2b-256 0a197904859b543c96a5c4864552d146af0def95ff4703ce4ed683472861c88a

See more details on using hashes here.

Supported by

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