SMTP栅葡、IMAP和POP3的區(qū)別和聯(lián)系

轉(zhuǎn)自:SMTP vs IMAP vs POP3 - Knowing The Difference

簡單說下結(jié)論, 這三個都是郵件應(yīng)用使用的基于TCP的協(xié)議.
SMTP:主要用來從郵件客戶端向郵件服務(wù)器發(fā)送郵件,也可以用來在郵件服務(wù)器之間轉(zhuǎn)發(fā)郵件.和其他的兩個協(xié)議有明顯的功能區(qū)別.


smtp_sending_forwarding

另外的兩個協(xié)議是用來從郵件服務(wù)器獲取郵件的.


smtp_imap_pop3

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_sending_forwarding

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.

smtp_imap_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:

  1. Connects to the mail server on port 110 (or 995 for SSL/TLS connections);
  2. Retrieves email messages;
  3. Deletes copies of the messages stored on the server; and
  4. 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:

  1. Connects to the mail server on port 143 (or 993 for SSL/TLS connections);
  2. Retrieves email messages;
  3. 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.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末壕曼,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 212,383評論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件砸脊,死亡現(xiàn)場離奇詭異驱显,居然都是意外死亡孩哑,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,522評論 3 385
  • 文/潘曉璐 我一進(jìn)店門仅炊,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人茵乱,你說我怎么就攤上這事茂洒。” “怎么了?”我有些...
    開封第一講書人閱讀 157,852評論 0 348
  • 文/不壞的土叔 我叫張陵督勺,是天一觀的道長渠羞。 經(jīng)常有香客問我,道長智哀,這世上最難降的妖魔是什么次询? 我笑而不...
    開封第一講書人閱讀 56,621評論 1 284
  • 正文 為了忘掉前任,我火速辦了婚禮瓷叫,結(jié)果婚禮上屯吊,老公的妹妹穿的比我還像新娘。我一直安慰自己摹菠,他們只是感情好盒卸,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,741評論 6 386
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著次氨,像睡著了一般蔽介。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上煮寡,一...
    開封第一講書人閱讀 49,929評論 1 290
  • 那天虹蓄,我揣著相機(jī)與錄音,去河邊找鬼幸撕。 笑死薇组,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的坐儿。 我是一名探鬼主播律胀,決...
    沈念sama閱讀 39,076評論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼挑童!你這毒婦竟也來了累铅?” 一聲冷哼從身側(cè)響起跃须,我...
    開封第一講書人閱讀 37,803評論 0 268
  • 序言:老撾萬榮一對情侶失蹤站叼,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后菇民,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體尽楔,經(jīng)...
    沈念sama閱讀 44,265評論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,582評論 2 327
  • 正文 我和宋清朗相戀三年第练,在試婚紗的時候發(fā)現(xiàn)自己被綠了阔馋。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,716評論 1 341
  • 序言:一個原本活蹦亂跳的男人離奇死亡娇掏,死狀恐怖呕寝,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情婴梧,我是刑警寧澤下梢,帶...
    沈念sama閱讀 34,395評論 4 333
  • 正文 年R本政府宣布客蹋,位于F島的核電站,受9級特大地震影響孽江,放射性物質(zhì)發(fā)生泄漏讶坯。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,039評論 3 316
  • 文/蒙蒙 一岗屏、第九天 我趴在偏房一處隱蔽的房頂上張望辆琅。 院中可真熱鬧,春花似錦这刷、人聲如沸婉烟。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,798評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽隅很。三九已至,卻和暖如春率碾,著一層夾襖步出監(jiān)牢的瞬間叔营,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,027評論 1 266
  • 我被黑心中介騙來泰國打工所宰, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留绒尊,地道東北人。 一個月前我還...
    沈念sama閱讀 46,488評論 2 361
  • 正文 我出身青樓仔粥,卻偏偏與公主長得像婴谱,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子躯泰,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,612評論 2 350

推薦閱讀更多精彩內(nèi)容