Free trial The cheapest email marketing platform: try Moosend free for 30 days, no credit card. Don't miss your seat. The cheapest email marketing platform Start free trial →

RFC 5321: Simple Mail Transfer Protocol

The authoritative SMTP standard defining the full MTA-to-MTA command sequence.

Alaa Touil
Email infrastructure specialist, 8+ years in SMTP and deliverability
15 min read Updated Nov 9, 2026 1.0K views
RFC 5321 Simple Mail Transfer Protocol - SMTPedia reference
RFC 5321
Simple Mail Transfer Protocol

Current standard

Domain
SMTP
Published
October 2008
Obsoletes
RFC 2821, RFC 821
SMTP relevance
foundational

↗ Read on rfc-editor.org

What this RFC defines

RFC 5321 is the current SMTP standard. It defines the complete protocol for transferring email between servers: the TCP session lifecycle, the EHLO greeting, the MAIL FROM and RCPT TO envelope commands, the DATA transaction, and the QUIT teardown. Every mail server on the internet, whether Postfix, Exchange, or SendGrid, implements this document.

Where you see it in practice

The three-digit reply codes in your bounce messages (220, 250, 421, 450, 550, 554) are defined here. When a receiving server rejects your message with “550 5.1.1 User unknown”, that code structure traces back to RFC 5321 section 4.2. RFC 5321 asks the client to send its fully-qualified domain name in EHLO (section 4.1.1.1). It does not require that name to match the PTR record of the sending IP: that check is a receiver policy, but one so widely applied (Gmail, Microsoft, Spamhaus-based filters) that missing or mismatched reverse DNS is one of the most common causes of rejection.

Implementation across major MTAs

Every production mail transfer agent implements RFC 5321. Postfix, Exim, Sendmail, and Microsoft Exchange are the four dominant open-source and enterprise MTAs, and each conforms to the base protocol described in the document, with minor policy differences in areas the RFC leaves as SHOULD or MAY. Cloud services like Amazon SES, SendGrid, Mailgun, Postmark, and SparkPost also speak RFC 5321 on their outbound relays and accept it on their inbound MX endpoints. The universality of RFC 5321 conformance is why interoperability at the SMTP layer is essentially a solved problem in 2026.

Common misconceptions

Three misconceptions recur frequently. First, RFC 5321 does not mandate authentication; SMTP AUTH is defined in RFC 4954 as an extension. A vanilla RFC 5321 conversation does not require the sender to authenticate, which is why open relays existed for decades before operational best practice mandated closing them. Second, RFC 5321 does not require TLS; STARTTLS is defined in RFC 3207 as an optional extension. RFC 8314 later declared cleartext obsolete for submission, but RFC 5321 itself remains protocol-agnostic on transport security. Third, the SIZE line in an EHLO response is a hint, not a hard commitment; a receiving server can accept a message larger or smaller than the advertised limit depending on per-recipient policy.

Testing conformance

The classic conformance check is a telnet session to port 25 (or 587 for submission), where you type each command manually and verify that the responses follow the reply-code grammar. Automated conformance is typically done with tools like swaks or the Postfix smtp-source utility. For inbound conformance, the receiving MTA logs should show your EHLO greeting, MAIL FROM and RCPT TO exchanges, and the final DATA acceptance. Any of these steps rejecting valid input, or accepting clearly invalid input, indicates a conformance issue.

Quick Reference

RFC 5321 (October 2008) is the current Simple Mail Transfer Protocol standard. It defines the complete server-to-server email transfer protocol: TCP session, EHLO handshake, MAIL FROM and RCPT TO envelope, DATA transaction, three-digit reply codes, and QUIT teardown. Obsoletes RFC 2821 (2001) and RFC 821 (1982). Works alongside RFC 5322 (message format), RFC 3207 (STARTTLS), RFC 4954 (SMTP AUTH), and RFC 6409 (message submission on port 587). A revision, draft-ietf-emailcore-rfc5321bis, has been approved by the IESG and is waiting in the RFC Editor queue; until it is published under a new number, RFC 5321 remains the standard (see What comes after RFC 5321).

RFC 5321 at a glance

