Linux Commands

SMTP Commands: Essential SMTP Commands and Response Codes

The ASCII Simple Mail Transfer Protocol (SMTP) comes with an array of commands and response codes. It functions on a client-server interface and uses TCP port 25. Since SMTP sessions are conversations between SMTP clients and SMTP servers, SMTP commands are often sent from the client machine to the server device.

Every command should consist of the keyword for the command and zero or more arguments. So, while some keywords contain one or more arguments, the keywords for several commands will not have any accompanying arguments.

The commands can either be supported by SMTP, CSSMTP, or both. Notably, a client sends commands in alphabetical characters while the server responds using numerical codes.

Usually, commands will take the following format:

This article lists all the essential SMTP commands. It also defines them, provides a short explanation, and gives an illustration for each command listed.

Essential SMTP Commands and How They Are Applicable in SMTP Sessions

Usually, SMTP commands define specific functions during an SMTP session. STMP sessions consist of three steps, including a handshake, email transfer, and termination stages.

The handshake step is the first of the three and involves initiating a TCP connection. The second step is the email transfer stage, which involves manipulating the email. Finally, the termination step closes a TCP connection.

The following are the basic SMTP commands that you should know:


The EHLO utility is handy in initiating the SMTP session for client-server conversations. It involves the client greeting the server and identifying itself by specifying its IP address or domain name. EHLO is a HELO alternative for servers supporting SMTP service extensions or ESMTP. Either way, HELO and EHLO command the SMTP client to initiate a conversation session by commencing a mail transfer.

An example is provided below:


You can use the MAIL FROM command to initiate a mail transfer. It is an argument that includes a sender mailbox or reverse path. Mails with non-delivery notifications may go without reverse paths. The command has a mail source address and starts an email transfer. An example of a MAIL FROM command is illustrated below:

RCPT TO Command

This utility identifies the mail recipient. You can repeat the command if you have more than one recipient. However, ensure that each command has a specified recipient email address. The destination mailbox is also known as the forward path. Below is an RCPT TO example:

SIZE Command

The SMTP size command has two primary functions. First, it specifies to the client the maximum message size the client can send. The client can use this information to inform the mail server of the size of the message it intends to send. With this, the server will be aware of the expected message size. The client will send a SIZE utility argument containing an EMAIL FROM and SIZE information as shown below:

DATA Command

This command seeks permission from the server to transfer mail data. Thus, it commences the actual transfer of mail data contents, including the body text and attachments. It uses the 354 response code to grant permission. Once the client obtains permission, the client will launch the delivery of the message, and the email contents will be transferred to the server line by line. Type a single dot/period in a separate line after the message is successfully sent. The server will respond with the 250 response code if the message goes through successfully.

RSET Command

This utility resets the connection to its initial session. When used, it will erase all the sender and recipient buffers and tables to provide a positive server response from response code 250. It leaves the SMTP service open and ready for a new session conversation. It does not come with any argument.

NOOP Command

If you are unsure if your SMTP service is connected and functioning properly, you should use the NOOP utility to check. It does nothing to your system but will prompt the receiver to send an OK response via response code 250. It does not have an argument and will just appear as it is.

VRFY Command

If you are unsure about the validity of a given mailbox or username, the VRFY command is here for you. It helps to verify the validity of users or mailboxes. This command will return the full name of a user and its respective email address by querying the service using the user name. You can also use this utility to probe login names on servers.

QUIT Command

You can terminate a session using the QUIT command. Once used, the server will respond with response code 221, prompting the client to close the current connection. The receiver will equally close the channel after responding with a 221 response code.


This article discussed the importance of the basic SMTP commands and their respective functions. Hopefully, they will help your work with the SMTP service become more accessible and convenient.

About the author

Kennedy Brian

Brian is a computer scientist with a bias for software development, programming, and technical content development. He has been in the profession since 2015. He reads novels, jogs, or plays table tennis whenever not on gadgets. He is an expert in Python, SQL, Java, and data and network security.