How does Simple Mail Transfer Protocol SMTP work?

Simple Mail Transfer Protocol (SMTP) works by facilitating the transfer of email messages between servers. When an email is sent, the SMTP client on the sender’s side establishes a connection to the SMTP server, typically using TCP. The client and server then communicate through a series of commands and responses to transfer the email. The process involves the client identifying itself, specifying the sender and recipient addresses, and transmitting the message content. The server then forwards the email to the recipient’s email server or stores it until the recipient retrieves it.

The SMTP protocol operates through a set of defined stages: connection establishment, mail transaction, and connection termination. Initially, the client establishes a TCP connection to the server, usually on port 25. The client sends a HELO or EHLO command to the server, which responds with a greeting. The client then issues a MAIL FROM command to specify the sender’s email address, followed by RCPT TO commands to specify the recipient(s). After the server acknowledges these commands, the client sends a DATA command to start the transmission of the email content. The message is sent, ending with a single period on a new line. The server acknowledges the receipt of the message, and the client sends a QUIT command to close the connection.

SMTP typically uses port 25 for communication between mail servers. For encrypted transmission using SSL/TLS, port 465 is often used. Another common port for SMTP with STARTTLS encryption is port 587, which is recommended for client-to-server email submission to ensure secure transmission.

The Simple Mail Transfer Protocol includes several commands used during the email transmission process. Key commands include HELO or EHLO for identifying the client to the server, MAIL FROM to specify the sender’s address, RCPT TO to specify the recipient’s address, DATA to begin the transfer of the email content, RSET to reset the current mail transaction, VRFY to verify an email address, EXPN to expand a mailing list, and QUIT to terminate the session. Each command is followed by a server response that indicates the success or failure of the operation.