Article
RFC 5322 Email Syntax: What Makes an Address Valid
By Unlimited Verifier Team ·

Summary
RFC 5322 email syntax is the IETF grammar that defines how a valid email address must be written inside a message header. It sets rules for characters, dots, and quoting, but it only proves an address is well formed, not that the mailbox exists. Use it as the first filter in any list cleanup, followed by domain and mailbox checks.RFC 5322 email syntax is the IETF grammar, published in 2008, that defines what a valid email address looks like inside a message header: one local part, one unquoted @ sign and a domain, with strict rules for characters, dots and quoting. Passing it means an address is well formed. It does not mean the mailbox exists.
That distinction is where most list-cleaning projects go wrong. Syntax is the first layer of syntax validation for email addresses, and it is the cheapest check in the process described in how email verification works. For teams in email verification for ecommerce and SaaS, a few hundred malformed rows in a checkout export are often the first visible sign of a list problem. This guide covers the grammar, where it stops being useful, and how to apply it to a real file.
Quick answer
- RFC 5322 defines the address format used in message headers (From, To, Cc). RFC 5321 governs SMTP delivery and sets the length limits mail servers enforce: 64 octets for the local part and 255 for the domain.
- A legal address has exactly one unquoted @, a local part of 1 to 64 octets, and dot-separated domain labels of up to 63 characters each.
- Syntax proves an address is well formed, not that the mailbox exists.
jane@gmial.compasses syntax. - For bulk cleanup, run a stricter practical check first, then verify the domain, MX records and SMTP mailbox.
- Accept apostrophes and plus signs (
o'brien@andjane+news@are legal). Flag quoted strings and UTF-8 for review. Reject internal spaces.
What does RFC 5322 define for an email address?
RFC 5322 is the Internet Message Format. It describes the structure of a message, including header fields such as From, To, Cc and Subject, and the grammar for addresses inside them. It replaced RFC 2822 (2001), and its grammar is written in ABNF, the notation defined in RFC 5234.
Two address forms matter for list work:
- addr-spec: the bare address, such as
jane.doe@example.com. - name-addr: a display name plus the address in angle brackets, such as
Jane Doe <jane.doe@example.com>.
CRM exports often contain the name-addr form in an email column. Extracting the address from the angle brackets is a routine preprocessing step, and the tutorial below does it for you.
RFC 5322 also allows comments inside addresses, such as jane(work)@example.com. The grammar permits them, but no marketing list should contain them, so treat them as a failure to review.
RFC 5322 says what may appear in a header. It says nothing about how a server routes or accepts mail. That is RFC 5321's job. Many "the validator says valid but the ESP rejected it" tickets trace back to mixing the two standards.
Bottom line: RFC 5322 defines the header grammar. Delivery rules and length limits live in RFC 5321.
What characters and dot rules apply before the @?
The local part is everything before the @. The rules are compact but easy to get wrong.
| Rule | Legal example | Illegal example | Practical note |
|---|---|---|---|
Unquoted atoms: letters, digits and ! # $ % & ' * + - / = ? ^ _ \ { | } ~` |
o'brien+news@example.com |
jane doe@example.com |
Apostrophes and plus signs are legal; spaces are not |
| Dots only between atoms | first.last@example.com |
.first@ or first..last@ |
Doubled dots are a common paste error |
| Quoted local part in double quotes | "jane doe"@example.com |
"jane doe@example.com (unclosed) |
Legal, but rare and usually junk in consumer lists |
| Exactly one unquoted @ | jane@example.com |
jane@@example.com |
Multiple @ signs are the most common structural failure |
Apostrophes matter in practice. A regex copied from a forum often rejects o'brien@..., which silently drops real customers. Check any regex you adopt against a handful of known-good addresses before trusting it on a full file.
Bottom line: Allow the common atoms, enforce dot placement, and treat quoted strings as a review case rather than a silent pass.
What can the domain part contain?
The domain is either a dot-separated list of labels or a bracketed IP literal such as [192.0.2.10]. RFC 5322 does not require a dot, so jane@localhost is grammatically legal, but it has no public DNS name that could receive mail. Treat IP literals and single-label domains as failures in a marketing list.
Three limits matter for cleanup:
- Label length: a DNS label is at most 63 octets (RFC 1035).
- Domain length: the full domain is at most 255 octets under RFC 5321.
- Top-level domain length: sources disagree. Some validators cap the TLD at two to six letters, but the RFCs don't. Recommend no fixed cap, because longer generic TLDs are legitimate.
For test data, use the names reserved by RFC 2606, such as example.com, so no real person receives your test mail.
Bottom line: Check label characters, label length and at least two labels. Don't cap the TLD length.
Why does an address that passes RFC 5322 still bounce?
Syntax answers one question. Deliverability depends on four.
| Check | Question answered | Catches | Misses |
|---|---|---|---|
| Syntax | Is this a legal address string? | Missing @, doubled @, spaces | Plausible typos such as jane@gmial.com |
| Domain and MX | Does this domain accept mail? | Dead or expired domains, no MX record | Individual mailboxes on live domains |
| SMTP mailbox | Does the receiving server accept this recipient? | Unknown users at real domains | Catch-all domains, which accept nearly everything |
| Catch-all detection | Does the domain accept any address? | Results that can't be confirmed | Whether the specific mailbox is real |
Here is the practical gap. jane@gmial.com is syntactically perfect. If the typo domain is dead, the domain check fails it. If someone has parked the domain on a server that accepts all mail, it can pass the domain and mailbox checks while going nowhere. That is why catch-all detection matters. Catch-all email verification explains how those domains are flagged, and how verifiers detect catch-all domains covers the mechanics. Domains that accept everything are what verifiers call accept-all results. For how a verifier can test one without sending mail, see bounce-based catch-all verification.
Mailbox responses need care too. A "mailbox full" reply is a temporary condition, not proof the address is dead. Read mailbox full results before you delete anything on that basis. The mechanics of the mailbox check are in how a verifier checks whether an address exists.
Bottom line: Treat syntax as a filter for obvious junk. It is never evidence that a mailbox exists.
How does RFC 5321 change the rules, and how long can an address be?
RFC 5321 governs SMTP, the protocol that moves mail between servers. It sets limits that RFC 5322 does not. The local part may be at most 64 octets, the domain at most 255, and the path at most 256 octets, as set out in RFC 5321 section 4.5.3.1.
Because the 256-octet path includes the angle brackets, the practical ceiling for a whole address is 254 octets. Sources quote different maxima, so here is one number to use: enforce 64 for the local part and 254 for the full address.
This creates a real gap. A 70-character local part can be well formed as a header and still be rejected by an SMTP server. A syntax check built only on RFC 5322 will pass some addresses your ESP cannot deliver to.
Bottom line: Apply the RFC 5321 length limits alongside the RFC 5322 grammar. Enforce 64 for the local part and 254 for the whole address.
Should a bulk list accept plus signs, quoted strings and accented addresses?
Accept plus signs and apostrophes. Flag quoted and UTF-8 forms for review. Reject spaces and structural errors.
- Plus-addressing (
jane+news@example.com) is legal and widely used for tagging. It is a valid address, not a typo. Keep it as entered. - Quoted local parts are legal but rare in marketing and ecommerce lists. Most quoted strings you find are junk, so route them to review rather than sending.
- Internationalized addresses use UTF-8 characters, which RFC 5322 does not allow in its basic atoms. They are covered by RFC 6531 (SMTPUTF8), and RFC 6532 extends the headers. Emoji fall in this category. Support varies across mail servers, so flag these rather than reject them outright.
Bottom line: Be strict about structure and lenient about legal variety. Route the unusual cases to review.
Which syntax-checking method should you use?
Each method answers a different question, so the right one depends on where you are in the workflow.
| Method | What it accepts | Best use | Main drawback |
|---|---|---|---|
Browser type="email" validation |
A deliberately simplified grammar from the WHATWG HTML Standard | First-pass check on a sign-up form | Too loose to clean a list alone |
| Full RFC 5322 parser or library | Everything the grammar permits, including quoted strings and comments | Parsing unusual or legacy headers | Accepts forms that many signup flows and ESPs reject |
| Practical rule set (see the tutorial) | Common ASCII forms; rejects quoted and UTF-8 local parts by design | Pre-upload cleanup of bulk exports | Rejects some RFC-legal addresses, on purpose |
| Full verification pipeline | Syntax, then domain, MX, SMTP mailbox, catch-all and role or disposable flags | Deciding who gets mailed | Needs a review path for uncertain results |
The best approach uses the practical rule set as a cheap first pass and the full pipeline for the decision. When you compare best email verification tools, check whether each one returns a syntax failure reason per row, and whether it separates catch-all, disposable and role-based flags from hard failures. Those two features decide whether a failure file is useful for auditing. For vendor evaluation, see how to choose an email verifier. For form-level checks, see real-time email validation at signup.
Bottom line: Use the rule set to triage and the full pipeline to decide.
How do you check syntax across a large list?
Use this six-step framework on any export, whether it has 500 rows or 500,000.
- Normalise first. Trim spaces, extract the address from any
<...>brackets, and lowercase the domain (DNS is case-insensitive). Deduplicate on a lowercased local part too, but keep the original string. RFC 5321 permits case-sensitive local parts, though most consumer providers treat them case-insensitively in practice. - Split on the @. Anything without exactly one unquoted @ fails. This single rule catches a large share of paste errors.
- Check the local part. Confirm allowed characters, dot placement and the 64-octet limit.
- Check the domain. Confirm at least two labels, valid label characters, no leading or trailing hyphen in a label, and the 255-octet limit.
- Quarantine, don't delete or correct. Write failures to a separate file with a reason column. Don't auto-correct typos.
gmial.comlooks like a fix forgmail.com, but the address may belong to someone else. Also read the failure pattern as a clue: spaces often mean a name landed in the email field, and two @ signs often mean two addresses were joined in one cell. Fixing the form mapping or import step prevents the next batch of failures. - Pass the survivors to a full verifier for domain, MX, SMTP mailbox and catch-all checks.
Bottom line: Normalise, split, check, quarantine, then verify. Never silently change a customer's address.
How do you clean a CSV for syntax errors, step by step?
This tutorial uses a Python pre-filter that implements the rules above, followed by a full verification run. You need Python 3.9 or later.
Step 1: Save this script as syntax_check.py.
import csv
import re
LOCAL_OK = re.compile(r"[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*")
LABEL_OK = re.compile(r"[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?")
def syntax_problems(raw: str) -> list[str]:
address = raw.strip()
angle = re.search(r"<([^<>]+)>", address) # "Jane Doe <jane@example.com>"
if angle:
address = angle.group(1)
if address.count("@") != 1:
return ["needs exactly one @"]
local, domain = address.split("@")
problems = []
if not (1 <= len(local) <= 64) or not LOCAL_OK.fullmatch(local):
problems.append("local part invalid")
labels = domain.split(".")
if len(domain) > 255 or len(labels) < 2 or not all(LABEL_OK.fullmatch(l) for l in labels):
problems.append("domain invalid")
return problems
with open("input.csv", newline="", encoding="utf-8") as src, \
open("pass.csv", "w", newline="", encoding="utf-8") as ok_file, \
open("fail.csv", "w", newline="", encoding="utf-8") as bad_file:
reader = csv.DictReader(src) # expects a column named "email"
ok = csv.DictWriter(ok_file, fieldnames=reader.fieldnames)
bad = csv.DictWriter(bad_file, fieldnames=reader.fieldnames + ["reason"])
ok.writeheader()
bad.writeheader()
for row in reader:
problems = syntax_problems(row["email"])
if problems:
row["reason"] = "; ".join(problems)
bad.writerow(row)
else:
ok.writerow(row)
Test it on four addresses before you run it on a file. jane.doe@example.com and o'brien+news@example.org pass. jane doe@example.com fails with "local part invalid", and a@@example.com fails with "needs exactly one @". The script is a deliberately narrow pre-filter, not a full RFC 5322 parser. It rejects quoted and UTF-8 local parts on purpose, so review those by hand.
Step 2: Export your list as CSV. Rename the address column to email, and keep an ID column so you can match failures back to your CRM.
Step 3: Run the pre-filter. Run python syntax_check.py. Passing rows go to pass.csv, and failing rows go to fail.csv with a reason column.
Step 4: Review 50 failures by hand. Work out where each pattern came from. Fix only what your source data confirms, such as a typo the customer typed at checkout. Suppress everything else.
Step 5: Create a free account. The Free plan handles lists of up to 150 emails each, up to 25 lists a month, with 750 deep verifications a month.
Step 6: Upload and verify a list. Upload pass.csv, not the raw export. CSV and Excel files up to 10MB are accepted, and the email column is detected automatically. Pro handles lists of up to 25,000 emails each. If a list runs slowly on certain providers, see why verification slows down on some domains.
Step 7: Read the results. Each address is sorted into Valid, Risky or Invalid. Check the catch-all, disposable and role-based flags, which are covered in role-based addresses. For Yahoo and AOL addresses, read how verification handles Yahoo and AOL before you judge those rows. Spot-check single addresses with the free single-email checker.
Step 8: Export before results expire. Results are kept for 24 hours on Free and 30 days on Pro. Download CSV, Excel or JSON promptly.
Step 9: Re-import Valid contacts. There are no native ESP, CRM or Zapier integrations, so the workflow is export, verify, re-import. For automated flows, use the email verification API and automation on a Pro plan. You can get an API key from your account.
Bottom line: Pre-filter locally, review the failure patterns, verify the survivors, and re-import only Valid contacts.
What does a syntax clean look like on a 40,000-row checkout export?
The numbers below are illustrative. The arithmetic uses Unlimited Verifier's published plan limits.
Starting point: A retailer exports 40,000 checkout emails. The pre-filter flags 480 rows:
- 310 with no @ or more than one @
- 120 with embedded spaces
- 50 with other invalid characters
480 ÷ 40,000 = 1.2% fail syntax
That leaves 39,520 rows for verification. Those are the rows the arithmetic below uses.
Option A: Free plan. Each list holds 150 emails, so the remaining rows need:
39,520 ÷ 150 = 263.5, so 264 lists 264 ÷ 25 lists a month = 10.6, so 11 months
Free is not a practical route for this file.
Option B: Pro upload. Pro allows up to 25,000 emails per list, so the 39,520 rows split into:
25,000 + 14,520 = 2 lists
Standard verification is unlimited on every plan. Deep verifications are capped at 25,000 a month on Pro. A deep check on all 39,520 rows therefore needs two months of allowance:
39,520 ÷ 25,000 = 1.6, so 2 months of deep checks
Run deep checks on the highest-value segment first and schedule the rest.
Option C: API. API access is included on Pro, with bulk batches of up to 10,000 emails per request:
39,520 ÷ 10,000 = 3.95, so 4 requests 39,520 ÷ 100,000 monthly API emails = 39.5% of the Pro allowance
Cost: Pro is $29 for one month, or $25 a month billed annually, which is $300 a year. For a one-off clean, the monthly plan is the cheaper way to test the workflow. Check the current email verification pricing before you commit.
Bottom line: A 1.2% syntax failure rate removes 480 rows before any paid check runs. The remaining 39,520 rows fit in two Pro lists.
What are the most common syntax mistakes?
- Over-strict regexes. Rules that reject apostrophes or plus signs drop legal, common addresses without any warning.
- Capping the TLD at six letters. This rejects longer generic TLDs that are perfectly valid.
- Stripping internal spaces.
jane doe@example.comis a typed-in name, not a fixable address. Removing the space invents an address the customer never gave. - Deduplicating raw strings. Gmail delivers mail for addresses that differ only by periods or a
+suffixto the same mailbox on gmail.com, sojane.doe@gmail.comandjanedoe+news@gmail.comare one contact. Deduplicate on that basis for Gmail addresses. - Treating a syntax pass as consent. A well-formed address is not an opted-in one. Consent sits on top of syntax checks, which is why list maintenance practices include re-checking addresses on a schedule.
- Losing results to the retention window. Free results are kept 24 hours, so save them before the window closes.
- Confusing syntax with email verification compliance and hygiene. A clean syntax file is one step in hygiene, not a compliance record in itself.
Bottom line: Most syntax damage comes from rules stricter than the standard, or cleaning more aggressive than the data supports.
How we compared (and limitations)
This article is based on public documentation: the text of RFC 5321, RFC 5322, RFC 6531, RFC 1035 and RFC 2606, the WHATWG HTML Standard, and Unlimited Verifier's published plan facts. We have not run controlled tests against any verifier or ESP.
The Python script is an illustrative pre-filter, not a full RFC 5322 implementation. Check it against a sample of your own data before you run it on a production list. The 99.5% deep verification accuracy figure is Unlimited Verifier's own stated number, not an independent benchmark. Worked-example numbers are illustrative. Plan limits and retention windows can change, so confirm them on the pricing page before you plan a large job.
Bottom line: Use the grammar for triage, the full pipeline for decisions, and your own sample to confirm both.
Syntax check on a sample CSV row
| Input | Syntax result | Reason | Next step |
|---|---|---|---|
| o'brien@example.com | Pass | Apostrophe is a legal atom | Import |
| jane+news@example.com | Pass | Plus is a legal atom | Import |
| jane doe@example.com | Fail | Unquoted space | Fix or remove |
| first..last@example.com | Fail | Doubled dot | Fix or remove |
| Jane Doe jane@example.com | Extract, then pass | name-addr form | Import address only |
| jane@gmial.com | Pass | Well formed | Run domain and mailbox checks |
Frequently asked questions
Is RFC 5322 the same as RFC 5321?
No. RFC 5322 defines the address format used in message headers such as From and To. RFC 5321 governs SMTP delivery and sets length limits, including 64 octets for the local part and 255 for the domain. Validators that mix the two often produce confusing results.
Does a valid RFC 5322 address mean the email works?
No. Syntax only confirms the address is well formed. A typo like jane@gmial.com passes syntax yet may not be a real mailbox. Domain, MX record, and mailbox checks are needed to confirm deliverability.
Are plus signs allowed in email addresses?
Yes. The plus sign is an allowed atom character in the local part under RFC 5322, so jane+news@example.com is syntactically valid. Whether a provider routes plus-addressed mail the same way depends on that provider.
Can an apostrophe appear in an email address?
Yes. Apostrophes are legal unquoted atom characters, so o'brien@example.com is well formed. Many older forms wrongly reject them, which causes valid customers to be dropped from lists.
Are spaces allowed in the local part?
Not unquoted. A space is only legal inside a quoted string, such as "jane doe"@example.com. For marketing lists, reject internal spaces because they are almost always paste errors.
What is the maximum length of an email address?
RFC 5321 sets 64 octets for the local part and 255 for the domain. The full path is limited to 256 octets in that standard. Practical checks usually cap the whole address at 254 characters.
Should I accept comments like jane(work)@example.com?
RFC 5322 permits comments, but a marketing list should not contain them. Flag them for review rather than importing them, because they are rarely intentional and some mail systems mishandle them.
Should I accept UTF-8 characters in addresses?
Internationalized addresses are defined in separate standards (RFC 6531 and related). Many systems still reject them, so flag UTF-8 addresses for review and confirm provider support before sending.
What is name-addr format?
It is the form Jane Doe <jane.doe@example.com>, combining a display name with an address in angle brackets. CRM exports often contain it, so extract the address before running syntax checks.
Cut Bounces and Protect Your Sender Reputation With Unlimited Email Verification
Every invalid address you send to hurts your sender reputation and your inbox placement. Verifying your list before each send means fewer bounces, healthier deliverability, and a predictable cost. With Unlimited Verifier, standard verification is unlimited on every plan, with no per-email fees.
Unlimited Verifier checks syntax, domain, MX records and the SMTP mailbox. It also detects catch-all domains and flags disposable and role-based addresses. Export a CSV from your email platform or CRM, upload and verify the list, then re-import the clean results. You can also automate checks with the email verification API.
| Free | Pro | |
|---|---|---|
| Price | $0 | $29/month ($25/month billed annually) |
| Lists | 25 a month, up to 150 emails each | Unlimited, up to 25,000 emails each |
| Deep verifications | 750 a month | 25,000 a month |
| API access | No | Yes (100,000 emails a month) |
| Result retention | 24 hours | 30 days |
Why teams choose Unlimited Verifier
- Unlimited standard verification on all plans, including Free, with no per-email fees.
- Catch-all detection so you know which domains accept every address.
- Clear Valid / Risky / Invalid results, exportable as CSV, Excel or JSON.
- An open-source verification engine you can inspect on GitHub.
Unlimited Verifier states 99.5% accuracy for deep verification.
Create a free account and verify your next list before you hit send.
Want to test a single address first? Try the free email checker.