MCPcopy Index your code
hub / github.com/bnkc/emval

github.com/bnkc/emval @v1.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1.0 ↗ · + Follow
80 symbols 201 edges 15 files 24 documented · 30%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

📬 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.

Core symbols most depended-on inside this repo

validate_email
called by 18
emval/validator.py
validate_deliverability
called by 10
src/validators/domain.rs
validate_chars
called by 6
src/validators/utils.rs
validate_email
called by 4
src/validators/email.rs
validate_domain
called by 4
src/validators/domain.rs
validate_local_part
called by 4
src/validators/local_part.rs
_generate_random_length
called by 4
scripts/benchmark.py
split_email
called by 3
src/validators/utils.rs

Shape

Function 61
Method 9
Route 5
Class 4
Enum 1

Languages

Rust56%
Python44%

Modules by API surface

src/validators/domain.rs17 symbols
tests/test_validator.py16 symbols
src/validators/utils.rs10 symbols
scripts/benchmark.py10 symbols
src/validators/email.rs8 symbols
src/validators/local_part.rs5 symbols
emval/model.py5 symbols
emval/validator.py4 symbols
src/models.rs2 symbols
src/errors.rs2 symbols
src/lib.rs1 symbols

For agents

$ claude mcp add emval \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page