Email Address Validation

1.3 · maintenance · verified Sat Apr 11

The `validate-email` library (version 1.3, last updated in 2015) provides basic functionality to verify if an email address is valid, properly formatted, and optionally checks for the existence of its domain's MX record and the email address itself via an SMTP check. Due to its age, it is largely unmaintained. More robust and actively developed alternatives are recommended for modern Python projects.

Warnings

Install

Imports

Quickstart

Demonstrates basic email validation, including optional MX record and SMTP verification checks. Note that `check_mx` and `verify` require the `pyDNS` dependency to be installed.

from validate_email import validate_email

# Basic syntax validation
is_valid_syntax = validate_email('test@example.com')
print(f"Syntax valid: {is_valid_syntax}")

# With MX record check (requires pyDNS)
is_valid_mx = validate_email('test@example.com', check_mx=True)
print(f"MX valid (requires pyDNS): {is_valid_mx}")

# With MX and SMTP verification (requires pyDNS)
is_valid_smtp = validate_email('test@example.com', check_mx=True, verify=True)
print(f"SMTP verified (requires pyDNS): {is_valid_smtp}")

# Example of an invalid email
is_invalid = validate_email('invalid-email')
print(f"Invalid email: {is_invalid}")

view raw JSON →