Legal Information
PC Knowledge Base - Simple Mail Transfer Protocol

Good Knowledge Is Good2Use
SMTP comprises and potentially multiple servers in between known as mail transfer agents (MTAs). The transfer of email is complex from the start just due to the number of servers and agents involved in the process.
The process flow for sending an email goes as follows:
  1. The MUA (client) sends the properly formatted email to the MSA or directly to an MTA
  2. The MSA sends the mail to its MTA
  3. Additional MTAs may be routed through until the email is on a "boundary MTA"
  4. The boundary MTA performs a query using DNS to identify the MX for the domain the email is intended for
  5. The MTA connects to the MX and transfers the email
  6. The MX transfers the email to the MDA
  7. At this point, the mail is transferred to the appropriate internal mail server and stored until the MUA or MRA connects to it and retrieves the message on behalf of the user (usually using the POP or IMAP Protocols)

The actual sequence of commands to construct and send a message using the SMTP protocol consists of a "HELO" message to open the communications channel followed by the commands "MAIL," "RCPT," and "DATA" each with the appropriate data to form the email header and message. Extended HELO (EHLO) is the Extended Simple Mail Transfer Protocol (ESMTP) command equivalent of HELO
Finally, the connection is terminated using the "QUIT" command.

The figure belowt shows a breakdown of the sequence of commands in sending an email
 

The SMTP handshake
The sending mail server (the SMTP client) establishes a TCP connection to the receiving mail server (The SMTP server) to which the SMTP server responds with code 220. (This step is not shown in the sequence diagram)
After the SMTP client receives the 220 reply, the handshaking starts.

.The general purpose of the handshaking stage is for the client and the server to identify themselves, the services they can provide, and to identify the identities of the sender and the recipient of the email. It starts with the sending mail server sending an EHLO command to the receiving mail server and identifying its domain. For example, the sending mail server would send "EHLO ".

The SMTP server it the receiving domain (e,g. yahoo.com) acknowledges the EHLO message by responding with code "250" along with the services that the SMTP server can support. It's important for the client and server to agree on the services and features they can support before the message transfer starts.
With the greeting is done, the client to sends the information of the sender and the recipient of the email.

The SMTP client resumes by sending a "MAIL FROM" command along with the sender information. In our scenario, it would be something like "MAIL FROM: ". When the SMTP server receives this command, it responds again with the same code 250 to indicate that it has no problem accepting messages from this user, Bob.
Afterwards, the client sends a "RCPT TO" command along with the email address of the recipient "RCPT TO: ".
Among other things, the SMTP server checks if the user "Alice" exists and if yes, it sends back a 250 acknowledgement indicating that it's OK with accepting messages from Bob to be delivered to Alice.

The handshaking stage is now complete.

The message transfer
Before starting the actual message transfer, the SMTP client sends one more command called "DATA" to the server just to make sure that the server side is ready.
The receiving mail server responds with code "354" indicating that it's ready to receive the message. After receiving this code from the server, the client is now ready to send the email message.

The actual email message is sent out line by line. The server side though does not acknowledge each individual line received. It just waits for the "End of Mail" special line which is a line that only has a "." (period or full stop) by itself.
When the client sends a "." to the server, this indicates that the client is done with sending the email message. This also tells the server that it can start processing the message now.
After the receiving mail server receives the ".", it acknowledges receiving the whole message by sending a 250 code back to the client.

Closing the connection
This is very simple and straightforward. The sending mail server sends a "QUIT" command to the receiving mail server to indicate its intention to close the connection to whicthw receiving mail server responds with a "221" code.

Search Knowledge Base Feedback

If you like our web site refer a friend.
Your friends name.
Your friends email address.
Your Name
Your Email Address


© Copyright 1998-1999 GOOD2USE