The Complete List of SMTP Commands and Their Functions

Himadri Sharma
ByHimadri Sharma

7 mins read

Emails are an integral part of our daily communication. It's as easy as typing your thoughts, hitting send, and the other person receiving it. But a lot of background processes happen to make this possible. Essential instructions, known as SMTP commands, are given to email servers to ensure that emails are processed and delivered efficiently. Understanding these commands can provide a deeper insight into the inner workings of email delivery.

This blog will explore what SMTP commands are, why they are necessary, and the types of SMTP commands used in email communication. We'll also provide a comprehensive list of key SMTP commands, complete with descriptions and syntax, to help you navigate this vital aspect of email technology.

What are SMTP commands?

SMTP commands are instructions used by email clients and servers to facilitate email sending, receiving, and routing.

These commands are part of the Simple Mail Transfer Protocol (SMTP), the standard protocol for email transmission across the Internet. The SMTP protocol enables structured and efficient email data transfer between servers by issuing specific SMTP commands. Each command serves a specific function in the communication process, ensuring that emails are delivered accurately and securely.

Why do we need SMTP commands?

SMTP commands are essential tools for managing email communication between servers. They play a key role in various technical scenarios.

  • Setting up SMTP: These commands are crucial for configuring SMTP on your computer or network. They help establish the connection and set parameters for email transmission.

  • Troubleshooting issues: When email problems arise, SMTP commands can help diagnose and fix issues. They allow you to interact directly with the email server to identify where problems may be occurring.

  • Contacting your SMTP server: Sometimes, you must communicate directly with your server for maintenance or configuration changes. Knowing the right commands ensures smooth communication.

  • Advanced access: In specialized situations, like accessing emails during a Telnet session or using a Linux shell, SMTP commands enable you to send emails in batches or manage automated emails securely.

  • Running tests: SMTP commands are also used to test the functionality of email systems. This can help ensure that emails are sent and received as expected.

Understanding SMTP commands can make managing email systems easier and more efficient. Even if you don't use them daily, having basic knowledge can be incredibly useful in specific situations.

Types of SMTP Commands

SMTP commands are divided into two main categories: client commands and server response codes. Client commands are initiated by the email client, while Server responses are codes sent by the server to indicate the status of the client commands. Each command has a specific role in the email communication process, helping ensure that emails are sent and received accurately.

Client commands

Command name Command form Description
HELO HELO [domain] Introduces the client to the server and initiates the communication.
EHLO EHLO [domain] An extended version of HELO that supports additional features, like SMTP extensions.
MAIL FROM MAIL FROM:email@example.com Specifies the sender's email address for the outgoing email.
RCPT TO RCPT TO:email@example.com Indicates the recipient’s email address for the outgoing email.
DATA DATA Signals that the next input will be the email's body content.
RSET RSET Resets the current email transaction, clearing all state.
NOOP NOOP A no-operation command used to test the server’s response.
QUIT QUIT Ends the SMTP session and disconnects from the server.
VRFY VRFY email@example.com Verifies if a specific email address exists on the server.
EXPN EXPN Expands a mailing list to show all the included addresses.
HELP HELP [command] Provides help or information about an SMTP command.
STARTTLS STARTTLS Requests a switch to a secure TLS connection.
AUTH AUTH [mechanism] Initiates authentication to verify the client's identity.
MAIL FROM: BODY=8BITMIME MAIL FROM:email@example.com BODY=8BITMIME Indicates that the email body may contain 8-bit data.
SIZE SIZE [number] Specifies the email size in bytes, helping the server manage large emails.
X-EXPS X-EXPS [parameters] Uses extended parameters for server-specific features beyond standard SMTP.
X-DELIVERY-TIME X-DELIVERY-TIME [time] Sets or queries the expected delivery time for the email.
TURN TURN Allows the client and server to switch roles for specific tasks.
ATRN ATRN Requests mail relay for a specific domain, often used for on-demand relay.
SOML (send or mail) SOML FROM: Sends the email if the recipient is logged in; if not, stores it in the recipient's mailbox for later access.
SEND SEND FROM: Sends the email if the recipient is connected; otherwise, no attempt is made to store it.
SAML (send and mail) SAML FROM: Sends the email if the recipient is logged in and stores it in the recipient's mailbox regardless of their connection status.

Server responses

