Email Address Validator
Validate single or multiple email addresses for format compliance.
About this tool
An email address validator is an essential tool for anyone who needs to verify that email addresses follow proper formatting rules. Whether you're building a sign-up form, cleaning up a contact list, or simply checking if an email is structured correctly, this validator uses standard email format rules to confirm that addresses are syntactically valid. Email validation helps prevent typos and ensures that communication attempts won't be automatically rejected by mail servers due to malformed addresses.
Using this tool is straightforward: paste a single email address or multiple addresses (one per line or comma-separated) into the input field and click validate. The tool checks each address against RFC 5322 standards and common email format rules, reporting which addresses are valid and which ones contain errors. Typical use cases include verifying customer email lists before sending newsletters, validating user input in registration forms, and checking contact databases for formatting issues before system integration.
This validator is particularly useful for data administrators, developers integrating email verification into applications, and businesses maintaining email lists. Note that this tool checks only the format of an email address—it does not verify whether the address actually exists or is currently active. For comprehensive email validation, you may still need to combine this with confirmation emails or SMTP checks in production systems.
Frequently Asked Questions
Code Implementation
import re
import dns.resolver # pip install dnspython
def validate_email_format(email: str) -> bool:
"""Validate email format using RFC 5321/5322 rules."""
pattern = r'^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$'
if not re.match(pattern, email):
return False
local, domain = email.rsplit('@', 1)
if len(email) > 254 or len(local) > 64:
return False
if '..' in email or email.startswith('.') or email.endswith('.'):
return False
return True
def check_mx_record(domain: str) -> bool:
"""Check if domain has MX records (can receive email)."""
try:
answers = dns.resolver.resolve(domain, 'MX')
return len(answers) > 0
except Exception:
return False
def validate_email(email: str, check_mx: bool = False) -> dict:
result = {
"email": email,
"format_valid": validate_email_format(email),
"mx_valid": None,
}
if result["format_valid"] and check_mx:
domain = email.split('@')[1]
result["mx_valid"] = check_mx_record(domain)
return result
# Usage
emails = ["user@example.com", "invalid@", "test..user@domain.com"]
for email in emails:
print(validate_email(email))Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.