How Email Works

IMAP Problems and Attachments

As email becomes more complex, attachments do, too, giving us options like video mail.
Getty Images

Your email client connects to the IMAP server using port 143. The email client then issues a set of text commands that allow it to do things like list all the folders on the server, list all the message headers in a folder, get a specific email message from the server, delete messages on the server or search through all of the emails on the server.

One problem that can arise with IMAP involves this simple question: "If all of my email is stored on the server, then how can I read my mail if I'm not connected to the Internet?" To solve this problem, most email clients have some way to cache email on their local machine. For example, the client will download all the messages and store their complete contents on the local machine (just like it would if it were talking to a POP3 server). The messages still exist on the IMAP server, but you now have copies on your machine. This allows you to read and reply to email even if you have no connection to the Internet. The next time you establish a connection, you download all the new messages you received while disconnected and send all the mail that you wrote while disconnected.



Your email client allows you to add attachments to email messages you send, and also lets you save attachments from messages that you receive. Attachments might include word processing documents, spreadsheets, sound files, snapshots and pieces of software. Usually, an attachment is not text (if it were, you would simply include it in the body of the message). Since email messages can contain only text information, and attachments aren't text, there's a problem that needs to be solved.

In the early days of email, you solved this problem by hand, using a program called uuencode. The uuencode program assumes that the file contains binary information. It extracts 3 bytes from the binary file and converts them to four text characters (that is, it takes 6 bits at a time, adds 32 to the value of the 6 bits and creates a text character — see How Bits and Bytes Work to learn more about ASCII characters). What uuencode produces, therefore, is an encoded version of the original binary file that contains only text characters. In the early days of email, you would run uuencode yourself and paste the uuencoded file into your email message.

Considering its tremendous impact on society, having forever changed the way we communicate, today's email system is one of the simplest things ever devised! There are parts of the system, like the routing rules in sendmail, that get complicated, but the basic system is incredibly straightforward. The next time you send an email, you'll know exactly how it's getting to its destination.