Email validation is one of the most common tasks in web development. Getting it right prevents bounced emails, improves data quality, and enhances user experience.
Email Address Structure
An email address follows the format: local-part@domain
| Part | Rules | Examples |
|---|---|---|
| Local part | Up to 64 characters, letters, digits, and special chars | john.doe, user+tag |
| @ symbol | Required separator | @ |
| Domain | Valid domain name with at least one dot | gmail.com, company.co.uk |
Levels of Email Validation
1. Format Validation (Syntax)
Check that the email matches the expected pattern. A practical regex:^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
2. Domain Validation (DNS)
Verify the domain exists and has MX (mail exchange) records.3. Mailbox Validation (SMTP)
Connect to the mail server to check if the specific mailbox exists. This is the most accurate but also the slowest method.Common Email Validation Mistakes
| Mistake | Why It Is Wrong |
|---|---|
| Rejecting + in local part | Gmail and others support user+tag@domain |
| Limiting TLD to 3 chars | TLDs like .museum, .travel exist |
| Requiring a dot in local part | a@b.com is valid |
| Case-sensitive comparison | Email local parts are technically case-sensitive but practically treated as case-insensitive |
Best Practices for Developers
Try It Yourself
Validate any email address with our free Email Validator. Check format, domain structure, and common issues instantly.