In "Untangling Email" (April 1998), I explained how the Simple Mail Transfer Protocol (SMTP) transfers data from one mail server to another. This month, I'll examine how email travels the final distance from your mail server to your desktop. An Internet standard called Post Office Protocol (POP) 3 makes the last leg of email transfer possible.
The Need for POP3
The original SMTP protocol made sense in the computing environment of 1980. Back then, all computers were mainframes and minicomputers. They could multitask, so users could work in other programs while an SMTP server program ran in the background. In addition, every online computer was connected to the Internet 24 hours a day. SMTP's requirement that mail servers always be prepared to accept new mail was not a problem for those early machines.
However, by the mid-1980s, PCs had drastically changed the complexion of computing. PC users did not keep their machines constantly connected to the Internet, and setting up an early PC to run an SMTP server program in the background would have required building the SMTP program as a terminate-and-stay-resident (TSR), which would have made the system unstable. In researching the background of Internet mail, I found Request for Comments (RFC) 918 from 1984, which calls for SMTP support for computers that are not always online and don't have the power to multitask SMTP software. In other words, RFC 918 calls for SMTP support for PCs.
In answer to RFC 918's concerns, POP emerged. RFC 1725, dated November 1994, describes POP3 as a tool that lets each mail server act as a post office, receiving mail for dozens of users. Users can log on to their POP3 server whenever they want and receive any mail that the server is holding for them.
The Big Picture
Internet mail's two protocols--SMTP and POP3--must work together to make email possible. To delineate each protocol's role in the message transfer process, let's follow an email from its sender's desktop to its recipient's desktop.
Suppose you work for Xenon Industries, a company with the domain name xenon.com, and you want to send a message to your friend Linda, who works for Acme Industries and has the email address firstname.lastname@example.org. You'll compose the message using an Internet mail client, such as Microsoft Exchange, Microsoft Outlook Express, Qualcomm Eudora Light, or Pegasus Mail. After you finish typing your message's text, you'll tell your mail client to send the message.
Internet mail clients use SMTP to send messages and POP3 to receive messages. Your mail client doesn't know how to find Linda's mailbox at acme.com. But your mail client knows how to hand the message over to a local SMTP server. That's why, when you set up your mail client, the installation software prompted you for your SMTP server's address.
If the address of Xenon's local mail server is mailcomp.xenon.com, then when you send your message to Linda, your mail client establishes a socket connection with port 25 (the standard SMTP port) on mailcomp.xenon.com. The mail client uses the SMTP commands I discussed last month (including mail from: and rcpt to:) to transfer your message to the local SMTP server.
Mailcomp.xenon.com then contacts the Domain Name System (DNS) at acme.com and asks for the mail exchanger (MX) address for the domain's SMTP server (for instance, smtphost.acme.com). The SMTP software on mailcomp.xenon.com attempts to establish a connection with smtphost.acme.com. Without waiting for smtphost.acme.com to reply, mailcomp.xenon.com sends your message.
To receive your message, smtphost.acme.com must meet two criteria. First, the server must be online. Because SMTP servers don't verify that recipient machines are online before sending a message, mail servers must stay continuously connected to the Internet to ensure that users receive all their email.
Second, smtphost.acme.com must be running POP3 server software. Most SMTP server software also functions as POP3 server software, but some SMTP software, such as Internet Information Server (IIS) 4.0, doesn't.
When smtphost.acme.com receives your message, the server's SMTP delivery agent software directs the message to Linda's POP3 mailbox. Linda's mail client then uses POP3 to access the message. When Linda logs on to her Internet mail client program, the mail client connects to port 110 (the standard POP3 port) on smtphost.acme.com. The mail client identifies Linda with a username and password and requests her messages. If your message is in Linda's mailbox, her mail client displays it. Linda can then read and reply to your message.
If Linda replies to your message, she sets the same process in motion in reverse. Her SMTP client sends a message to her local SMTP server, her SMTP server locates your POP3 server and transfers the message, your POP3 server's delivery agent transfers the message to your mailbox, and you view the message through your POP3 client. These four simple steps underlie every email transfer you make.
Like SMTP, POP3 lets computers communicate through commands that resemble English words. POP3 servers respond to mail client queries with command lines that begin with +OK or ERR; specific data, such as the number of messages in a mailbox; or the text of a message. To demonstrate POP3 language, I'll open a Telnet session with my POP3 server, check my messages, and retrieve a message from my inbox.
To connect to the server smtp.xenon.com, I request a connection to port 110 using the telnet command. I open a command line and type
When my computer establishes a connection to the mail server, I must enter the user command to provide the server with my username and the pass command to provide my password. Suppose I have a POP3 account called mark on smtp.xenon.com with the password swordfish. After I have entered the telnet command, my logon exchange with the mail server might look like
+OK Mark is welcome here
+OK mark's mailbox has 3 message(s) (10248 octets)
Notice that the server embellishes each +OK message with additional information. Server remarks vary according to the POP3 software the server is running, but they usually provide helpful information. My server's first response tells me which POP3 software it is running. The second response tells me nothing--most POP3 servers respond to a username with <username> is welcome here, regardless of whether the user has an account on the server. My server's third response summarizes the contents of my mailbox.
If my server didn't automatically provide me with information about my inbox, I could find that information using the stat command, which requests my mailbox's statistics from the server. The exchange would look like
+OK 3 10248
The 3 in the server's response tells me the number of messages in my mailbox; the 10248 represents those messages' total number of bytes.
To find out the size of each message, I use the list command. The server lists my inbox's files and each file's size in bytes, as follows:
To see the beginning of a message, I use the top command with the message number, followed by the number of lines I want to see. Because I want to see only the message's header, I request 0 lines of text.
From: "NT Magazine Editor" <email@example.com>
To: "Mark Minasi" <firstname.lastname@example.org>
Date: Tue, 27 Jan 1998 11:33:44 -0500
To see the entire message, I use the retr command, followed by the message number. The server provides me with the same header information, plus the message text. When I've read the message, I use the dele command to delete it.
+OK message 1 deleted
Finally, to disconnect from smtp.xenon.com, I use the quit command.
POP3 at Work
Now you know how POP3 works and what part it plays in email delivery. Your Internet mail client uses these simple commands to communicate with your POP3 server every time you check your email.
Knowing the commands your POP3 client uses to communicate with your POP3 server can come in handy. I recently attended a conference that provided participants with Internet access via computers running Windows 98. I tried to use Win98's mail client, Outlook Express, to access my mailbox on my Internet server at home, but the first file in my mailbox was so large that Outlook Express couldn't load it. I couldn't skip over the file in Outlook Express, so I couldn't scan the rest of my inbox. Fortunately, Win98 comes with a Telnet client. Because I know POP3 commands, I was able to telnet in to my POP3 server and bypass the first message to read my shorter emails.