a FETCH 1 BODY[HEADER.FIELDS ()](查看邮件文件头信息,小括号里面可以指定返回的特定字段)
* 1 FETCH (BODY[HEADER.FIELDS] {2}
)
a OK FETCH completed.
如:a FETCH 1 BODY[HEADER.FIELDS (From)]
* 1 FETCH (BODY[HEADER.FIELDS ("From")] {55}
From: "=?utf-8?B?6ZmG5YeM54eV?=" <lulingyan@zzy.cn>
)
成功,只返回邮件头部信息的From信息
如:a FETCH 1 BODY[HEADER.FIELDS (DATE)]
* 1 FETCH (BODY[HEADER.FIELDS ("DATE")] {47}
Date: Tue, 4 Dec 2012 11:07:29 +0800 (CST)
)
a OK FETCH completed.
成功,只返回邮件头部信息的date信息
a FETCH 1 BODY[HEADER.FIELDS.NOT ()](查看邮件文件头信息,小括号里面可以指定不需要返回的特定字段)
* 1 FETCH (BODY[HEADER.FIELDS.NOT] {1766}
Return-Path: <tang@188.test.net>
Delivered-To: tang@188.test.net
X-MID: 0026B93241E7.2664.1369708345.217272.0
Received: by localhost.localdomain (Postfix, from userid 0)
id 34EFB543138; Tue, 28 May 2013 10:32:25 +0800 (CST)
Received: from FF96E4D31F48429 (unknown [59.57.251.34])
......
Date: Sun, 07 Apr 2013 10:46:58 +0800
From: "=?utf-8?B?6ZmG5YeM54eV?=" <lulingyan@zzy.cn>
To: "=?utf-8?B?amVmZg==?="<jeff@zzy.cn>
X-MD5: 349560dfee48c6527264bb88dcce17c7
)
a OK FETCH completed.
成功,返回邮件的所有头信息,在正常情况下跟BODY[HEADER]没有区别
如:a FETCH 1 BODY[HEADER.FIELDS.NOT (from)]
* 1 FETCH (BODY[HEADER.FIELDS.NOT ("From")] {1713}
Return-Path: <tang@188.test.net>
Delivered-To: tang@188.test.net
.......
成功,返回邮件头信息(除From信息外),在正常情况下跟BODY[HEADER]没有区别
a FETCH 1 BODY[1.MIME](返回邮件的[MIME-IMB]的头信息,在正常情况下跟BODY[HEADER]没有区别)
a OK FETCH completed.
成功,返回邮件的[MIME-IMB]的头信息,在正常情况下跟BODY[HEADER]没有区别
a fetch 1 BODY[TEXT](返回整个邮件体,这里的邮件体并不包括邮件头)
* 1 FETCH (BODY[TEXT] {0}
)
a OK FETCH completed.
成功,返回整个邮件体,但不包括邮件头
SEARCH [CHARSET specification] (search criteria)
命令介绍:
SEARCH命令可以根据搜索条件在处于活动状态的邮箱中搜索邮件,然后显示匹配的邮件编号。字符集标志参数[CHARSET specification]由CHARSET和注册的字符集标志符组成,缺省的标志符是US-ASCⅡ,所以该参数长省略。search criteria:查询条件参数,明确查询的关键字和值。查询关键字有几十种。如:
C: A119 SEARCH header subject another
S: SEARCH 1 2
S:* A119 OK SEARCH completed
C: A120 SEARCH header subject another
S: *SEARCH 2
S: A120 OK SEARCH completed
C: A121 SEARCH UNSEEN
S: *SEARCH 1 2
S: A120 OK SEARCH completed
以上每个例子都在邮件头的Subject:字段中查询一个不同的单词。服务器返回条件的邮件号列表,如果没有匹配邮件则返回不带UID的SEARCH单词。
各参数返回的信息如下:
ALL:All messages in the mailbox; the default initial key forANDing.
ANSWERED:Messages with the \Answered flag set.
BCC <string>:Messages that contain the specified string in the envelope Structure's BCC field.
BEFORE <date>:Messages whose internal date (disregarding time and timezone)is earlier than the specified date.
BODY <string>:Messages that contain the specified string in the body of the message.
CC <string>:Messages that contain the specified string in the envelope Structure's CC field.
DELETED:Messages with the \Deleted flag set.
DRAFT:Messages with the \Draft flag set.
FLAGGED:Messages with the \Flagged flag set.
FROM <string>:Messages that contain the specified string in the envelope Structure's FROM field.
HEADER <field-name> <string>:Messages that have a header with the specified field-name (asdefined in [RFC-2822]) and that contains the specified stringin the text of the header (what comes after the colon). If the String to search is zero-length, this matches all messages thathave a header line with the specified field-name regardless ofthe contents.
KEYWORD <flag>:Messages with the specified keyword flag set.
LARGER <n>:Messages with an [RFC-2822] size larger than the specified number of octets.
NEW:Messages that have the \Recent flag set but not the \Seen flag.This is functionally equivalent to "(RECENT UNSEEN)".
NOT <search-key>:Messages that do not match the specified search key.
OLD:Messages that do not have the \Recent flag set. This isfunctionally equivalent to "NOT RECENT" (as opposed to "NOTNEW").
ON <date>:Messages whose internal date (disregarding time and timezone)is within the specified date.
OR <search-key1> <search-key2>:Messages that match either search key.
RECENT:Messages that have the \Recent flag set.
SEEN:Messages that have the \Seen flag set.
SENTBEFORE <date>:Messages whose [RFC-2822] Date: header (disregarding time andtimezone) is earlier than the specified date.
SENTON <date>:Messages whose [RFC-2822] Date: header (disregarding time andtimezone) is within the specified date.
SENTSINCE <date>:Messages whose [RFC-2822] Date: header (disregarding time andtimezone) is within or later than the specified date.
SINCE <date>:Messages whose internal date (disregarding time and timezone)is within or later than the specified date.
SMALLER <n>:Messages with an [RFC-2822] size smaller than the specifiednumber of octets.
SUBJECT <string>:Messages that contain the specified string in the envelope Structure's SUBJECT field.
TEXT <string>:Messages that contain the specified string in the header or body of the message.
TO <string>:Messages that contain the specified string in the envelope Structure's TO field.
UID <sequence set>:Messages with unique identifiers corresponding to the specified Unique identifier set. Sequence set ranges are permitted.
UNANSWERED:Messages that do not have the \Answered flag set.
UNDELETED:Messages that do not have the \Deleted flag set.
UNDRAFT:Messages that do not have the \Draft flag set.
UNFLAGGED:Messages that do not have the \Flagged flag set.
UNKEYWORD <flag>:Messages that do not have the specified keyword flag set.
UNSEEN:Messages that do not have the \Seen flag set.
命令执行:
[root@localhost src]# telnet localhost 143
..........
a SEARCH all(没有邮箱用户login前执行)
提示失败,需先有邮箱login,并且select邮件夹后,才能使用search命令
a login tang@188.test.net 111111
.....
A select INBOX
.....
a search ALL(命令名为小写,参数使用大写,显示所有邮件)
* SEARCH 1 2 3 4 5
a OK Search completed (0.000 secs).
成功,返回该邮件夹所有的邮件
a SEARCH answered(命令名为大写,参数使用小写,显示有回复标记的邮件)
* SEARCH
a OK Search completed (0.000 secs).
a search answered
* SEARCH 1
a OK Search completed (0.000 secs).
a search before 1-Feb-2014
* SEARCH 1
a OK Search completed (0.000 secs).
a search body 2013
* SEARCH 1 2 3 4 12 13 14 16 17
a OK Search completed (0.104 secs).
a search CC tang@17.test.net
* SEARCH 4 5 11 13 14 15
a OK Search completed (0.044 secs).
a STORE 1 +flags (\deleted)
* 1 FETCH (FLAGS (\Deleted delete))
a OK Store completed.
a search DELETED
* SEARCH 1
a OK Search completed (0.000 secs).
a store 2 +flags (\draft)
* 2 FETCH (FLAGS (\Seen \Draft))
a OK Store completed.
a search Draft
* SEARCH 2
a OK Search completed (0.000 secs).
a store 3 +flags (\FLAGGED)
* 3 FETCH (FLAGS (\Answered \Flagged \Seen))
a OK Store completed.
a search FLAGGED
* SEARCH 3
a OK Search completed (0.000 secs).
a search from tang@11.test.net
* SEARCH 4 5 6 7 8 9 10 11 12 13 14 15 16 17
a OK Search completed (0.045 secs).
a search HEADER from tang@
* SEARCH 4 5 6 7 8 9 10 11 12 13 14 15 16 17
a OK Search completed (0.043 secs).
a search KEYWORD 1
* SEARCH
a OK Search completed (0.002 secs).
a search LARGER 766
* SEARCH 1 2 3 4 5 6 10 11 12 13 14 15 16 17