What Makes an Email Address Valid? RFC Syntax Rules, Weird Edge Cases, and Why Regex Fails

Ask ten developers what makes an email address valid and you will get ten regular expressions, most rejecting addresses the standards allow and accepting addresses no server will deliver to. The real rules live in RFC 5321 and RFC 5322, and they are stranger than most validation code assumes. This guide walks the specification in plain language: the exact character rules, the weird-but-valid edge cases, the regex failure gallery, and the two-line approach that beats them all.

64 / 255 / 254
The three length limits that matter: 64 characters maximum for the local part, 255 for the domain, and a practical ceiling of 254 for the complete address imposed by the SMTP path length. Validators that check none of them accept addresses that cannot exist; validators that invent stricter limits reject addresses that do.
Quick Answer

What Is a Syntactically Valid Email Address?

Per RFC 5321 and RFC 5322, a valid address is a local part (up to 64 characters) followed by @ and a domain (up to 255 characters), with the whole address practically capped at 254. The local part allows letters, digits, and the specials ! # $ % & ' * + - / = ? ^ _ ` { | } ~, with dots permitted between characters but not first, last, or doubled; a quoted form ("john smith"@example.com) legally permits spaces and most other characters. The domain is dot-joined labels of letters, digits, and interior hyphens, each label up to 63 characters, and it must resolve in DNS (MX or fallback A record) for mail to route. Case sensitivity in the local part is technically allowed but ignored by virtually every provider. The most important caveat: a perfectly formed address says nothing about deliverability, since sdgkjhsdfgkjh@gmail.com meets every rule and is almost certainly nonexistent, which is why real systems pair a permissive syntax check with actual mailbox verification instead of an ever-longer regex.

The Local Part: Stranger Than You Think

Everything before the @ is the local part, and the specification is far more permissive than intuition suggests. In the ordinary dot-atom form, every letter and digit is allowed alongside these specials: ! # $ % & ' * + - / = ? ^ _ ` { | } ~. Dots may appear between characters but not at the start, at the end, or doubled. That makes user.name+tag@example.com, customer/department=shipping@example.com, and !def!xyz%abc@example.com all fully standards-compliant.

Then there is the quoted form, the part of RFC 5322 that breaks the most validators: wrap the local part in double quotes and nearly anything goes, including spaces. "john smith"@example.com and "very.unusual.@.address"@example.com are legal addresses. Almost no mainstream provider will let you register one, but the syntax is valid, and mail systems that meet the standard must parse it.

📊
Key Stat: The local part maximum is 64 octets, set by RFC 5321. Combined with the 255-octet domain limit and the SMTP path constraint, the practical maximum for a complete address is 254 characters. Database columns sized at VARCHAR(255) got that number from these rules, usually without anyone remembering why.

The Domain Side: Labels, Hyphens, and DNS

The domain is a sequence of labels joined by dots, each label 1-63 characters of letters, digits, and hyphens, with hyphens forbidden at a label's edges. The full domain caps at 255 characters. Syntax, though, is only the entry ticket on this side: a domain that parses perfectly but has no MX record (and no fallback A record) cannot receive mail, which makes DNS resolution the first genuinely semantic check in any validation pipeline. Whether a syntactically fine domain actually routes mail is a one-second question for a domain email verification check.

Two details trip up validators here. Top-level domains longer than four characters are routine now (.museum, .technology, .international), so any regex with a {2,4} TLD quantifier rejects real customers. And a trailing dot (example.com.) is technically a valid fully qualified DNS name, another case where the standard is looser than the folklore.

Weird but Valid: The Edge Case Gallery

"john smith"@example.com
Quoted local parts legally contain spaces. Most validators reject it; the RFC does not.
!def!xyz%abc@example.com
Bang and percent are ordinary local-part characters, living fossils of pre-internet routing that remain valid.
o'brien@example.ie
The apostrophe is a permitted special. Validators that reject it tell every O'Brien and D'Angelo their name is invalid.
sdgkjhsdfgkjh@gmail.com
Perfect syntax, almost certainly no mailbox. The class of address no syntax rule can ever catch.
.user@example.com
Leading, trailing, or doubled dots in an unquoted local part are the classic genuinely invalid forms.
The gallery teaches one lesson: well-formed and deliverable are different properties. A validator can be perfectly faithful to the RFC and still tell you nothing about whether mail will arrive.

Provider Conventions: Plus Tags, Gmail Dots, and Case

Several famous email behaviors are provider conventions, not syntax rules. Plus-addressing (user+newsletter@gmail.com routing to user@) is a subaddressing convention many providers implement; the RFC just sees + as another legal character, so stripping tags is a business decision about identity, not a validation step. Gmail additionally ignores dots in local parts (u.ser@ and user@ reach the same inbox), a Gmail-specific behavior that is wrong to generalize: on most mail systems those are different mailboxes. And while RFC 5321 technically permits case-sensitive local parts, virtually every provider treats User@ and user@ identically, so lowercasing on intake is safe in practice and universal in deduplication pipelines.

Warning: Never silently rewrite addresses based on provider conventions: stripping a plus tag or collapsing dots changes what the user gave you, breaks their filtering, and on non-Gmail systems can redirect mail to a different person entirely. Store what was entered, normalize a separate copy for deduplication, and keep the two roles distinct.

Internationalized Addresses and Punycode

