by Dinesh Thakur Category: Services and Applications

SMTP stands for Simple Mail Transfer Protocol. It is a TCP/IP protocol that specifies how computers exchange electronic mail. It works with post office protocol (POP).

SMTP is used to upload mail directly from the client to an intermediate host, but only computers constantly connected such as Internet Service Providers (ISP) to the Internet can use SMTP to receive mail. The ISP servers then offload the mail to the users to whom they provide the Internet service.

SMTP uses TCP port number 25 for his service. Therefore e-mail is delivered from source to destination by having the source machine established a TCP connection to port 25 of the destination machine.

To send a mail, a system must have a client MTA, and to receive a mail, a system must have a server MTA. SMTP transfers this message from client MTA to server MTA. SMTP uses commands and responses to transfer the message between an MTA client and MTA server In order to send a mail, SMTP is used two times: one between the sender and the sender's mail server, and the other between the two mail servers.

Each command or response ends with two characters (CR and LF) CR stands for Carriage Return and LF stands for Line Feed.

Windows NT Option Pack 4 includes an SMTP mail client so do the Windows NT Resource Kit. Microsoft Exchange Server will route your LAN mail on and off the Internet.

Working of SMTP: SMTP is a simple ASCII protocol that is based on client-server model. After establishing the TCP connection, the sending machine, operating as the client, waits for the receiving machine, operating as the server, to talk first. The server starts by sending a line of text giving its identity and telling whether or not it is prepared to receive mail. If it is not, the client releases the connection and tries again later.

If the server is willing to accept e-mail, the client announces whom the e-mail is coming from and destination, the server gives the client the go ahead to send the message. Then the client sends the message and the server acknowledges it.

The problems that may arise with SMTP protocol are as follows:

Some older version of SMTP implementations cannot handle messages exceeding 64KB.

If the client and server have different timeouts, one of them may give up while the other is still busy, unexpectedly terminating the connection.

To get around these problems, extended SMTP (ESMTP) has been defined in RFC 1425.

SMTP Commands

• SMTP commands are sent from the client to the server.

• Each command consists of a keyword or command name followed by zero or more argument. It means some keywords do not contain any argument.

• The format of command is:

Keyword: argument(s)

• There are 14 different SMTP commands listed in the table below:

SMTP Responses

• SMTP responses are sent from server to client.

• Each response begins with a three digit code and may be followed by additional textual information.

• The leading digits indicate the category of the response.

The difference categories of response are:

1. Positive completion reply. It indicates that the requested action has been successfully completed. A new request may be initiated.

2. Positive Intermediate reply. It indicates that the command has been accepted, but the requested action is being held in abeyance, pending receipt of further information.

3. Transient Negative Completion reply. It indicates that the command was not accepted and the requested action did not occur. However, the error condition is temporary and the action may be requested.

4. Permanent Negative Completion reply. It indicates the command was not accepted and the requested action did not occur.


The various SMTP responses are listed in the table below:

Mail Transfer Phases

The basic SMTP operation occurs in three phases:

1. Connection set up

2. Mail transfer

3. Connection termination

Connection Setup

An SMTP sender will attempt to set up a TCP connection with a target host when it has one or more mail message to deliver to that host. The following sequence occurs during connection setup:

1. The sender opens a TCP connection with the receiver.

2. Once the connection is established, the receiver identifies itself with '220 Service Ready".

3. The sender identifies itself with the HELO command.

4. The receiver accepts the sender's identification with "250 'OK".

5. If the mail service on the destination is not available, the destination host returns a "421 Service Not Available" reply in step 2 and the process is terminated.

Mail transfer

• Once the connection has been established, the SMTP sender may send one or more messages to the SMTP receiver.

• There are three logical phases to the transfer of a message :

1. A MAIL command identifies the originator of the message.

2. One or more RCPT commands identify the recipients of this message.

3. A DATA command transfers the message text.

Connection termination

• The SMTP sender closes the connection in the following manner:

1. The sender sends a QUIT command and waits for a reply.

2. Sender initiates TCP close operation for the TCP connection.

3. The receiver initiates its TCP close after sending is reply to the QUIT command.

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles