Skip to content
send.io
All posts

SMTP commands and response codes reference

SMTP commands and response codes mapped to actions: 2xx proceed, 4xx retry with backoff, 5xx stop and fix the root cause immediately. This reference shows you exactly what each reply code means and which failures are retryable versus permanent so you stop wasting queue capacity on dead addresses.

On this page
TL;DR: SMTP is a strict state machine. SMTP commands follow the sequence HELO/EHLO (Hello/Extended Hello) → MAIL FROM → RCPT TO → DATA → QUIT. SMTP response codes tell you what to do next: 2xx means proceed, 4xx means retry with backoff, 5xx means stop and fix the root cause. For a 550, the enhanced status code decides the fix: 550 5.1.1 means remove the address, while 550 5.7.1 means fix your sender authentication first. Use telnet for plaintext debugging and openssl s_client for encrypted sessions.

Your application logs a 550 response, and your retry queue starts filling up. Before you touch the code, you need to know whether that 550 means "fix your Sender Policy Framework (SPF) record" or "this address never existed." This reference maps every standard Simple Mail Transfer Protocol (SMTP) command to its expected server response, then translates each reply code into a concrete action: proceed, retry, or abandon.

Essential SMTP commands for debugging

SMTP debugging starts with knowing what the client sends and what the server returns. The commands below form the core of every SMTP session, from initial handshake to final disconnect. Each produces a numeric reply code that tells you whether to proceed, retry, or stop.

Core SMTP command flow

A compliant SMTP session follows a strict sequence defined in Request for Comments (RFC) 5321. The client opens a connection, receives a 220 greeting, identifies itself with EHLO (or HELO), specifies the sender with MAIL FROM, adds recipients with RCPT TO, transmits the message with DATA, and closes with QUIT. Each command must complete successfully before the next executes. Issuing commands out of sequence produces a 503 "Bad sequence of commands" error.

Parsing raw SMTP command strings

In a packet capture or application log, each command follows a fixed pattern: the verb, a space, then the argument, terminated by a carriage return and line feed (CRLF). MAIL FROM and RCPT TO wrap address arguments in angle brackets. DATA takes no arguments but triggers a mode change where everything that follows is message content until the server sees a line containing only a period.

SMTP command execution lifecycle

  1. Connect: Server responds 220.
  2. EHLO: Server responds 250 with capability list.
  3. MAIL FROM: Server responds 250.
  4. RCPT TO: Server responds 250 or 251 per recipient.
  5. DATA: Server responds 354, then 250 after message body.
  6. RSET (optional): Server responds 250, resets transaction.
  7. NOOP (optional): Server responds 250, no state change.
  8. QUIT: Server responds 221, closes connection.

RSET (Reset) and NOOP (No Operation) can appear at any point after EHLO without breaking the sequence. RSET aborts the current mail transaction and returns to the post-EHLO state. NOOP confirms the connection is alive.

Key SMTP commands for telnet troubleshooting

Telnet gives you direct access to the SMTP conversation, per Microsoft's telnet testing guide. Every command below can be typed manually into a telnet session to test server behavior without writing application code, a direct way to isolate whether a failure originates in your code, your credentials, or the receiving server.

Session initiation: HELO vs EHLO

HELO is the original SMTP greeting, defined in RFC 821. EHLO is the extended version, introduced in RFC 1869 (SMTP Service Extensions, November 1995). RFC 2821 (April 2001) later obsoleted both documents, along with RFC 974, and required servers to support both HELO and EHLO. RFC 5321 has since obsoleted RFC 2821 and carries EHLO in the core SMTP specification. EHLO triggers capability discovery: when you send it, the server responds with a multiline 250 reply listing every extension it supports: SIZE, 8BITMIME, AUTH, STARTTLS, and others from the Internet Assigned Numbers Authority (IANA) SMTP Service Extension Registry.

HELO returns a single 250 line with no extension list. If a server returns "command not recognized" to EHLO, fall back to HELO. In practice, always use EHLO first because the capability list tells you whether the server supports authentication, Transport Layer Security (TLS), and message size limits before you attempt to use them.

Defining the MAIL FROM sender address

