轉(zhuǎn)自:SMTP vs IMAP vs POP3 - Knowing The Difference
簡單說下結(jié)論, 這三個都是郵件應(yīng)用使用的基于TCP的協(xié)議.
SMTP:主要用來從郵件客戶端向郵件服務(wù)器發(fā)送郵件,也可以用來在郵件服務(wù)器之間轉(zhuǎn)發(fā)郵件.和其他的兩個協(xié)議有明顯的功能區(qū)別.
另外的兩個協(xié)議是用來從郵件服務(wù)器獲取郵件的.
POP3:從郵件服務(wù)器收取郵件之后會刪除在服務(wù)器的備份,下載完成之后會斷開連接.簡單,功能少.
IMAP:和POP3最大的不同就是下載完成之后不會刪除在服務(wù)器的郵件. 該協(xié)議設(shè)計的目的就是讓用戶管理在服務(wù)器端的郵件.比POP3占據(jù)了更多的資源,但是在郵件同步方面有極大的優(yōu)勢.
更多細(xì)節(jié)方面的介紹請請移步原文, 更為詳細(xì)的比較在
"Considerations when choosing between IMAP and POP3"部分.
原文如下
Overview
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.
SMTP
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.
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
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.
Advantage: 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.
Advantage: IMAP
Synchronization
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.
Advantage: IMAP
Organization
Because IMAP allows users to arrange messages in a hierarchical fashion and place them in folders, it's certainly better at helping users organize.
Advantage: IMAP
Computational overhead
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.
Advantage: POP3
Privacy
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.
Advantage: POP3
Speed
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.