JavaScript Editor Source code editor     Website development 

Main Page

Previous Section Next Section

Simple Mail Transfer Protocol (SMTP)

SMTP is the protocol that email servers use to forward messages across a TCP/IP network. The client computer that initiates an email message also uses SMTP to send that message to a local server for delivery.

A user never has to speak SMTP. The SMTP communication process goes on behind the scenes. However, it is occasionally important to know a little about SMTP to interpret error messages for undelivered mail. Also, programs and scripts sometimes access SMTP directly to send email warnings and alerts to network personnel.

Like other TCP/IP application services, SMTP communicates with the network through the TCP/IP protocol stack. The duties of the email application are kept simple because the application can count on the connection and verification services of the TCP/IP protocol software. SMTP communication occurs through a TCP connection to port 25 on the SMTP server. The dialog between the client and server consists of standard 4-character commands (and data) from the client interspersed with 3-digit response codes from the server. Table 18.2 shows some SMTP client commands. The corresponding server response codes are shown in Table 18.3.

Table 18.2. SMTP Client Commands




Hello. (Client requests a connection with the server.)


Precedes email address of sending user.


Precedes email address of receiving user.


Announces an intention to start transmitting the contents of the message.


Asks the server to send an OK reply.


Asks the server to send an OK reply and terminate the session.


Aborts the mail transaction.

Table 18.3. Some SMTP Server Response Codes




<domain> service ready.


<domain> service closing transmission channel.


Requested action completed successfully.


User is not local. Message will be forwarded to <path>.


Start sending data. End data with the string <CRLF>.<CRLF> (which signifies a period on a line by itself).


Action was not taken because mailbox is busy.


Syntax error: command not recognized.


Syntax error: problem with parameters or arguments.


Action was not taken because mailbox was not found.


User is not local. Try sending the message to <path>.


Transaction failed.

The process is roughly as follows. As mentioned earlier in this hour, this process is used to send a message from the initiating client to the local email server and also to forward the message from the local server to the destination server or to another server on the relay path:

  1. The sending computer issues a HELO command to the server. The name of the sender is included as an argument.

  2. The server sends back the 250 response code.

  3. The sender issues the MAIL FROM: command. The email address of the user who sent the message is included as an argument.

  4. The server sends back the 250 response code.

  5. The sender issues the RCPT TO: command. The email address of the message recipient is included as an argument.

  6. If the server can accept mail for the recipient, the server sends back the 250 response code. Otherwise, the server sends back a code indicating the problem (such as the 550 code, which indicates that the user's mailbox wasn't found).

  7. The sender issues the DATA command, indicating that it is ready to start sending the contents of the email message.

  8. The server issues the 354 response code, instructing the sender to start transmitting the message contents.

  9. The sender sends the message data and ends with a period (.) on a line by itself.

  10. The server sends back the 250 response code, indicating that the mail was received.

  11. The sender issues the QUIT command, indicating that the transmission is over and the session should be closed.

  12. The server sends the 221 code, indicating that the transmission channel will be closed.

The network uses this SMTP communication process to pass the email message to the user's mailbox on the destination email server. The message then waits in the user's mailbox until the user logs in and downloads any waiting mail. This final download is a separate process that requires a different protocol. You'll learn more about mail retrieval protocols in the following sections.

    Previous Section Next Section

    JavaScript Editor Source code editor     Website development