MAIL FROM initiates a mail transaction and specifies the envelope sender: MAIL FROM:<sender@example.com>. The server validates the address format and responds 250 on success. This address receives bounce notifications if delivery fails.

The envelope sender can differ from the From: header in the message body. Bounce processing and SPF checks use the envelope sender. A 553 response here means the server rejected the address format. A 550 means the server refuses to accept mail from this sender, often due to authentication or policy restrictions.

RCPT TO command and address validation

RCPT TO adds one recipient to the current transaction. You can issue multiple RCPT TO commands for a single message. The server responds 250 if the recipient is accepted, 251 if the user is not local but will be forwarded, or a 5xx code if rejected.

This is where most delivery failures surface. A 550 means the mailbox does not exist or the server refuses the message for policy reasons. A 451 means the server hit a local processing error and you should retry later. A 452 means the server cannot accept more recipients due to storage or rate limits. Each RCPT TO gets its own reply, so a message to five recipients produces five response codes.

Understanding SMTP DATA command flow

DATA signals that the client is ready to transmit the message body. The server responds 354 and waits. The client sends headers (From, To, Subject, Date), a blank line, then the body text, ending with a line containing only a period (\r\n.\r\n).

After the terminating period, the server responds 250 if it accepted the message for delivery. A 4xx response means the server temporarily could not process the message (queue full, disk space). A 5xx means the message was rejected (content policy, size limit exceeded).

Canceling SMTP operations with RSET

RSET aborts the current mail transaction without closing the connection. The server responds 250 and discards any sender, recipient, or message data from the current transaction. If you issue RSET immediately after EHLO or before starting a new transaction, it acts as a no-op because there is no transaction to cancel.

Use RSET when you need to send a new message on the same connection but the previous transaction encountered an error. Reusing the existing TCP connection avoids the overhead of a new handshake.

Using NOOP to verify SMTP liveness

NOOP confirms the server is still responsive: the server responds 250. Use NOOP to keep a connection alive during long pauses or to verify a firewall or load balancer has not dropped it.

A non-250 response to NOOP indicates a problem on either side: a 4xx suggests a temporary server-side issue, while a 5xx can reflect a permanent server failure or a client-side error such as a syntax problem. RFC 5321 does not mandate connection closure after a failed NOOP, but in practice you should treat it as a signal to end the session cleanly with QUIT before reconnecting and attempting further commands.

Terminating SMTP sessions with QUIT

QUIT ends the session, and the server responds 221 and closes the connection. Always send QUIT before closing the TCP connection. RFC 5321 requires the sender to send QUIT before closing the channel. If the connection drops prematurely, the server must cancel any pending transaction, without undoing transactions that already completed.

Standard SMTP AUTH workflow and syntax

SMTP AUTH extends the protocol to provide authentication before accepting mail for relay. Without AUTH, any client that can reach the server can send mail through it, which is why open relays were a persistent spam vector before AUTH became standard. The AUTH command and its security mechanisms are defined in RFC 4954.

Defining SMTP AUTH command arguments and mechanisms

The AUTH command takes one required argument: the Simple Authentication and Security Layer (SASL) mechanism name. Common mechanisms include PLAIN, LOGIN, and Challenge-Response Authentication Mechanism with Message Digest 5 (CRAM-MD5). PLAIN accepts an optional initial response as a second argument, base64-encoded.

The PLAIN mechanism encodes three components separated by null bytes: [authzid]\x00[authcid]\x00[passwd]. For example, the string test\0test\01234 encodes to dGVzdAB0ZXN0ADEyMzQ=. The full command:

AUTH PLAIN dGVzdAB0ZXN0ADEyMzQ=

The server advertises its supported mechanisms in the EHLO response:

250-AUTH PLAIN LOGIN

PLAIN sends credentials in a single base64-encoded string. LOGIN uses a two-step prompt-response sequence (not a cryptographic challenge like CRAM-MD5): the server requests a base64-encoded username, then a base64-encoded password. CRAM-MD5 avoids sending plaintext passwords over the wire, but the server must still hold secret-equivalent material (the plaintext or a precomputed MD5 context) to verify the response, which RFC 2195 itself notes offers only marginal protection over cleartext storage if the server is compromised.

