Click to Rate and Give Feedback
Tips
With Windows 7, it's easy to head off potential problems by preventing users from running unauthorized programs and scripts. Find out how. ...

Read more!

Find out how you can use the SchTasks.exe command-line utility to create, delete, query, change, run, and end scheduled tasks. ...

Read more!

The Recovery Console has been deprecated in Windows Vista, so what happened to all those commands? Here's how you can access some of those familiar tools. ...

Read more!

Exchange Server 2007 enables Outlook Web Access for each user by default. In five steps, however, you can easily disable Outlook Web Access for specific users ...

Read more!

SQL Server PowerShell includes new cmdlets designed specially for working with SQL Server 2008. Here's a look at what's new, and what you can do. ...

Read more!

Related Articles

Unlike the typical service pack, Exchange Server 2007 Service Pack 1 provides a lot more than just hotfixes and security updates. Here's an overview of some of the most important new features and capabilities SP1 has to offer.

Tony Smith

TechNet Magazine December 2007

...

Read more!

Learn how you can use message journaling to monitor e-mail in your company, find out if Office 2003 users can use Unified Messaging, examine storage options for your Exchange 2007 implementation, get answers about connecting to Exchange 2007 with older versions of Outlook, and more.

KC Lemson and Nino Billic

TechNet Magazine September 2007

...

Read more!

Have questions about Exchange? In this installment, we answer questions about using Exchange with SharePoint, working with standby continuous replication, installing Exchange 2007 Mailbox servers on Windows Server 2008, and more.

Henrik Walther

TechNet Magazine July 2008

...

Read more!

How does Microsoft ensure delivery of legitimate messages to employees while keeping the flood of malicious content away from the messaging envrionment? One way is by deploying Exchange Server 2007 Edge Transport servers and Forefront Security for Exchange Server. Find out how these technologies can keep your organization safe.

Kay Unkroth

TechNet Magazine October 2007

...

Read more!

One of the most exciting features offered by Service Pack 1 is Standby Continuous Replication. Find out how this can help you improve uptime, limit data loss, and simplify e-mail maintenance and retention.

Scott Schnoll

TechNet Magazine December 2007

...

Read more!

Also by this Author

As a network administrator, you've just seen fifty copies of the same e-mail virus sent to your users. How do you know which machine is infected? Is it someone inside your own company or someone external you can block?

R'ykandar Korra'ti

TechNet Magazine Winter 2005

...

Read more!

Over the previous two issues, I discussed the two most popular Internet message-moving protocols, SMTP and POP3. This month, I will approach the Internet Message Access Protocol Version 4, revision one (IMAP4rev1), often referred to just as IMAP4.

R'ykandar Korra'ti

TechNet Magazine March • April 2006

...

Read more!

R'ykandar Korra'ti

TechNet Magazine October 2006

...

Read more!

R'ykandar Korra'ti

TechNet Magazine February 2007

...

Read more!

SMTP, the Simple Mail Transfer Protocol, carries the electronic mail of the world. While other message transferring systems exist—some more efficient, some better at specific tasks, some privately owned and some public—none have won the widespread public acceptance of the venerable SMTP, first defined in RFC 821, all the way back in 1982.

R'ykandar Korra'ti

TechNet Magazine November • December 2005

...

Read more!

Popular Articles

Take a close look at SharePoint Security Accounts to see how a weak configuration can give an attacker full control over all site collections and sites.

Pav Cherny

TechNet Magazine January 2009

...

Read more!

Raymond Chen explains why it is often the developers who have their acts together who end up checking in the final bug fixes to products.

Raymond Chen

TechNet Magazine January 2009

...

Read more!

The new Group Policy Preferences feature found in Windows Server 2008 and Windows Vista provides more than 3,000 settings, greatly expanding what administrators can do with Group Policy. Here’s a guide to using Group Policy Preferences to manage your environment.

Derek Melber

TechNet Magazine January 2009

...

Read more!

Why do attachment sizes increase when sending and receiving e-mail messages? How can you ensure databases on a passive node in a CCR cluster are defragmented during online maintenance? Can you use an external trust between forests? We answer these questions and more.

Henrik Walther

TechNet Magazine January 2009

...

Read more!

Aaron Margosis

TechNet Magazine August 2006

...

Read more!

Our Blog