AspectDetail
PurposeServer-to-server email transfer protocol
TransportTCP, typically port 25 (server-to-server) or 587 (client submission per RFC 6409)
Session modelStateful command/response with three-digit reply codes
Core commandsEHLO, MAIL FROM, RCPT TO, DATA, QUIT (plus RSET, NOOP, VRFY, EXPN, HELP)
Reply code structure3-digit numeric: first digit is severity class, remaining digits refine
Extension mechanismEHLO response advertises supported extensions per RFC 1869
PublishedOctober 2008 (obsoletes RFC 2821, RFC 821)
StatusCurrent standard; revision (5321bis) approved and in the RFC Editor queue

Complete SMTP command reference

RFC 5321 defines a small set of commands that flow between client (sending MTA) and server (receiving MTA). Every SMTP conversation follows the same pattern: server greeting, EHLO exchange, envelope commands, DATA, and QUIT.

CommandPurposeExampleSection
HELOLegacy greeting (RFC 821), rarely used todayHELO mail.example.com4.1.1.1
EHLOExtended greeting, triggers capability advertisementEHLO mail.example.com4.1.1.1
MAIL FROMEnvelope sender (Return-Path)MAIL FROM:<sender@example.com>4.1.1.2
RCPT TOEnvelope recipient (one per command)RCPT TO:<user@example.com>4.1.1.3
DATABegin message body transfer, ends with . on line aloneDATA4.1.1.4
RSETAbort current transaction, keep connectionRSET4.1.1.5
VRFYVerify address exists (often disabled for anti-harvesting)VRFY user@example.com4.1.1.6
EXPNExpand mailing list (usually disabled)EXPN list@example.com4.1.1.7
HELPRequest server-side help textHELP4.1.1.8
NOOPNo operation, keep-aliveNOOP4.1.1.9
QUITEnd sessionQUIT4.1.1.10

SMTP reply code structure

Every SMTP command produces a three-digit reply code. The first digit indicates the severity class; the second digit categorizes the source; the third digit adds specificity. Modern deployments extend this with enhanced status codes per RFC 3463 (see also DSN parsing guide for practical parsing).

First digitClassMeaningCommon examples
2xxSuccessCommand accepted and completed220 Ready, 221 Bye, 250 OK, 251 User forwarded
3xxIntermediateAwaiting more input from client354 Start mail input (after DATA)
4xxTransient failureRetry later, may succeed421 Service unavailable, 450 Mailbox busy, 451 Local error, 452 Insufficient storage
5xxPermanent failureDo not retry, address the underlying issue550 Mailbox unavailable, 551 User not local, 552 Storage full, 553 Bad address, 554 Transaction failed

Each code has its own troubleshooting page with real bounce samples and fixes per mail server: browse the full SMTP reply code library.

Size limits defined in RFC 5321

Section 4.5.3.1 sets the minimum sizes every SMTP implementation must accept. Servers may accept more, but anything that stays within these limits must work everywhere. These numbers are also why email validation libraries reject some addresses as too long.

ObjectLimitWhat it means in practice
Local part (before the @)64 octetsfirstname.lastname must fit in 64 characters (ASCII)
Domain255 octetsUpper bound for the part after the @
Path (address in MAIL FROM or RCPT TO)256 octets, including the angle bracketsA full address can therefore be at most 254 characters
Command line512 octets, including CRLFLimit for one SMTP command such as RCPT TO:<...>
Reply line512 octets, including CRLFLimit for one line of a server response
Text line in the message1000 octets, including CRLFLong lines in HTML emails must be wrapped or encoded (quoted-printable or base64)
Recipients per transactionAt least 100 must be acceptedServers can refuse more with a 452 reply, so senders must be ready to split
Validating addresses? Check the 64-octet local part and the 254-character total before you send. Longer addresses cannot be delivered reliably even if your form accepts them.

What the big providers actually allow

RFC 5321 sets floors, not ceilings: every server must accept at least what the table above lists, and each provider then picks its own limits. These are the values documented by the providers themselves, and the ones you actually hit when a message bounces.