SMTP AUTH handshake sequence

  1. Client sends EHLO, server responds with capabilities including AUTH.
  2. Client sends AUTH PLAIN <base64-credentials>.
  3. Server responds 235 (authentication successful) or 535 (authentication failed).

If the server requires STARTTLS before AUTH, it advertises AUTH only after the TLS handshake completes. Never send credentials over an unencrypted connection.

SMTP security checklist

Before sending credentials over SMTP:

  1. Never send AUTH over unencrypted connections. Port 25 plaintext carries credentials in the clear.
  2. Use port 587 with STARTTLS for submission. The server must advertise STARTTLS in its EHLO response before you issue AUTH.
  3. Use port 465 for implicit TLS if the server supports it. The TLS handshake completes before SMTP commands begin.
  4. Verify the server enforces encryption by checking that AUTH is not advertised before STARTTLS on a STARTTLS-required server.

Debugging SMTP flows with manual telnet

Manual testing isolates protocol-level failures from application bugs. Telnet works for plaintext connections, and openssl s_client handles encrypted sessions. Both let you type SMTP commands directly and see raw server responses.

Verifying server access with telnet

Connect on port 25 (SMTP) or 587 (submission):

telnet smtp.example.com 25

A successful connection returns a 220 greeting. If the connection times out, the server is unreachable or a firewall blocks the port. If you get connection refused, no SMTP service is listening on that port.

For encrypted connections, use openssl s_client:

# Port 587 with STARTTLS
openssl s_client -starttls smtp -crlf -connect smtp.example.com:587

# Port 465 with implicit TLS
openssl s_client -crlf -connect smtp.example.com:465

The -crlf flag ensures correct line endings. After the TLS handshake completes, type EHLO and continue as normal.

Tool

Protocol

Port

Use Case

Command Example

telnet

Plaintext

25

Test unencrypted sessions

telnet smtp.example.com 25

openssl s_client

TLS/ Secure Sockets Layer (SSL)

587 (STARTTLS), 465 (implicit TLS)

Test encrypted sessions

openssl s_client -starttls smtp -connect smtp.example.com:587

End-to-end SMTP command flow

This annotated session shows a complete SMTP conversation:

# Client connects
S: 220 smtp.example.com ESMTP ready

# Client identifies itself
C: EHLO test.local
S: 250-smtp.example.com
S: 250-SIZE 52428800
S: 250-AUTH PLAIN LOGIN
S: 250 OK

# Client specifies sender
C: MAIL FROM:<sender@example.com>
S: 250 OK

# Client specifies recipient
C: RCPT TO:<recipient@example.com>
S: 250 OK

# Client signals message body
C: DATA
S: 354 Start mail input; end with <CRLF>.<CRLF>

# Client sends headers and body
C: From: sender@example.com
C: To: recipient@example.com
C: Subject: Test message
C:
C: This is a test.
C: .
S: 250 OK: queued as 12345

# Client ends session
C: QUIT
S: 221 Bye

The S: and C: labels are annotations, not part of the actual protocol. In a real telnet session, you type only the client lines and the server responds with the numbered lines.

Interpreting SMTP response codes

The first digit tells you the category:

Class

Meaning

Action

Examples

2xx

Success

Proceed to next step

220, 250, 235

3xx

Intermediate

Continue with protocol

354

4xx

Temporary failure

Retry with backoff

421, 450, 451, 452

5xx

Permanent failure

Stop, fix root cause

550, 551, 552, 553

Enhanced status codes from RFC 3463 add a X.Y.Z suffix (class.subject.detail) for more specific diagnostics. For example, 550 5.1.1 means permanent failure (5), address issue (1), mailbox does not exist (1).

How SMTP response classes define failures

Reply codes are decision signals. Treating a 5xx as retryable wastes queue capacity, and treating a 4xx as permanent loses deliverable mail.

Interpreting 2xx SMTP replies

2xx codes mean the server accepted the command or message. The most common is 250, appearing after EHLO, MAIL FROM, RCPT TO, and final message acceptance after DATA. Code 220 appears at connection time, 221 after QUIT, and 235 after successful AUTH.

