The POP3 and IMAP Servers
In the simplest implementations of POP3, the server really does maintain a collection of text files — one for each email account. When a message arrives, the POP3 server simply appends it to the bottom of the recipient's file.
When you check your email, your email client connects to the POP3 server using port 110. The POP3 server requires an account name and a password. Once you've logged in, the POP3 server opens your text file and allows you to access it. Like the SMTP server, the POP3 server understands a very simple set of text commands. Here are the most common commands:
- USER - enter your user ID
- PASS - enter your password
- QUIT - quit the POP3 server
- LIST - list the messages and their size
- RETR - retrieve a message, pass it a message number
- DELE - delete a message, pass it a message number
- TOP - show the top x lines of a message, pass it a message number and the number of lines
Your email client connects to the POP3 server and issues a series of commands to bring copies of your email messages to your local machine. Generally, it will then delete the messages from the server (unless you've told the email client not to).
You can see that the POP3 server simply acts as an interface between the email client and the text file containing your messages. And again, you can see that the POP3 server is extremely simple. You can connect to it through telnet at port 110 and issue the commands yourself if you would like to (see How Web Servers Work for details on telnetting to servers).
The IMAP Server
As you can see, the POP3 protocol is very simple. It allows you to have a collection of messages stored in a text file on the server. Your email client (e.g. Outlook Express) can connect to your POP3 email server and download the messages from the POP3 text file onto your PC. That is about all that you can do with POP3.
Many users want to do far more than that with their email, and they want their email to remain on the server. The main reason for keeping your email on the server is to allow users to connect from a variety of machines. With POP3, once you download your email it's stuck on the machine to which you downloaded it. If you want to read your email both on your desktop machine and your laptop (depending on whether you're working in the office or on the road), POP3 makes life difficult.
IMAP (Internet Mail Access Protocol) is a more advanced protocol that solves these problems. With IMAP, your mail stays on the email server. You can organize your mail into folders, and all the folders live on the server as well. When you search your email, the search occurs on the server machine, rather than on your machine. This approach makes it extremely easy for you to access your email from any machine, and regardless of which machine you use, you have access to all of your mail in all of your folders.
We'll look at IMAP problems and attachments in the next section.