Provider or MTAMaximum message sizeRecipients per messageBounce you get when you exceed it
Gmail and Google Workspace25 MB to send, 50 MB to receive (Google announced higher limits for Enterprise Plus in 2026)Set by Google’s sending limits for the account type (consumer or Workspace)552 message size exceeded
Microsoft 365 (Exchange Online)Configurable by the admin up to 150 MB500 by default, customizable up to 1,000552 5.3.4, or a 452 / 550 when the recipient limit is reached
Postfix (default settings)message_size_limit = 10240000 bytes (about 10 MB)smtpd_recipient_limit = 1000552 for size; recipients over the limit receive a temporary 452 so the sender can retry them
RFC 5321 minimumAt least 64K octets must be accepted (§4.5.3.1.7); servers announce their real limit with the SIZE extension (RFC 1870)At least 100 must be accepted452 “too many recipients” means: send the rest in a new transaction
Attachments grow in transit. Base64 encoding adds about a third to a file’s size, so a 20 MB attachment becomes a message of roughly 27 MB and fails against a 25 MB limit. Leave margin, or send a link. More detail in our email attachment size limits guide.

A complete SMTP dialogue

Full SMTP session (client → server flow)
S: 220 mx.example.com ESMTP Postfix
C: EHLO mail.sender.com
S: 250-mx.example.com Hello mail.sender.com [192.0.2.10]
S: 250-SIZE 52428800
S: 250-8BITMIME
S: 250-STARTTLS
S: 250-ENHANCEDSTATUSCODES
S: 250-PIPELINING
S: 250-DSN
S: 250-CHUNKING
S: 250 SMTPUTF8
C: MAIL FROM:<alice@sender.com>
S: 250 2.1.0 Ok
C: RCPT TO:<bob@example.com>
S: 250 2.1.5 Ok
C: DATA
S: 354 End data with <CR><LF>.<CR><LF>
C: From: Alice <alice@sender.com>
C: To: Bob <bob@example.com>
C: Subject: Test message
C:
C: Hello Bob, this is a test.
C: .
S: 250 2.0.0 Ok: queued as ABC123
C: QUIT
S: 221 2.0.0 Bye

Common ESMTP extensions

The EHLO response advertises server capabilities as extensions per RFC 1869. Modern SMTP servers implement dozens of extensions; the essentials are listed below.

ExtensionAdvertised asDefined inPurpose
SIZESIZE 52428800RFC 1870Advertise maximum message size in bytes
8BITMIME8BITMIMERFC 6152Accept 8-bit MIME content without encoding
STARTTLSSTARTTLSRFC 3207Upgrade cleartext connection to TLS
AUTHAUTH LOGIN PLAINRFC 4954Client authentication (list of mechanisms)
PIPELININGPIPELININGRFC 2920Batch multiple commands without waiting for reply
ENHANCEDSTATUSCODESENHANCEDSTATUSCODESRFC 2034Return X.Y.Z codes alongside 3-digit codes
DSNDSNRFC 3464Support delivery status notifications
CHUNKINGCHUNKINGRFC 3030Transfer message body in binary chunks (BDAT)
SMTPUTF8SMTPUTF8RFC 6531Support internationalized mailbox names
BINARYMIMEBINARYMIMERFC 3030Accept binary MIME parts (requires CHUNKING)

Common SMTP implementation pitfalls

EHLO hostname does not resolve or does not match PTR. RFC 5321 section 4.1.1.1 asks for the client’s fully-qualified domain name (or an address literal) as the EHLO argument. On top of that, strict receivers cross-check that reverse DNS (PTR) of the sending IP matches the EHLO hostname (FCrDNS). Mismatch causes rejections like 550 Access denied: Invalid HELO name. Fix: publish PTR matching your EHLO hostname (see PTR and rDNS records guide).
MAIL FROM with quoted display name or CFWS. The MAIL FROM envelope uses simple mailbox format, not the full RFC 5322 mailbox with display name. Sending MAIL FROM:<"Sender Team" <team@example.com>> is a syntax error. Use only the bare address: MAIL FROM:<team@example.com>. Display names go in the From header inside DATA.
Retrying 5xx responses as though they were transient. RFC 5321 section 4.5.4 mandates that 5xx is permanent. Retrying a 5xx bounce violates protocol semantics and damages sender reputation because receivers track how many times you send to known-bad addresses (see hard bounce vs soft bounce guide).
Ignoring TIMEOUT values in section 4.5.3.2. RFC 5321 specifies minimum timeouts for each phase of the SMTP conversation: 5 minutes for the initial 220 greeting, 5 minutes for the replies to MAIL and RCPT, 2 minutes for the 354 reply to DATA, 3 minutes for each block of data sent, and 10 minutes for the final 250 after the terminating dot (the server may be scanning the message). Aggressive short timeouts cause premature disconnects with slow receivers; long timeouts hold sockets open unnecessarily. Follow the spec.
Not handling BDAT after advertising CHUNKING. Some servers advertise CHUNKING in EHLO but reject BDAT commands in practice. If you implement CHUNKING support on the client side, test against real receivers; fall back to DATA on BDAT errors.

