A 503 reply means the SMTP commands arrived in an order the server will not accept. RFC 5321 defines the text as "Bad sequence of commands". SMTP is a strict conversation: greeting, EHLO, optional STARTTLS and AUTH, then MAIL FROM, one or more RCPT TO, DATA, and finally QUIT. A client that skips or repeats a step gets 503.
503 5.5.1 Error: send HELO/EHLO first
503 5.5.1 Error: need RCPT command
503 5.5.1 Error: need MAIL command
503 5.5.1 Error: authentication not enabled
503 5.5.1 Bad sequence of commands
503 5.5.1 Error: nested MAIL command
Gmail documents several 503 variants, such as "EHLO/HELO first", "RCPT first", "No DATA after BDAT" and 5.7.0 No identity changes permitted. Check its current SMTP reference for exact wording.
Causes, most likely first
- No
EHLO/HELObeforeMAIL FROM, or a secondEHLOthat the server rejects after TLS or AUTH. DATAbefore any validRCPT TO. If every recipient was refused, a client that blindly continues toDATAgets "need RCPT command".AUTHsent at the wrong time: afterMAIL FROMhas started, or twice, or on a server where authentication is not offered.- Pipelining mistakes, where a client sends commands in a batch and does not handle an early failure.
- A proxy, firewall or "SMTP fixup" feature that rewrites or reorders traffic.
- A script talking raw SMTP with a hand-built conversation.
Step 1: find the first error, not the 503
The 503 is often a symptom. The earlier line that failed explains it. Capture the conversation (your library's debug mode, or openssl s_client -starttls smtp -crlf) and read from the top:
C: EHLO app01
S: 250-mail.example.com
S: 250 STARTTLS
C: MAIL FROM:<noreply@example.com>
S: 530 5.7.0 Must issue a STARTTLS command first
C: RCPT TO:<user@example.net>
S: 503 5.5.1 Error: need MAIL command
Here the real error is the 530; see SMTP 530 must issue a STARTTLS command first. The 503 followed because MAIL FROM never succeeded.
Step 2: check the required order
The minimal valid transaction:
EHLO client.example.com
MAIL FROM:<sender@example.com>
RCPT TO:<recipient@example.net>
DATA
(message headers and body)
.
QUIT
If TLS is used: EHLO, STARTTLS, the TLS handshake, then EHLO again. After STARTTLS the server discards what it learned, so your client must send a new EHLO. A client that skips the second EHLO gets "send HELO/EHLO first". For authenticated submission the order is: EHLO, STARTTLS, EHLO, AUTH, MAIL FROM. Confirm the port and encryption mode; submission on 587 uses STARTTLS and port 465 uses implicit TLS from the first byte. The पोर्ट चेकर tells you which ports respond, and the TLS वर्शन चेकर shows supported TLS versions.
Step 3: fix common client bugs
- Using the wrong security mode. Library options like
ssl=Trueon port 587 orstarttlson 465 break the sequence. Match mode to port. - Connection reuse after failure. If a transaction fails, send
RSETbefore starting a newMAIL FROM, or open a new connection. Starting a new MAIL while one is open produces "nested MAIL command". - Sending to a list where all recipients fail. Check each
RCPTresponse and abort if none were accepted. - Sending
AUTHmore than once per session. Authenticate once.
In Python's smtplib, the pattern is:
with smtplib.SMTP("smtp.example.com", 587) as s:
s.ehlo()
s.starttls()
s.ehlo() # required again after STARTTLS
s.login(user, pw)
s.sendmail(sender, recipients, msg)
Step 4: rule out middleboxes
Some firewalls have an SMTP inspection feature (Cisco's ASA "fixup"/inspect, for example) that mangles commands and breaks ESMTP extensions. If the same client works from another network, disable SMTP inspection for that path or switch to an alternative submission port. Compare using another network, and verify the provider's MX with the MX लुकअप.
How to verify
A clean manual session ends with 250 2.0.0 OK after the final period. Send a real message and verify status=sent in the logs. Finish with the ईमेल डिलीवरेबिलिटी टेस्ट to check that the same path also passes authentication.
अगले कदम
- Read SMTP 501 syntax error in parameters for malformed arguments.
- See SMTP 535 authentication failed for credential errors.
- Learn the code families in email bounce codes explained.
- जाँचें WordPress email not sending if the sender is a plugin.
सामान्य प्रश्न
Is 503 temporary or permanent?
It is a permanent error for that session. Retrying the same bad sequence fails again; fix the client order.
Why do I get 503 only after STARTTLS?
The client probably did not repeat EHLO after the TLS handshake. The server resets its state at that point.
Can a firewall cause it?
Yes. SMTP inspection features can alter or drop commands. Test from a different network to confirm.
Is a bad sequence the same as a syntax error?
No. Syntax errors (501) mean a malformed command; 503 means a valid command at the wrong time.
Get notified when this fix updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.