NAP monitors the health of specified computers when they attempt to connect to a network and includes a number of mechanisms to enforce health requirements. In this article, Geek of All Trades Greg Shields gives readers an overview of these enforcement mechanisms and, as an example, takes a closer look at setting ...

Read more!

Use Windows PowerShell to Manage Virtual Machines Here are a few examples of how you can use Windows PowerShell scripts to manage virtual machines running on a Server Core installation. Note that these scripts are presented as samples and may need to be customized to work in your environment.

Create a New ...

Read more!

Disabling an Unused Part of Group Policy Objects One way to disable a policy is to disable an unused part of the GPO. By disabling part of a policy that isn’t used, the application of GPOs and security will be faster.

Administer Windows Server 2008 Server Core from the Command Prompt ...

Read more!

In the August 2008 issue of TechNet Magazine, Paul Randal wrote an article Top Tips for Effective Database Maintenance.  It was geared toward "involuntary  DBAs" (IT pros who inadvertently wind up responsible for a SQL Server instance).  The article had a great response from our readers so Paul has written another ...

Read more!

Microsoft Forefront is designed to deliver an integrated security solution that makes it much easier to deploy and manage security across an organization’s IT infrastructure. In this, our annual security issue, we feature two articles that describe how Forefront Security protects instant messaging and e-mail.

Protect ...

Read more!

How IT Works POP3 Delivers
R’ykandar Korra’ti


