Overview
A "session" refers to a single incoming SMTP connection. Each SMTP session progresses through a series of distinct stages, each with its own function:
Connect stage
The connect stage is the initial stage of an SMTP session, where the server and client establish a connection. It determines the hostname and greeting the server advertises, and can run a Sieve script against the incoming connection.
EHLO stage
The EHLO (Extended Hello) command is sent by an email client to the server to initiate an SMTP session and negotiate the features and extensions that will be used during the session. The EHLO command provides a way for the email client to identify itself, and for the server to advertise the capabilities and extensions it supports, such as authentication mechanisms, message size limits, and others. The response to the EHLO command provides information to the client about the server's capabilities, which the client can then use to determine the best way to send the email.
MAIL stage
The MAIL FROM command initiates an SMTP message transfer by identifying the sender of the message. After the command is issued, the receiving mail server validates the sender address and checks whether the sender is authorised to send messages on behalf of that domain. If valid, the transaction proceeds to the RCPT TO stage.
RCPT stage
The RCPT TO command specifies the recipient of an email message during the SMTP message transfer. It is used in conjunction with the MAIL FROM command. After the command is issued, the SMTP server responds with a status code indicating whether the recipient is valid and the server is willing to accept the message. If the recipient is valid, the SMTP client proceeds with the DATA command.
DATA stage
The DATA command initiates the data transfer phase of message delivery. Once the sender has successfully completed the MAIL FROM and RCPT TO commands, the DATA (or BDAT when chunking is used) command begins transmission of the message. After the message has been transmitted, the server responds with a status code indicating whether it was accepted or rejected.
AUTH stage
The AUTH command authenticates a user wishing to send an email message through an SMTP server. Once issued, the client supplies credentials using SASL, a framework for authentication and data security in network protocols. SASL supports mechanisms such as username and password, public-key cryptography, and bearer tokens.