503
SMTPERRORCommonClient ErrorHIGH confidence

Bad sequence of commands

What this means

The 503 code indicates the client sent a valid command in the wrong order. SMTP sessions follow a strict sequence, and this error occurs when that sequence is violated.

Why it happens
  1. 1Sending `MAIL FROM` before a successful `EHLO` or `HELO` command.
  2. 2Sending `RCPT TO` before a successful `MAIL FROM` command.
  3. 3Sending `DATA` before a successful `RCPT TO` command.
How to reproduce

A client attempts to specify a recipient before specifying the sender.

trigger — this will error
trigger — this will error
EHLO client.example.com
250-mail.example.com
RCPT TO:<recipient@example.com>
503 5.5.1 Error: need MAIL command

expected output

503 Bad sequence of commands

Fix

Correct client logic

WHEN When developing the SMTP client

Correct client logic
// Follow the correct SMTP command order
smtp.send("EHLO client.example.com");
smtp.send("MAIL FROM:<sender@example.com>");
smtp.send("RCPT TO:<recipient@example.com>");
smtp.send("DATA");

Why this works

Ensures the client adheres to the required SMTP state machine, preventing this error.

What not to do

✕ Reset the connection and retry the same sequence

The logical flow is wrong. The client software must be fixed to follow the correct EHLO -> MAIL FROM -> RCPT TO -> DATA sequence.

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All SMTP errors