SMTP is an asymmetric response protocol which means it sends a command and then waits for a response before transmitting another command. The commands that SMTP use are words but the responses are numeric values/codes. I have included some common SMTP commands.
HELO – The hello command is used to start an SMTP session. When a host needs to make a connection (SMTP session) with another server, it sends the HELO command to the other server. The server wanting to make the connection cannot send anything until it has received a response from the initial command. To ensure the host that is receiving the request knows where to send its response, the sending server uses it’s FQDN as an argument to the HELO command.
MAIL FROM: – This command is primarily used to send email addresses. The HELO command provides the receiving host with the FQDN of the server sending the message but the receiving server doesnt know which email address within that organsiation (domain) actually sent the message. Of course, there is no guarantee that the sending server belongs to the same domain as the server that transmitted the orginal HELO command because that server could have been relaying. So, its very important for the sending server to send the receiving server the originating email address so that the recipient can reply to the message if neccessary.
RCPT TO: – This command tells the receiving server the email address of the message sender. Its very common for mail messages to be sent to multiple users often in different domains. If the users are in a common domain SMTP sends the RCPT TO: command manytimes for each user. If the users are in different domains then the sending SMTP server performs a DNS lookup against all of the users to obtain the MX record that is associated with the users domain. And dont forget, this happens everytime a SMTP message is sent regardless of the number of recipients. This query returns the IP address of the recipients mail server, if the message is going to many servers which is often the case when recipients are in different domains then SMTP has to establish a session with each domain.
DATA – There is one thing all the above commands have in common, they are all used in conjuction with a parameter such as the email address. Well, the data command works differently. When the sending server transmits the data command it tells the receiving server that a stream of data will follow which of course is the message body. And the things is, because an email message can be long the receiving server needs to know when the message is complete. To do so, SMTP appends a CRLF and a period to the end of the message body. This period on a line by itself allows the receiving host to work out when the complete message has been received.
QUIT – This command is used to end the SMTP session.
RSET – This command performs an SMTP reset and aborts the current message being sent.