Foundations of Python Network Programming

(WallPaper) #1
241

Chapter 13

SMTP


As outlined at the beginning of Chapter 12, the actual movement of e-mail between systems is accomplished through
SMTP, the Simple Mail Transport Protocol. It was first defined in 1982 in RFC 821; the most recent RFC defining of
SMTP is RFC 5321. The protocol typically serves two roles:



  1. When a user types an e-mail message on a laptop or desktop machine, the e-mail client
    uses SMTP to submit the e-mail to a server that can send it along to its destination.

  2. E-mail servers themselves use SMTP to deliver messages, sending each message across the
    Internet from one server to another until it reaches the server in charge of the recipient’s
    e-mail address’s domain (the part of the e-mail address after the @ sign).


There are several differences between how SMTP is used for submission and delivery. Before discussing them,
however, I will quickly outline the difference between users who check e-mail with a local e-mail client and those who
use a webmail service instead.


E-mail Clients vs. Webmail Services


The role of SMTP in message submission, where the user clicks Send and expects a message to go winging its way
across the Internet, will probably be least confusing if I trace the history of how users have historically worked with
Internet e-mail.
The key concept to understand is that users have never been asked to sit around and wait for an e-mail message
actually to be delivered. This process can often take quite a bit of time—and up to several dozen repeated attempts—
before an e-mail message is actually delivered to its destination. Any number of things could cause delays: a message
could have to wait because other messages are already being transmitted across a link of limited bandwidth, the
destination server might be down for a few hours, or its network might not be currently accessible because of a glitch.
If the e-mail is destined for a large organization, such as a university, it might have to make several different “hops” as
it arrives at the big university server, then is directed to a smaller e-mail machine for one particular college within the
larger university, and finally is delivered to a departmental e-mail server.
Thus understanding what happens when the user clicks Send is, essentially, comprehending how the finished
e-mail message gets submitted to the first of possibly several e-mail queues in which it can languish until the
circumstances are just right for its delivery to occur. (This will be discussed in the next section on e-mail delivery.)


In the Beginning Was the Command Line

The first generation of e-mail users were given usernames and passwords by their business or university, which
provided them with command-line access to the large mainframes where user files and general-purpose programs
were kept. Each large machine typically ran an e-mail daemon that maintained an outgoing queue; right on the same
box where the users were busily typing messages using small command-line e-mail programs. Several such
programs each had their heyday; mail was followed by the fancier mailx, which was then eclipsed by the far prettier
interfaces—with greater capabilities—of elm, pine, and finally mutt.

Free download pdf