What is the maximum length of a valid email address?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
The maximum length of a valid email address is 254 characters. This limit comes from RFC 5321 (the SMTP specification) and applies to the complete local@domain string. The local part (before the @) can be at most 64 characters, and the domain part (after the @) can be at most 253 characters.
Note the total is 254, not 320 (64 + 1 + 255). The effective limit is constrained by how email addresses are encoded in SMTP commands. This article explains why, covers the relevant RFCs, and provides practical guidance for implementing email validation in your applications.
The Length Limits Explained
Why 254, Not 320?
A common mistake is to calculate 64 (local) + 1 (@) + 255 (domain) = 320. The actual limit of 254 comes from RFC 5321 Section 4.5.3.1, which defines the maximum length of a MAIL FROM or RCPT TO command path.
In SMTP, the email address is transmitted as part of a path enclosed in angle brackets:
The maximum path length is 256 characters, which includes the enclosing < and >. So the address itself can be at most 256 - 2 = 254 characters.
This was formally clarified by Dominic Sayers (based on work by RFC author John Klensin) and is the universally accepted maximum.
Component Breakdown
| Component | Max Length | Specification |
| Local part | 64 characters | RFC 5321 Section 4.5.3.1.1 |
| @ separator | 1 character | Required delimiter |
| Domain part | 253 characters | RFC 1035 Section 2.3.4 (wire format) |
| Total address | 254 characters | RFC 5321 (SMTP path constraint) |
Why the Domain Is 253, Not 255
RFC 1035 states that domain names can be 255 octets in wire format. The wire format includes a length byte at the start and a null terminator at the end, which leaves 253 characters for the actual domain name as a text string. This 253-character limit applies to the fully qualified domain name (FQDN) including all labels and dots.
What Characters Are Allowed?
Local Part Rules
The local part (before @) follows rules from RFC 5321 and RFC 5322:
With quoting (enclosing the entire local part in double quotes), almost any character is valid, including spaces and @:
In practice, most email providers restrict local parts to letters, digits, dots, hyphens, and underscores.
Domain Part Rules
The domain part follows DNS naming rules:
Example of a near-maximum domain:
Validation in Code
JavaScript
Python
Database Column Sizing
When designing database schemas for email storage, the column size should accommodate the maximum valid length:
| Column type | Recommendation |
VARCHAR(254) | Correct. Matches the RFC maximum exactly. |
VARCHAR(255) | Acceptable. One byte of waste, but aligns with common defaults. |
VARCHAR(320) | Wasteful. Based on the incorrect 64+1+255 calculation. |
VARCHAR(100) | Too short. Rejects valid addresses. |
TEXT | Works but loses the length constraint at the database level. |
Using VARCHAR(254) is the most precise choice. It enforces the spec at the storage layer and communicates intent to other developers reading the schema.
Real-World Provider Limits
While the RFC allows 254 characters, major email providers impose stricter limits:
| Provider | Local Part Limit | Notes |
| Gmail | 30 characters | Only letters, digits, dots |
| Outlook/Hotmail | 64 characters | Letters, digits, dots, hyphens, underscores |
| Yahoo Mail | 32 characters | Letters, digits, dots, underscores |
| ProtonMail | 40 characters | Letters, digits, dots, hyphens, underscores |
These are creation limits. Users cannot create addresses longer than these limits. However, addresses from custom domains routed through these providers may have longer local parts.
Input Field and API Validation
On the client side, use HTML's built-in length constraint:
On the server side, validate length before performing more expensive operations like DNS lookups:
Always validate on both sides. Client-side constraints can be bypassed.
Common Pitfalls
Using 320 as the maximum length. The 64 + 1 + 255 = 320 calculation ignores the SMTP path encoding constraint. The correct maximum is 254. Using 320 is not harmful (it accepts all valid addresses), but it also accepts invalid ones and misrepresents the spec.
Rejecting valid addresses with strict regex. Many email regexes in the wild reject valid addresses like [email protected], "quoted string"@domain.com, or addresses with long domain parts. If you must use regex, keep it simple and rely on length checks and the presence of @ for basic validation. Full RFC compliance in regex is notoriously difficult.
Truncating on insert without validation. If your database column is VARCHAR(100) and you insert a 120-character email without checking length first, the database will either truncate it silently (MySQL in non-strict mode) or reject it with an error. Validate before inserting.
Treating the 64-character local part limit as universal. While the RFC allows 64 characters, most providers limit local parts to 30-40 characters. For user-facing forms, consider warning (but not blocking) when local parts exceed 40 characters, as these are rare in practice.
Not normalizing before length checks. Some inputs include leading/trailing whitespace. Trim the input before measuring length, or you may reject valid addresses and accept invalid ones:
Summary
- The maximum length of a valid email address is 254 characters (RFC 5321).
- The local part (before
@) can be at most 64 characters. - The domain part (after
@) can be at most 253 characters. - The 254 limit comes from SMTP path encoding (256 max path minus
<and>). - Use
VARCHAR(254)in database schemas for email columns. - Validate length on both client and server. Do not rely solely on regex.
- Real-world providers impose stricter limits than the RFC, typically 30-64 characters for the local part.
- Internationalized email addresses (RFC 6531) follow the same length limits but use UTF-8 encoding.