From the RFC to the bounce: what breaks in practice

Most SMTP rejections you will see trace back to one rule in RFC 5321, or to a receiver policy built on top of it. This table connects the two, with a troubleshooting page for each case.

Rule or policyWhere it comes fromTypical rejectionFix
EHLO must carry the client’s real domain nameRFC 5321 §4.1.1.1, plus receiver checks550 Access denied: invalid HELO nameSend a resolvable FQDN in EHLO, never localhost or a bare IP
Reverse DNS must exist and matchReceiver policy (not required by RFC 5321)421 No reverse DNS, Spamhaus HELO and rDNS checksPublish a PTR that resolves back to the IP and matches the EHLO name
Servers may cap recipients per transaction (minimum 100)RFC 5321 §4.5.3.1.8 and §4.5.3.1.10452 4.5.3 Too many recipientsTreat 452 as temporary: send the remaining recipients in a new transaction
Message larger than the server acceptsSIZE extension (RFC 1870)552 5.3.4 Message size exceeds fixed maximumCompress, split, or send a download link
Relaying only for authorized clientsRFC 5321 §3.6 (relaying), enforced by every MTA550 5.7.1 Relaying denied, 503 Authentication requiredAuthenticate on port 587, or send to a domain the server is MX for
4xx means try again laterRFC 5321 §4.2.1 and §4.5.4421 4.7.0 Too many connections, 452 4.2.2 Mailbox fullQueue and retry with back-off; never retry a 5xx the same way
Text lines limited to 1,000 octetsRFC 5321 §4.5.3.1.6Rejections or broken HTML when a line is too longEncode HTML bodies in quoted-printable or base64

Migration from RFC 2821 to RFC 5321

AspectRFC 2821 (2001)RFC 5321 (2008)Impact if code targets 2821
Core protocolComplete SMTPIdentical semantics with clarificationsNone
Reply code registryEnumerated in RFCDelegated to IANAUpdate reference; no code change
Address literal syntaxIPv4 only in bracket formAdds IPv6 with IPv6: tagUpdate address parser for IPv6
Errata integrationSeparate errataErrata integrated in main textNone
InternationalizationASCII onlyASCII base with pointer to RFC 6531 for SMTPUTF8None (extension is separate RFC)
SIZE recommendationsSection 3.1.1Clarified in section 4.5.3.1.5Review SIZE handling logic
Should you migrate? Yes. RFC 2821 is obsolete; all references and implementations should target RFC 5321. In practice, code correctly implementing RFC 2821 already works fine against RFC 5321 peers because the protocol is backward compatible. The migration is primarily about documentation and reference accuracy.

What comes after RFC 5321

The IETF EMAILCORE working group has revised the core email standards. Its SMTP revision, draft-ietf-emailcore-rfc5321bis, has been approved by the IESG with the intended status of Internet Standard and sits in the RFC Editor queue. The matching revision of the message format (5322bis) is in the same queue, and both are waiting for a companion Applicability Statement, still being finalized, that gives guidance on using the core protocols.

What it means for you today. Nothing to change yet. The revision is a cleanup and clarification of SMTP, not a new protocol: servers that follow RFC 5321 will keep working. Keep citing RFC 5321 until the new RFC number is published; we will update this page when it is.
Core SMTP ecosystem RFCs

  • RFC 5322: Internet Message Format (headers and body of the actual message)
  • RFC 6409: Message Submission (port 587 client-to-server distinction)
  • RFC 3207: STARTTLS extension for SMTP over TLS
  • RFC 4954: SMTP AUTH extension
  • RFC 8314: Cleartext considered obsolete for submission/access
  • RFC 6152: 8-bit MIME transport
  • RFC 1869: The EHLO extension mechanism
Report and status RFCs (built on SMTP)

Authentication and deliverability layer

SMTPedia companion guides

Frequently asked questions

What is the difference between HELO and EHLO?

