SMTP(Simple
Mail Transfer Protocol)
• Simple
Mail Transfer Protocol is a protocol for sending e-mail messages between
servers or between a mail client and a server.
• Most
e-mail systems that send mail over the Internet use SMTP to send messages from
one server to another; the messages can then be retrieved with an e-mail client
using either POP or IMAP.
• It works
on port 25.
• SMTP is a
text-based protocol, in which a mail sender communicates with a mail receiver
by issuing command strings and supplying necessary data over a reliable ordered
data stream channel, typically a Transmission Control Protocol (TCP)
connection.
• An SMTP
session consists of commands originated by an SMTP client (the initiating
agent, sender, or transmitter) and corresponding responses from the SMTP server
(the listening agent, or receiver) so that the session is opened, and session
parameters are exchanged. A session may include zero or more SMTP transactions.
• An SMTP
transaction consists of three command/reply sequences. They are:
1. MAIL
command, to establish the return address, a.k.a. Return-Path, 5321.From, mfrom,
or envelope sender. This is the address for bounce messages.
2. RCPT command,
to establish a recipient of this message. This command can be issued multiple
times, one for each recipient. These addresses are also part of the envelope.
3. DATA to
send the message text. This is the content of the message, as opposed to its
envelope. It consists of a message header and a message body separated by an
empty line. DATA is actually a group of commands, and the server replies twice:
once to the DATA command proper, to acknowledge that it is ready to receive the
text, and the second time after the end-of-data sequence, to either accept or
reject the entire message.
SMTP transport example
• A typical
example of sending a message via SMTP to two mailboxes (alice and theboss)
located in the same mail domain (example.com) is reproduced in the following
session exchange.
• The
protocol exchanges are prefixed for the server (S:) and the client (C:). After
the message sender (SMTP client) establishes a reliable communications channel
to the message receiver (SMTP server), the session is opened with a greeting by
the server, usually containing its fully qualified domain name (FQDN), in this
case smtp.example.com.
• The
client initiates its dialog by responding with a HELO command identifying
itself in the command's parameter with its FQDN (or an address literal if none
is available)
S: 220
smtp.example.com ESMTP
Postfix
C: HELO relay.example.org
S: 250
Hello relay.example.org, I am glad to meet you C: MAIL
FROM:<bob@example.org>
S: 250 Ok
C: RCPT
TO:<alice@example.com>
S: 250 Ok
C: RCPT
TO:<theboss@example.com>
S: 250 Ok
C: DATA
S: 354
End data with <CR><LF>.<CR><LF> C:
From:
"Bob Example" <bob@example.org> C:
To:
"Alice Example" <alice@example.com> C:
Cc:
theboss@example.com
C: Date:
Tue, 15 Jan 2008 16:02:43 -0500 C: Subject: Test message
C:
C: Hello
Alice.
C: This
is a test message with 5 header fields and 4 lines in the message body. C: Your
friend,
C: Bob
C: .
S: 250
Ok: queued as 12345
C: QUIT
S: 221
Bye
{The
server closes the connection}
• The
client notifies the receiver of the originating email address of the message in
a MAIL FROM command. In this example, the email message is sent to two
mailboxes on the same SMTP server: one each for each recipient listed in the To
and Cc header fields.
• The
corresponding SMTP command is RCPT TO. Each successful reception and execution
of a command is acknowledged by the server with a result code and response
message (e.g., 250 Ok).
• The
transmission of the body of the mail message is initiated with a DATA command
after which it is transmitted verbatim line by line and is terminated with an
end-of-data sequence. This consists of a new-line (<CR><LF>), a
single full stop (period), followed by another new-line.
Since a
message body can contain a line with just a period as part of the text, the client
sends two periods every time a line starts with a period; correspondingly, the
server replaces every sequence of two periods at the beginning of a line with a
single one. Such escaping method is called dot-stuffing.
• The
server's positive reply to the end-of-data, as exemplified, implies that the
server has taken the responsibility of delivering the message. A message can be
doubled if there is a communication failure at this time, e.g. due to a power
shortage: Until the sender has not received that 250 reply, it must assume the
message was not delivered.
• After the
receiver has decided to accept the message, it must assume the message has been
delivered to it. Thus, during this time span, both agents have active copies of
the message that they will try to deliver.
• The
probability that a communication failure occurs exactly at this step is
directly proportional to the amount of filtering that the server performs on
the message body, most often for anti-spam purposes. The limiting timeout is
specified to be 10 minutes.
• The QUIT
command ends the session. If the second recipient were located elsewhere, the
client would QUIT and connect to the appropriate SMTP server after the first
message had been queued. The information that the client sends in the HELO and
MAIL FROM commands are added (not seen in example code) as additional header
fields to the message by the receiving server. It adds a Received and
Return-Path header field, respectively.
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2026 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.