Your ability to send and receive emails is largely due to 3 TCP protocols: SMTP, IMAP, and POP3. If you've got a couple of minutes to spare, now's a good time to know what they are and how they differ from one another.
Let's start with SMTP because its primary function is different from the other two. SMTP or Simple Mail Transfer Protocol is mostly used for sending out email from an email client (e.g. Microsoft Outlook, Thunderbird or Apple Mail) to an email server. It's also used for relaying or forwarding mail messages from one mail server to another. The ability to relay messages from one server to another is necessary if the sender and recipient have different email service providers.
SMTP, which is specified in RFC 5321, uses port 25 by default. It may also use port 587 and port 465. The latter, which was introduced as the port of choice for secure SMTP (a.k.a. SMTPS), is supposed to be deprecated. But in reality, it's still being used by several mail service providers.
Now that you have a basic understanding of SMTP, it's time to turn our attention to the two protocols for retrieving email from mail servers: IMAP and POP3. Let's start with POP3.
As shown in the figure above, the Post Office Protocol or POP is used to retrieve email messages from a mail server to a mail client. The latest version, which is what's widely used, is version 3 - hence the term "POP3".
POP version 3, which is specified in RFC 1939, supports extensions and several authentication mechanisms. Authentication features are necessary to prevent malicious individuals from gaining unauthorized access to users' messages.
Generally speaking, a POP3 client retrieves email in the following manner:
- Connects to the mail server on port 110 (or 995 for SSL/TLS connections);
- Retrieves email messages;
- Deletes copies of the messages stored on the server; and
- Disconnects from the server
Although POP clients may be configured to allow the server to continue storing copies of the downloaded messages, the steps outlined above is the usual practice. Leaving them on the server is a practice that's usually done via IMAP. Let's talk about it now.
IMAP, especially the current version (IMAP4), is a more sophisticated protocol. It allows users to group related messages and place them in folders, which can in turn be arranged hierarchically. It's also equipped with message flags that indicate whether a message has been read, deleted, or replied to. It even allows users to carry out searches against the server mailboxes.
Here's how IMAP works in a nutshell:
- Connects to the mail server on port 143 (or 993 for SSL/TLS connections);
- Retrieves email messages;
- Stays connected until the mail client app is closed and downloads messages on demand.
Notice that messages aren't deleted on the server. This has major implications, which we'll talk about shortly.
IMAP specifications can be found in RFC 3501.
Considerations when choosing between IMAP and POP3
Since SMTP's main function is different altogether, the dilemma of choosing the better protocol usually involves only IMAP and POP3. Here are some of the things you will want to put into consideration:
Server storage space
A server with limited storage space is one major factor that may force you to favor POP3. Since IMAP leaves messages on the server, it can consume storage space faster than POP3.
Anytime, anywhere access
There's one good reason why IMAP was designed to store messages on the server. It's meant to enable retrieval of messages from multiple devices; sometimes, even simultaneously. So if you have an iPhone, an Android tablet, a laptop, and a desktop, and you want to read email from any or all of these devices, IMAP would be the better choice.
If you access email messages from multiple devices (who doesn't these days?), you'll likely want all devices to reflect whatever action you performed on one device.
For instance, if you read messages, A, B, and C, then you'll want those messages to be also marked as "read" on the other devices. If you deleted messages B and C, then you'll want those same messages removed from your inbox on the other devices as well. If you moved message A to another folder ... well, you know what I mean. All these synchronizations can only be achieved if you're using IMAP.
Because IMAP allows users to arrange messages in a hierarchical fashion and place them in folders, it's certainly better at helping users organize.
Of course, all that IMAP functionality comes at a price. It's arguably more difficult to implement and certainly consumes a lot more CPU and RAM, especially when it performs those synchronizations. In fact, high CPU and memory usage can happen at both the client and server side if there's a ton of messages to sync.
This is one concern that would weigh heavily on end users who frequently deal with confidential information. These users would prefer to download all email messages and leave no copies behind on the server.
Whereas POP3 downloads all mail messages upon connection, IMAP may optionally download just the message headers or certain portions and leave, for example, the attachments on the server. Only when the user decides the remaining portions are worth downloading, will those portions be downloaded. In this regard, IMAP can be considered faster.
However, if all messages on the server are supposed to be downloaded every single time, then POP3 would now be faster.
Advantage: Depends on the situation
As you can see, each protocol has its own advantages and disadvantages. It's really up to you to decide which functions/capabilities are more important to you.
Are you a developer?
If you are and you use Java, Secure iNet Factory includes some easy to use Java-based components for developing applications that support SMTP, IMAP, POP3 and several other networking protocols. Download it now.
For those who use .NET, there's Email Factory for .NET as well.
Want to be updated on posts like this? Connect with us...