HELO is the legacy greeting from RFC 821 (1982). EHLO is the extended greeting introduced in RFC 1869 and codified in RFC 5321. When a client sends EHLO, the server responds with a multi-line reply listing all supported extensions (SIZE, STARTTLS, AUTH, PIPELINING, and others). HELO produces only a single greeting line without capability information. Modern clients always send EHLO first; if the server responds with a syntax error, they fall back to HELO. In 2026, every production SMTP server supports EHLO; HELO is retained purely for backward compatibility.

What is the maximum length of an email address under RFC 5321?

The local part (before the @) is limited to 64 octets and the domain to 255 octets. The binding limit is the path used in MAIL FROM and RCPT TO, which is 256 octets including the angle brackets. In practice, a deliverable email address is at most 254 characters long.

Does RFC 5321 require authentication?

No. RFC 5321 defines the base SMTP protocol; authentication is a separate extension in RFC 4954. A vanilla RFC 5321 conversation does not require the client to authenticate. This is why open relays existed for decades; the protocol did not mandate closure. Modern operational best practice requires AUTH for message submission (per RFC 6409 and RFC 8314) but server-to-server relay per RFC 5321 remains authentication-optional.

Does RFC 5321 require TLS?

No. RFC 5321 is transport-security-agnostic; STARTTLS is defined as an optional extension in RFC 3207. RFC 8314 (2018) declared cleartext obsolete for message submission and access, but did not amend RFC 5321 for server-to-server relay. Practical reality in 2026: cleartext SMTP relay still occurs when both peers lack STARTTLS support, though this is uncommon at reputable providers. TLS-required policies (MTA-STS, DANE) sit on top of RFC 5321 as separate mechanisms.

What is the difference between MAIL FROM and the From header?

MAIL FROM is the envelope sender, a protocol-level attribute of the SMTP conversation. It becomes the Return-Path header of the delivered message and is used for bounce routing. The From header is a message-level attribute inside DATA, defined by RFC 5322, that names the visible sender to the recipient. The two can differ (a common pattern with newsletter platforms where MAIL FROM points at a bounce-processing subdomain but From displays the company brand). Anti-spoofing mechanisms like DMARC require alignment between these two identities per configured policy.

Why do some servers disable VRFY and EXPN?

Both commands allow a client to query which addresses exist on a server without sending mail. Spammers used VRFY to harvest valid addresses from target domains at scale. Modern operational best practice disables both commands on internet-facing MTAs to prevent address harvesting. RFC 5321 section 3.5.3 explicitly permits this: implementations MAY implement VRFY as a no-op returning 252 (cannot verify) to avoid disclosing address existence. Most production Postfix and Exchange deployments disable VRFY and EXPN entirely.

What happens when a message hits the SIZE limit?

If the client sent the SIZE parameter with MAIL FROM and the value exceeds the server-advertised limit, the server rejects at MAIL FROM with a 552 or 452 code before any data transfer. If the client did not declare SIZE, the server can still reject after DATA if the actual message exceeds its limit. Either path produces a bounce back to the sender. Some servers accept messages slightly over the advertised limit as a courtesy; others enforce strictly. The SIZE extension itself is defined in RFC 1870, not in RFC 5321.

Did this guide save you time?

SMTPedia is free and independent. A coffee helps keep every guide accurate.

Buy SMTPedia a coffee

See SMTPedia first on Google

Add us as a preferred source in Top Stories.

Add as preferred source

About the Author

Alaa - SMTPedia author

Alaa · LinkedIn

Email infrastructure specialist with 8+ years of hands-on experience in SMTP, deliverability, and email verification. I’ve configured and troubleshot mail systems across Postfix, Exchange, and cloud relays, managed IP reputation and warmup campaigns, and built verification pipelines processing millions of addresses. My work spans DNS authentication (SPF, DKIM, DMARC, BIMI), bounce handling, blocklist monitoring, and compliance frameworks including CAN-SPAM and GDPR. I write every article on SMTPedia to give email professionals, developers, and marketers the accurate, RFC-grounded reference they need.


About SMTPedia

SMTPedia is an independent email industry reference covering SMTP, IMAP, POP3, email deliverability, marketing platforms, DNS authentication, and email verification. Every article is researched from official provider documentation, IETF RFCs, and industry best practices. Settings and configurations are verified quarterly.

We are cited as a source by ChatGPT, Microsoft Copilot, and thousands of email professionals worldwide. Learn more about our editorial process.