使用TELNET手工操作 IMAP 查看邮件
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 "<000f01c699ae$7c5014a0$6b01a8c0@xxxxxx.xx>") 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]$
posted on 2006-08-12 10:05 CrazyWill 阅读(3054) 评论(0) 编辑 收藏 举报