1. 程式人生 > >mail imap noop命令

mail imap noop命令

一 文件說明

摘自rfc3501

6.1.2. NOOP Command
Arguments: none
Responses: no specific responses for this command (but see below)
Result:  
    OK - noop completed
    BAD - command unknown or arguments invalid
The NOOP command always succeeds. It does nothing.
Since any command can return a status update as untagged data, the NOOP command can be used as a periodic poll for new messages or message status updates during a period of inactivity (this is the preferred method to do this). The NOOP command can also be used to reset any inactivity autologout timer on the server.

noop命令總是返回成功,但是當伺服器有新訊息或者訊息狀態發生改變時,伺服器在noop命令響應前會進行響應。

二 舉例

C: a002 NOOP
S: a002 OK NOOP completed
. . .
C: a047 NOOP
S: * 22 EXPUNGE   // 郵件序號 刪除
S: * 23 EXISTS    // 收取後,有新郵件到達,郵件總數量,也是當前最大的郵件序號
S: * 3 RECENT    // 收取後,有新郵件到達,但沒被收取過的數量。(關閉其他郵件客戶端時,與EXISTS一起出現)
S: * 14 FETCH (FLAGS (\Seen \Deleted)) // 郵件序號 標籤發生改變
S: a047 OK NOOP completed

三 討論

noop是imap的全域性命令,既然涉及到郵件序號,那麼要處理該類伺服器響應,是否應該先進行select命令。