SMTP Commands¶
SMTP Commands are the set of instructions used by Mail User Agents (MUA) or Mail Transfer Agents (MTA) to communicate with an SMTP server to send or relay email^[600-developer__smtp.md].
Transaction Flow¶
The interaction typically follows a structured sequence. It begins with a greeting to identify the client and protocol version, followed by the specification of the sender and recipients^[600-developer__smtp.md]. Once the transaction participants are established, the client signals the intent to send the message content^[600-developer__smtp.md]. Finally, the session is terminated^[600-developer__smtp.md].
Common Commands¶
HELO¶
This is the first command sent to a standard SMTP server to initiate the session^[600-developer__smtp.md]. It is used to "greet" the server and identify the client via the domain name provided in the argument^[600-developer__smtp.md]. The domain name must be resolvable to an IP address that matches the client's current connection IP, a feature often used for anti-spam verification^[600-developer__smtp.md].
EHLO¶
This is the first command sent to an Extended SMTP (ESMTP) server^[600-developer__smtp.md]. Similar to HELO, it is used to greet the server and identify the client's domain, which must be resolvable and match the connection IP^[600-developer__smtp.md]. Additionally, the server will respond with a list of supported ESMTP extensions, such as STARTTLS^[600-developer__smtp.md].
STARTTLS¶
Issued after a client confirms that the server supports TLS (via the EHLO response), this command requests the initiation of a TLS handshake to secure the connection^[600-developer__smtp.md].
MAIL FROM¶
This command specifies the sender address in the SMTP envelope^[600-developer__smtp.md]. It is important to note that this address can differ from the sender address listed in the actual message header^[600-developer__smtp.md].
RCPT TO¶
This command specifies the recipient address in the SMTP envelope^[600-developer__smtp.md]. Like MAIL FROM, this can differ from the address in the message content^[600-developer__smtp.md]. This command can be executed multiple times in a single transaction to specify multiple recipients^[600-developer__smtp.md].
DATA¶
This command signals to the SMTP server that the client is ready to begin transmitting the actual email content^[600-developer__smtp.md].
QUIT¶
This command is used to terminate the session^[600-developer__smtp.md]. Many SMTP servers use the presence or absence of this command as a heuristic to determine whether the sending client is legitimate or potentially sending spam^[600-developer__smtp.md].
Related Concepts¶
- [[SMTP]]
- [[Telnet]]
Sources¶
^[600-developer__smtp.md]