【轉】使用TELNET手工操作 IMAP 查看郵件

本文轉自:http://www.cnblogs.com/crazywill/archive/2006/08/12/474884.html

 

IMAP 協議收信與POP收信有很大的不同,最明顯的一點就是發送的每條命令(命令是不區分大小寫的),前面都要帶有一個標籤/標誌,發送一條命令後可以緊接着發送另一條命令,服務器端返回命令處理結果的順序是未知的,取決於各條命令的執行時間。所以返回的結果中,將帶有所發送命令的標籤。如下面示例中的 A01, A02 等等。

說明:手工錄入的用藍色字體表示,#後的爲註釋,不可錄入。

[crazywill@localhost crazywill]$ telnet 192.168.0.1 143      #telnet登錄IMAP協議的143端口
Trying 192.168.0.1...
Connected to xxxxxx
Escape character is '^]'.
* OK xxxxxxx System IMap Server Ready
A01 LOGIN abc 123       #用戶登錄
A01 OK LOGIN completed
A02 LIST "" *           #列出所有信箱列表
* LIST () "/" "INBOX"
* LIST () "/" "Drafts"
* LIST () "/" "Sent Items"
* LIST () "/" "Trash"
* LIST () "/" "Junk E-mail"
* LIST () "/" "Virus Items"
* LIST () "/" "&XfJT0ZABkK5O9g-"
* LIST () "/" "&g0l6Pw-"
* LIST () "/" "&XfJT0ZABkK5O9g-/DailyReport"
* LIST () "/" "Jira"
* LIST () "/" "Admin"
* LIST () "/" "&V4NXPpCuTvY-"
A02 OK LIST Completed
A03 Select INBOX         #選擇收件箱
* 37 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1] UIDs valid
* FLAGS (\Answered \Seen \Deleted \Draft)
* OK [PERMANENTFLAGS (\Answered \Seen \Deleted \Draft)] Limited
A03 OK [READ-WRITE] SELECT completed
A04 Search ALL           #查詢收件箱所有郵件
* OK X-SEARCH in progress
* OK X-SEARCH in progress
* OK X-SEARCH in progress
* SEARCH 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
A04 OK SEARCH completed            # 列出符合條件的郵件序號(ALL表示列出當前信箱INBOX中的所有郵件)
A05 Search new           #查詢收件箱所有新郵件
* OK X-SEARCH in progress
* OK X-SEARCH in progress
* OK X-SEARCH in progress
* SEARCH
A05 OK SEARCH completed            #找不到任何新郵件
A06 Fetch 5 full         #獲取第5封郵件的郵件頭
* 5 FETCH (INTERNALDATE "27-Jun-2006 14:00:27 +0800" FLAGS (\Seen) ENVELOPE ("Tue, 27 Jun 2006 13:56:51 +0800" "test " (("xxxxxx" NIL "xxxx" "xxxxxx")) (("xxxxxx" NIL "xxxx" "xxxxxx")) (("xxxxxx" NIL "xxxx" "xxxxxx")) ((NIL NIL "xxx" "xxxxx")) NIL NIL NIL "<[email protected]>") BODY (("text" "plain" ("charset" "gb2312") NIL NIL "base64" 14 2) ("text" "html" ("charset" "gb2312") NIL NIL "base64" 420 7) "alternative") RFC822.SIZE 1396)
A06 OK Fetch completed
A07 Fetch 5 rfc822       #獲取第5封郵件的完整內容
* 5 FETCH (RFC822 {1396}
[這裏是郵件內容,太長,略...]
A07 OK Fetch completed
A08 Fetch 5 flags        #查詢第5封郵件的標誌位
A08 OK Fetch completed
A09 Store 5 +flags.silent (\deleted)          #設置標誌位爲刪除
A09 OK STORE completed
A10 Expunge              #永久刪除當前郵箱INBOX中所有設置了\deleted標誌的信件
A10 OK EXPUNGE completed
A11 noop                  # 空語句
A11 OK NOOP completed


A20 LOGOUT               #退出
* BYE IMAP4rev1 Server logging out
A20 OK LOGOUT completed
Connection closed by foreign host.
[crazywill@localhost crazywill]$

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章