DEV Community

Cover image for What are SMTP codes and how to troubleshoot them
Andy Agarwal for Mailazy

Posted on • Originally published at mailazy.com

What are SMTP codes and how to troubleshoot them

Each time when you send an email to the recipient, they would receive it almost instantaneously and there would be no errors. But when your transactional emails fail to get delivered to your recipient, you need a way to figure out what happened and you might have an SMTP error that needs to be taken care of.

They are three digits SMTP code responses from a mail server that is telling the status of an email. But not all the codes are super easy to decode!

Before we start understanding common SMTP response codes and how you can troubleshoot delivery issues, let's check how SMTP actually works.

What is SMTP?

Simple Mail Transfer Protocol (SMTP) is the standard communication protocol for sending emails over the Internet from one email account to another. There are other email protocols or sets of rules like IMAP and POP along with SMTP that allows different email clients and accounts easily exchange information. SMTP is the only dedicated protocol for sending emails. It is used by popular email providers like Gmail, Yahoo, Outlook, and Apple Mail to send messages from a sender to a recipient.

How does SMTP work?

The best way to understand SMTP working is to check out the sending process, rules, commands, and the errors you may encounter. It is more technical and we have a detailed article on SMTP. You can check this out here.

For now, to understand the SMTP working, you can relate it to the Parcel delivery service or any Postal service which ensures your mail should get delivered to the right location and person. And each time in this process the receiving server will respond with an SMTP code.

What are SMTP codes?

SMTP Response Codes are the three-digit code sent by an SMTP server during the mail delivery process as an update.

  • The first digit of code or Class- The first number indicates whether the server accepts the command. There are five possible values, ranging from 1 to 5.

1 - The server accepted the command but no action has been taken yet. Currently, this is not in use.

2- This falls under general positive response codes. This means the server has completed the task successfully.

3- This means that the server has understood the request, but requires additional/further information to complete the task. This is also a common positive response code.

4- This means the server has encountered a temporary failure and the sender can try again later. This is also taken as the Soft Bounce.

5- This means that the server has encountered a permanent error and trying again will produce the same result. This is also considered as Hard Bounce.

  • The second digit of code or subject: The second digit of the SMTP response code provides additional information and indicates whether there is a syntax, communication, or other problem.

0: Other or Undefined Status
1: Addressing Status
2: Mailbox Status
3: Mail System Status
4: Network and Routing Status
5: Mail Delivery Protocol Status
6: Message Content or Media Status
7: Security or Policy Status

  • Detail: The last digit provides more information about the mail transfer status.

Common SMTP codes and how to troubleshoot them

  • 220 — SMTP Service ready. This is a general response, indicating that the SMTP server is ready to proceed to the next command.
  • 221 — Service closing. The session or connection of the mail server is ending and all processes are completed. The result may be a Pass or Fail.
  • 250 — Requested action taken and completed. This is the best message the sender can receive because it indicates that the SMTP communication was successful. The SMTP 250 response code is also the most common in SMTP because it is issued in response to each received command (each message maybe 4-6 times).
  • 354 — Start message input and end with … Indicates that the server is ready to accept the message itself.
  • 421 — The service is not available, the connection will be closed. If you receive an “SMTP error (421) Failed to connect to the server”, this is considered an open error, which is usually related to the “unreachable” target server. However, this may also mean that your outgoing mail server is “unreachable.” If you use a remote mail server to send mail.
  • 450 — The requested command failed because the user’s mailbox was not available There also can be some additional meanings to the present response code such as:
  1. The e-mail account does not exist on the recipient mail server
  2. The e-mail account doesn’t have permission to receive the email
  3. The recipient mail server rejected the email thanks to blacklisting or filtering
  • 451 — Aborted due to a server error. It is generally not your responsibility as the recipient's mail server rules may interfere with the processing of your email.

  • 452 — The server has insufficient system storage. This usually happens because the mail server is overloaded when sending multiple emails at the same time. To resolve this issue, check your mail queue and use the correct delivery rate.

  • 455 — The server cannot interact with the command at this time. If you receive this message, please allow time to try more. If unsuccessful, please contact the administrator of the recipient’s mail server.

  • 500 — The server could not recognize the command because of a syntax error. Your answer may be due to antivirus software or firewall. To confirm this is the case, try disabling each function to test the connection.

  • 501 — A syntax error occurred in command arguments. This is similar to the SMTP 500 response code. However, 501 responses are usually caused by incorrect or invalid email addresses.

  • 502 — This command is not implemented. If you get this answer, there may be a problem with your original MTA configuration.. Check your MTA settings and try to connect again.

  • 503 — Bad sequence of commands at server side. This response indicates that the parameters used do not match the order expected by the mail server, which usually occurs when the email account is not authenticated. To resolve this error, please verify that your email account is properly authenticated and make sure that all MTA settings are correct.

  • 504 — A command parameter is not implemented. Same like response code 502.

  • 521 — This host never accepts mail, a response by a dummy server. This response simply means that the recipient’s mail server did not accept or deliver the email. To correct SMTP error 521, verify that the message failed and was not retransmitted.

  • 541 — Message not delivered because of policy reasons — If you receive this SMTP response, it means that your email may have been marked as spam. Confirm that your server is not sending spam and is not blacklisted.

SMTP Email Status Code 500

  1. 550 — Request failed because Mailbox did not activate For example, In addition, the SMTP 550 response code is often used to indicate other instances of permanent failure. For example, “The 550 mail server has detected that your mail is spam and has blocked it from being sent.”

  2. 551 — The receiving server is not local to the server. Then the server gives a forwarding address for testing. This is often used as a spam prevention strategy.

  3. 552 — Exceeded storage allocation. This is usually because the recipient’s mail server is too full. This may be because the recipient did not check their email, or in some more extreme cases, the recipient was a victim of mail bombing.

  4. 553 — The mailbox name is invalid. In this case, the mailbox cannot verify the email address. Please check to make sure all email addresses you send to are correct.

  5. 554 — delivery error: Sorry, your message cannot be delivered. This mailbox is disabled. If you receive the SMTP code 554, this is just a normal invalid address response.

The most common thing asked is how to fix an SMTP 450 error. We are sharing some recommendations. Check this out-

Read the exact error you received. It gives a more descriptive reason for ex- SMTP Error 450 5.2.3 Msg Size greater than allowed by Remote Host

If not, here are a few suggestions

  1. Ensure the email account does exit.

  2. If you have an alternative contact method for the user, contact them making them aware of the issue.

  3. Check your mail server’s IP address for blacklisting.

  4. Check your email message for “spammy” content.

  5. If you have an attachment, try sending it without one.

Top comments (2)

Collapse
 
dero profile image
Dero Idoghor

This is a very good breakdown of the various responses.

Collapse
 
dero profile image
Dero Idoghor

Please enlighten me, what do you make off of this 👇

“503 Valid RCPT command must precede DATA”