A 250 after DATA means the server accepted responsibility for delivering the message, not that it was delivered, so delivery failures after this point generate bounce messages sent to the envelope sender.

Debugging SMTP 4xx temporary errors

4xx codes mean the failure is temporary and the client should retry later. Common causes: rate limiting, greylisting, and resource exhaustion on the receiving server.

Code 421 means the service is temporarily unavailable, often due to rate limiting. Code 450 means the mailbox is temporarily unavailable, often associated with greylisting (an anti-spam technique that rejects the first delivery attempt and accepts retries). Code 451 indicates a local processing error. Code 452 means insufficient storage or too many recipients.

For all 4xx codes, queue the message and retry with exponential backoff. See the Backoff patterns for SMTP errors table below for a concrete delay schedule with jitter and a maximum retry window.

Addressing 5xx SMTP delivery failures

5xx codes mean permanent failure. Retrying the same message to the same address will produce the same result. Stop, log the failure, and fix the root cause.

  • Code 550: The mailbox does not exist or the server refuses the message.
  • Code 551: The recipient is not local and the server does not relay.
  • Code 552: The mailbox is over quota (also used when the message exceeds the server's size limit, so shrink the message rather than retrying).
  • Code 553: The address is malformed or the sender is not authorized.
  • Code 554: A generic rejection, often used for spam policy violations.

Each 5xx code requires a different fix. A 550 5.1.1 means remove the address from your list. A 550 5.7.1 means check your sending reputation or SPF/DomainKeys Identified Mail (DKIM) configuration. A 554 can indicate a blacklisted sender Internet Protocol (IP) address, failed authentication, spam-flagged content, or a policy violation.

Mapping SMTP replies to delivery actions

This section maps the most common reply codes to their specific meanings and the correct next step. Enhanced status codes, such as 5.1.1 and 5.7.1, are included where they change the action.

Code

Meaning

Common Cause

Action

220

Service ready

Server sends greeting on connect

Proceed with EHLO

250

Command successful

Generic success response

Proceed to next command

354

Start mail input

Server ready for message body after DATA

Send headers, body, then .\r\n

421

Service unavailable

Rate limiting, server overload, maintenance

Reduce sending rate, retry with exponential backoff starting at 5 minutes

450

Mailbox temporarily unavailable

Greylisting, temporary server issue

Retry after 15 to 30 minutes

451

Local error in processing

Server-side internal error

Retry with backoff. If it persists 24+ hours, contact recipient via alternate channel

452

Insufficient storage or too many recipients

Disk full on receiving server, recipient batch too large

If many recipients, split into smaller batches. If storage, retry later

550

Mailbox unavailable or policy rejection

Non-existent mailbox (5.1.1), spam/policy block (5.7.1)

5.1.1: remove address from list. 5.7.1: check SPF, DKIM, Domain-based Message Authentication, Reporting, and Conformance (DMARC), sender reputation

551

User not local

Recipient not hosted on this server, no relay configured

Verify Mail Exchange (MX) records point to correct server, and do not retry until Domain Name System (DNS) is fixed

552

Mailbox full

Recipient mailbox over quota (also used when the message exceeds the server's size limit)

Notify recipient via alternate channel, then retry after they free space. If the message exceeds the size limit, shrink the message rather than retrying

553

Address rejected

Malformed address, unauthorized sender

Check address format for typos, and verify domain has valid MX records

SMTP error codes and recommended retry paths

The difference between a well-behaved email system and a queue-filling incident is how it handles retries.

Resolving transient 4xx SMTP failures

Queue the message and retry with exponential backoff. Postfix uses delays starting at 300 seconds, doubling each time, with a default maximum queue lifetime of 5 days (see the Postfix postconf(5) documentation for queue_run_delay and maximal_queue_lifetime).

Add jitter to prevent synchronized retry storms when multiple messages to the same domain fail simultaneously. A reasonable pattern multiplies the base delay by a random factor between 0.5 and 1.5.

When to abandon SMTP 5xx retries

Abandon immediately: a 5xx code means the failure is permanent, and continuing to retry a 550 5.1.1 wastes queue capacity and damages your sender reputation.

Move the address to your suppression list and log the failure with the full response text. If the 5xx is policy-related (5.7.1), fix the root cause (SPF, DKIM, content) before sending to that domain again.

Backoff patterns for SMTP errors

A practical backoff schedule for 4xx errors:

Retry

Delay

Cumulative

1

5 min

5 min

2

10 min

15 min

3

20 min

35 min

4

40 min

75 min

5

80 min

155 min

6+

160 min

315+ min

Set a maximum retry window of 4 to 5 days. After that, move the message to a dead-letter queue and alert your team.

Recovering messages from dead-letter queues

When a message exhausts its retry window, it lands in the dead-letter queue. For 4xx-expired messages, check whether the receiving server has resolved its issue and requeue if appropriate. For 5xx messages, fix the root cause (address format, authentication, content) before requeuing.

send.io's SMTP relay uses standard SMTP reply codes and includes full diagnostic detail in bounce event webhooks. On send.io's own sending IPs, bounce events include the raw SMTP response, the Delivery Status Notification (DSN) code, and the sending IP, so you can map each failure to the exact server response without parsing your own logs. send.io stores the client-generated Idempotency-Key header value for 24 hours, so a retry with the same key returns the original result instead of sending a duplicate. send.io does not derive an idempotency key from request content, so a request sent without the header has no deduplication protection.

Test send.io's SMTP relay with the documented test addresses to validate your retry logic against documented reply code behavior before deploying to production. Send to delivered@send.io, bounced@send.io, complained@send.io, or suppressed@send.io to simulate each outcome and fire the matching webhook without sending real mail.

FAQs

What is the difference between HELO and EHLO?

HELO returns a single 250 line with no capability list. EHLO returns a multiline 250 reply listing every extension the server supports (SIZE, AUTH, STARTTLS, 8BITMIME). Always use EHLO first, and fall back to HELO only if the server does not recognize EHLO.

How do you test SMTP commands without sending real mail?

Use a tool like Mailtrap or a local SMTP sink (MailHog, Mailpit) that accepts SMTP connections but does not deliver messages. Point your telnet or application test at the sink's hostname and port. To test against send.io's SMTP relay directly, use the documented test addresses to validate your commands and retry logic against documented reply code behavior before deploying to production. Send to delivered@send.io, bounced@send.io, complained@send.io, or suppressed@send.io to simulate each outcome.

Should you retry a 550 response code?

No, 550 is a permanent failure and retrying wastes queue capacity. Check the enhanced status code: 5.1.1 means remove the address, 5.7.1 means fix your authentication first.

What does a 451 response code mean in production logs?

451 means the receiving server hit an internal processing error, so queue the message and retry with exponential backoff starting at 5 minutes. If it persists for 24+ hours, the receiving server has a persistent configuration issue.

How long should you wait between SMTP retries?

Start with 5 minutes and double on each retry, adding jitter between 0.5 and 1.5 to prevent synchronized retries. Set a maximum window of 4 to 5 days, matching the Postfix default queue lifetime.

Key terms glossary

SMTP: Simple Mail Transfer Protocol. The standard protocol for sending email between servers, defined in RFC 5321.

EHLO: Extended HELLO. The SMTP greeting that triggers capability discovery, returning a list of supported extensions.

STARTTLS: An SMTP extension that upgrades a plaintext connection to TLS mid-stream on port 587. Distinct from implicit TLS on port 465.

SASL: Simple Authentication and Security Layer. The framework used by SMTP AUTH to authenticate clients with mechanisms like PLAIN and LOGIN.

Greylisting: An anti-spam technique where the receiving server rejects the first delivery attempt with a 450 and accepts retries after a delay.

Enhanced status code: A three-part code (X.Y.Z) defined in RFC 3463 that adds diagnostic detail to the basic three-digit SMTP reply code.

Dead-letter queue: A holding area for messages that have exhausted their retry window. Messages here require manual intervention or automated reprocessing.

Idempotency key: A client-generated identifier attached to an Application Programming Interface (API) request. The server stores it and returns the original result for duplicate requests, preventing double-sends on retry.