Server responses are codes sent by the server to indicate the status of the client commands. While not commands, these responses are crucial for understanding the outcome of each command.

Response code Form Description
250 OK The command was successful.
421 Service not available The server is temporarily unavailable.
450 Requested action not taken Temporary issue; action has not been taken.
451 Requested action aborted Command aborted due to error.
500 Syntax error The command was unrecognized due to a syntax error.
550 Requested action not taken Mailbox unavailable.
551 User not local Forwarding to another address is suggested.
552 Requested mail action aborted Mailbox full.
553 Requested action not taken Syntax error in mailbox name.
554 Transaction failed Permanent error; transaction failed.

Exchange of SMTP commands and server codes

When an email is sent, a series of exchanges occur between the sending and receiving servers using the SMTP. These exchanges involve commands and responses that ensure the email is properly delivered. Below is an example of how this communication takes place:

From Command Meaning
Sending server HELO client.gmail.com Identifies itself with the domain name or IP address to start the conversation
Receiving server 250 OK
Sending server MAIL FROM mark@gmail.com Specifies the sender of the email
Receiving server 250 OK
Sending server RCPT TO clair@yahoo.com Specifies the recipient of the email
Receiving server 250 OK
Sending server DATA Request to start the transfer of email contents, date, subject line, etc.
Receiving server 354 Allows the sender to start the transfer of information
Sending server Date: Sunday, 30 July 2023 Date of the email
Sending server Subject: Welcome to the party! Subject of the email
Sending server Empty line
Sending server We welcome you to the party. We hope to have a lot of fun together Content of the email
Sending server . Terminates the transfer of email contents
Receiving server 250 OK
Sending server QUIT Request to terminate the session
Receiving server 221 Closing session

Conclusion

The seamless flow of emails we often take for granted relies on SMTP protocols and commands. Whether you're an IT professional, a developer, or just curious, knowing these commands helps you understand the email process better. By learning client commands and server responses, you can effectively manage email systems and troubleshoot issues, ensuring smooth email communication.

FAQs

If you receive an error after issuing the MAIL FROM command, check the format and syntax of the email address you're providing. Ensure the email address is correctly formatted and the domain is valid. If the issue persists, verify that your server settings are correctly configured and that no restrictions prevent using that email address.

If the RCPT TO command is not accepting the recipient's email address, it could be due to several reasons: the email address might be incorrectly formatted, the domain could be blacklisted, or the recipient's mailbox might not exist. Double-check the email address for typos and ensure the domain is valid and reachable. If necessary, contact the recipient's email server administrator for further assistance.

A "421 Service not available" error indicates that the email server can temporarily not process your request. This could be due to server overload, maintenance, or other temporary issues. In such cases, you should wait and try again later. If the problem persists, contact the server administrator to understand the underlying cause.

If the DATA command is not being accepted, ensure it is issued after the correct sequence of commands (e.g., after HELO/EHLO, MAIL FROM, and RCPT TO). Also, check for any network or server configuration problems that might interrupt the command sequence. Reviewing server logs may provide more detailed information on why the command is being rejected.

A "535 Authentication failed" error typically occurs when the credentials provided for authentication are incorrect. Double-check the username and password for typos and ensure that they match the account you're trying to access. If the credentials are correct, verify that the server's authentication method is properly configured and compatible with your client. If the issue continues, consult your email provider's support for assistance.

Hack growth with weekly round up of guides

100k+ marketers like you read these guides every month

What should you do next?

You made it till the end! Here's what you can do next to grow your business:

2_1_27027d2b7d
Get smarter with email resources

Free guides, ebooks, and other resources to master email marketing.

1_2_69505430ad
Do interactive email marketing with Mailmodo

Send forms, carts, calendars, games and more within your emails to boost ROI.

3_1_3e1f82b05a
Consult an email expert

30-min free email consultation with an expert to fix your email marketing.

Get 3X conversions with interactive emails

Group_1110166328_c98d897e88

Get 3X conversions
with interactive emails

Check.svg

Create & send interactive emails without coding

Check.svg

Put revenue on auto-pilot with pre-built journeys

Check.svg

Save time with AI-powered email content creation

1000+ businesses grew with Mailmodo, including

Frame_1110165681_3_b26b1a7573
Group_1110165532_1_bf39ce18b3
Ellipse_Gradientbottom_Bg
Ellipse_Gradientbottom_Top
gradient_Right