Internationalized domains (münchen.de, 日本.jp) travel through DNS as ASCII punycode (xn--mnchen-3ya.de), so a validator that rejects non-ASCII domains rejects real registrable names; the conversion, not rejection, is the correct handling. Fully internationalized local parts (用户@example.cn) go further, requiring the SMTPUTF8 extension end to end, and support remains uneven across providers in 2026. The pragmatic policy for most systems: accept internationalized input, convert domains to punycode for DNS work, and let mailbox verification report whether the receiving infrastructure actually supports the address, because that varies server by server in a way no syntax rule can encode.

Why Regex Fails: The Failure Gallery

Every popular email regex is wrong in both directions at once, and the classic patterns fail predictably:

regex_failures.py
import re

# The regex everyone copies from a forum answer
naive = re.compile(r"^[\w.-]+@[\w-]+\.[a-z]{2,4}$")

# FALSE REJECTS: all of these are valid addresses
print(naive.match("user+tag@example.com"))        # None: rejects plus
print(naive.match("o'brien@example.ie"))         # None: rejects apostrophe
print(naive.match("team@company.technology"))    # None: TLD {2,4} myth
print(naive.match("info@mail.example.co.uk"))    # None: multi-label domain

# FALSE ACCEPTS: these pass and can never receive mail
print(naive.match("user@nonexistent-domain-xkcd.com"))  # matches: no DNS check
print(naive.match("a" * 99 + "@example.com"))       # matches: no 64-char limit

# The two-line check that beats every clever regex:
def plausible(addr):
    local, sep, domain = addr.rpartition("@")
    return bool(sep) and 0 < len(local) <= 64 and "." in domain and len(addr) <= 254
# ...then hand plausible addresses to real mailbox verification

Tightening the pattern never wins. A regex that fully encoded RFC 5322 runs thousands of characters, remains unreadable, and still validates only syntax: it will approve every well-formed address at a dead domain and every gibberish local part at Gmail. The failure is architectural, not a matter of finding a better pattern.

The Right Architecture: Permissive Syntax + Real Verification

Production systems that get this right all converge on the same split: a deliberately permissive syntax gate (has one @, sane lengths, a dotted domain) that never rejects a real customer, followed by verification that answers the question regex never could: does this mailbox exist and accept mail. The verification layer performs the DNS resolution, MX lookup, and live SMTP conversation, and returns syntax failures, dead domains, and nonexistent mailboxes as distinct results (the three layers separate visibly when you run any address through an instant email verification check), via a real-time email verification API call at capture or a bulk email list verification pass for existing data.

The division of labor is clean: syntax rules reject the structurally impossible instantly and for free, and the mailbox probe settles everything syntax cannot see. The response schema and event codes for the verification side are documented in the email verification API docs; primary sources for the syntax side are the specifications themselves, RFC 5321 for the SMTP transport rules and RFC 5322 for the message format grammar.

💡
Pro Tip: When migrating off a strict legacy regex, run your rejected-signups log through verification before celebrating the new gate. Teams routinely discover that addresses their old pattern bounced (plus tags, apostrophes, long TLDs) were live customers, and the recovered segment pays for the migration by itself.

Frequently Asked Questions

What characters are allowed in an email address?
In the unquoted local part: letters, digits, and ! # $ % & ' * + - / = ? ^ _ ` { | } ~, with dots between characters (never first, last, or doubled). The quoted form ("john smith"@example.com) additionally permits spaces and most other characters. Domains allow letters, digits, and interior hyphens in dot-joined labels.
What is the maximum length of an email address?
254 characters for the complete address in practice, from the SMTP path limit, with the local part capped at 64 characters and the domain at 255. Individual domain labels max out at 63 characters each.
Are email addresses case sensitive?
The standard technically permits case-sensitive local parts, but virtually every real provider treats User@ and user@ as the same mailbox. Lowercasing on intake is safe in practice and standard in deduplication pipelines; domains are case-insensitive by DNS rules regardless.
Is user+tag@gmail.com a different address than user@gmail.com?
Syntactically yes, they are distinct addresses; by Gmail's subaddressing convention they deliver to the same inbox. That routing is a provider behavior, not an RFC rule, so never assume it or strip tags silently: store what the user entered and normalize a separate copy if you need identity matching.
Why is regex not enough to validate email addresses?
Because regex checks structure only. Every popular pattern simultaneously rejects valid addresses (plus tags, apostrophes, long TLDs, quoted forms) and accepts undeliverable ones (dead domains, nonexistent mailboxes, over-length locals). Deliverability requires DNS and a live mailbox probe, which no pattern can perform.
Can a syntactically valid email address still bounce?
Constantly; it is the most common bounce type. Perfect syntax at a domain with no MX records, or a well-formed local part with no mailbox behind it, passes every syntax rule and hard bounces on send. Only mailbox verification separates well-formed from deliverable.

The Bottom Line

The RFC rules are worth knowing precisely so you stop trying to enforce them with patterns: the specification is permissive in ways that break strict validators and silent on the one thing senders care about, whether mail arrives. Validate structure loosely (one @, sane lengths, a dotted domain), and delegate the real question to a mailbox probe.

Your O'Briens sign up, your .technology customers get through, and the perfectly formed garbage gets caught by the only check that can catch it.

Test the Edge Cases Yourself: Paste any address from the gallery above into the free email address checker and watch syntax, DNS, and mailbox results come back as separate findings; it is the fastest way to see why the two-layer architecture beats any single pattern.
99.7% Accuracy Guarantee

Stop Bouncing. Start Converting.

Millions of emails verified daily. Industry-leading SMTP validation engine.