SMTP


Contents

  1. Introduction
  2. Mail Transfer
  3. An Example Session

Introduction

The purpose of the Simple Mail Transfer Protocol (SMTP) is to manage the transfer of electronic mail (e-mail) from one computer mail system to another. It does not accept mail from local users, nor does it distribute mail to the intended recipients. This task is handled by the local mail system.

How SMTP fits in.

Since SMTP only interacts with the local mail system it does not see mail which is local to the system. Only when mail is to be sent to or received from another machine will SMTP come into play.

There is usually an I/O queue at the interface between the Local Mail System and the Client/Server ports. The Client is concerned with the sending of mail to another system, whilst the server is concerned with receiving mail.

The local system maintains a mailbox for each user on the system. The name of this mailbox is unique and consists of two parts:

The Local Port
This is simply the name of the user and must be unique to the local host.
The Global Port
This part is the name of the host and must be unique to the InterNet.


Mail Transfer

In the actual transferring of mail from one system to another there are two main issues :

  1. Format of Mail
  2. SMTP used to Transfer Mail

Format of Mail

The format of the mail message itself consists of two parts: the header and the body.

The Header

The header of the mail consists of a series of lines of text each line of which is a keyword followed by text. These two form the minimum header necessary and as such must appear in every mail message. These headings are all optional and some or all of them may appear in the header according to the user's requirements. This final keyword lists the InterNet gateways which were involved in the sending of the message.

The Body

The body of the message can consist of any amount of ASCII text only. It is separated from the header by a blank line and is terminated by a line containing a full stop and a carriage return only.


SMTP used to Transfer Mail

After the mail has been created the local mail system determines, based on the recipient name, whether or not to place the message in the SMTP output queue. If the mail is kept local it is delivered by the local mail system without SMTP getting involved.

To send the mail to another machine the client SMTP first gets the destination IP address from the directory service (known as the Domain Name Server). Using this and the SMTP server well known port, address 25, a transport connection is established between the server SMTP and the destination host. Once the connection has been established the client starts the transfer of the waiting mail to the server.

The mail transfer involves the the exchange of SMTP PDUs, known as commands. Each command is an ASCII character string and it can consist of a three digit number, text or both. Commands are transferred over the established transport connection using the standard TCP Send/Deliver user primitives.

An example session:

The session starts with the client establishing a TCP connection with the server well known port, 25. Once this is done, the server responds with a PDU 220 (ready for mail). The client and server then exchange names with a HELO Client name from the client and a corresponding Server name response.

The mail message starts with a MAIL FROM: message from the client. After a 250 (Ok) response from the server the client then sends a RCPT TO: indicating the name of the intended recipient of the email. The server then has two options: It can either send 250 indicating that the recipient exists on its system or it can send 550 (recipient not here) which will result in the message not being sent by the client.

Once the Ok message has been received by the client it sends DATA which is actually the header of the mail message. Following this the server sends a 345 (Ready for mail) indicating that it is now ready for the body of the mai. The client then sends the body which is terminated by a line containing a single full stop. The end of the mail is acknowledged by the server with another 250 message.

Finally the connection is broken gracefully. The client sends a QUIT which is answered by the server using a 221(Destination closing) message. The connection is then terminated using the normal TCP termination method.

This is the basic functionality which is provided by SMTP. However other additional features may be provided.
For example:



pmccrthy@alf2.tcd.ie