In the last issue, I discussed SMTP, the most common protocol for sending e-mail across the Internet. Now I’d like to discuss the other Internet protocol that almost all mail clients support: POP3, which lets users access the e-mail on their mail server.
As with many Internet specifications, POP3 is simple. It consists of a small number of commands sent in human-readable form over a line-oriented TCP/IP connection, the same underlying protocol used by Telnet and SMTP. This makes it particularly easy to learn, since a person can play the role of the POP3 client, typing commands and reading responses as they are sent.
In POP3, the client always initiates the connection, requesting access to the user’s mail server over TCP port 110 (by default). The server must return +OK and a greeting message:
C:\> telnet adatum.com 110
Connected to adatum.com.
+OK Microsoft Exchange Server 2003 POP3 server version 6.5.6944.0 (adatum.com) ready.
At this point, the POP3 server is in authentication mode. The client must identify the name of the user whose mail it wishes to retrieve, and provide some password, key, or other validating marker to indicate that the client has authorization to retrieve that user’s mail.
The traditional method is the username/password pair:
USER <username>
PASS <password>
The first is sent in response to the POP3 server greeting. The second is sent after the username is accepted, thusly:
USER dara
+OK
PASS solarbird
+OK User successfully logged on.
Note that accepted commands always gather a +OK response. Bad commands and server-side errors trigger an –ERR response, usually followed by a detailed explanation. A bad username/password pair would have prompted a server response similar to this:
-ERR permission denied
The USER/PASS authentication method has a particularly severe weakness: both the username and password are transmitted unencrypted. Anyone with a network sniffer can gain login information for any user logging on. While this is less of a problem in a properly secured corporate environment, it is a major vulnerability in a public networking environment, such as the free Wireless Access Point (WAP) connectivity found in many public facilities. For more information on how to mitigate this risk, see the sidebar entitled "Securing POP3."
Regardless of the authentication system used, once the server has accepted the user’s credentials, it enters the transaction state, where messages may be retrieved. This is accomplished with a small set of commands: STAT, LIST, RETR, DELE, NOOP, RSET, and optionally TOP and UIDL. These may be entered in any order and may be repeated.
STAT prompts the server to return the number of messages queued and their combined size, in bytes:
STAT
+OK 5 4071
Here, the command response indicates that the server has five messages for the user, and that their total combined size is 4,071 bytes. Including an argument would cause the server to return –ERR, often followed by a detailed message on the same line indicating a protocol error. This is the standard error response for any improperly formatted or unrecognized command.
LIST provides information about individual messages stored on the server, specifically the number and size of messages, the latter again being in bytes. If no parameter is given, data for all messages is returned:
LIST
+OK 5 4071
1 1049
2 204
3 1840
4 474
5 504
.
The period on a line by itself indicates the end of any multiline output. If given a message number as a parameter, it returns that message number and its size alone, all on a single line with the +OK response:
LIST 4
OK 4 474
A client can download these messages using the RETR command, which requires a single message number as parameter as shown in Figure 1.
Figure 1 Downloading Messages with RETR 
Note again the use of a period on a line by itself to indicate the end of the message. The byte count provided must match the size of the output message, which will be presented in RFC 2822 format: the full headers, followedv by a blank line, followed by the message body. Attachments will be presented either as MIME-enveloped sections or as UUENCODED blocks, as determined by the sender’s e-mail client, with the expectation that the receiver’s client will decode them appropriately.
The client may mark the message for deletion with the DELE command, which takes only a single message number:
DELE 4
+OK
If the message doesn’t exist or has been deleted, the server will return error codes:
DELE 6
-ERR The specified message is out of range. 
DELE 4
+OK
DELE 4
-ERR The requested message is no longer available; it may have been deleted.
The command NOOP is simply used to avoid server timeouts, if it’s used at all. It takes no parameters and does nothing; the server must return +OK.
The RSET command, which takes no parameters, clears any delete flags that have been set. It returns +OK if the flags clear, or –ERR if, for some internal-to-server reason, they don’t.
QUIT tells the server to actually delete any messages previously marked for deletion and end the session, in that order. Typically, this generates a quick +OK response, followed by a dropped connection. However, since this is the stage when messages are actually removed from the server, the server could, in theory, be unable to delete the messages and return –ERR before closing the port anyway.
In addition to these mandatory commands, the POP3 specification includes two very useful optional commands: TOP and UIDL. Most servers implement both. TOP accepts a message number and a number of lines. The POP3 server returns the requested message’s full headers, followed by the number of lines of the message that were requested, as shown in Figure 2.
Clients often use this command in slow networking environments to pull down headers for an Inbox entry, downloading the full message only on demand.
Figure 2 Message Information Returned by TOP 
UIDL returns unique identifiers for each message or, if a message number is given as a parameter, for one message. Using this unique identifier, the client can identify whether a message is one it has previously downloaded and left on the server and accordingly not download it a second time:
UIDL 1
+OK 1 AAgK5ADAAAAxknrcB3ItECk45jXkigfA
UIDL
1 AAgK5ADAAAAxknrcB3ItECk45jXkigfA
2 AAAL5ADAAAAxknrcB3ItECk45jXkigfA
3 AAwK5ADAAAAxknrcB3ItECk45jXkigfA
4 AAQL5ADAAAAxknrcB3ItECk45jXkigfA
5 AAgL5ADAAAAxknrcB3ItECk45jXkigfA
This very simple and small set of commands provides all the functionality needed to retrieve e-mail from a server. It does not provide more advanced functionality, leaving that to the e-mail client to implement as it sees fit. As a result, it is both simple to implement and commonly supported.
Securing POP3
Three good methods exist to work around the problem of clear text credentials in POP3. One method is the optional AUTH command, borrowed from the Internet Message Access Protocol (IMAP) specification. The AUTH command may be used on some servers in place of the USER/PASS pair. The AUTH includes as its parameter an IMAP-encrypted identification string:
AUTH <IMAP identification string>
This command triggers an encrypted exchange that authenticates the user without having to transmit the username or password in the clear at any time. POP3 then returns to transmitting information in the clear, as if a USER/PASS pair had been sent.
A second solution is the optional Authenticated Post Office Protocol (APOP) command, which requires a timestamp ID to be sent by the server at connect time in the greeting line. This server-sent timestamp ID is then combined with the user’s password by the client and converted into fixed-size hexadecimal "digest" form with the MD5 algorithm (see RFC 1321 for details on MD5). Then the client logs on with a single command:
APOP <username> <digest-form-password>
+OK User successfully logged on. 
Since the digest changes each login, thanks to the inclusion of the timestamp ID, there is no single unencrypted token to steal, improving login security.
The third, and probably safest, route is to run the standard POP3 protocol itself over an encrypted channel. By connecting through an encrypted Virtual Private Network (VPN), or by substituting the ssh2 protocol for the basic Telnet connection, the user ensures that nothing is sent in clear text, making sniffing much less a threat for both login information and e-mail content.


R’ykandar Korra’ti postmaster for a small co-op ISP, lives near Seattle with her partner Anna. Having previously shipped mail products at Microsoft, she is now looking at grad school in a CS-related field so esoteric it doesn’t really have a name. Potential faculty advisors can reach her at darako@murkworks.net
© 2008 Microsoft Corporation and CMP Media, LLC. All rights reserved; reproduction in part or in whole without permission is prohibited.
Page view tracker