16 |
# along with this program; if not, write to the Free Software Foundation, |
# along with this program; if not, write to the Free Software Foundation, |
17 |
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 |
|
|
19 |
|
# 6.4.4. SEARCH Command |
20 |
|
# Arguments: OPTIONAL [CHARSET] specification |
21 |
|
# searching criteria (one or more) |
22 |
|
# Responses: REQUIRED untagged response: SEARCH |
23 |
|
# Result: OK - search completed |
24 |
|
# NO - search error: can't search that [CHARSET] or |
25 |
|
# criteria |
26 |
|
# BAD - command unknown or arguments invalid |
27 |
|
# |
28 |
|
# The SEARCH command searches the mailbox for messages that match |
29 |
|
# the given searching criteria. Searching criteria consist of one |
30 |
|
# or more search keys. The untagged SEARCH response from the server |
31 |
|
# contains a listing of message sequence numbers corresponding to |
32 |
|
# those messages that match the searching criteria. |
33 |
|
|
34 |
imap4d_start |
imap4d_start |
35 |
imap4d_auth "user!passwd" "guessme" |
imap4d_auth "user!passwd" "guessme" |
36 |
|
|
46 |
"OK \[PERMANENTFLAGS (\\Answered \\Deleted \\Seen)\] Permanent flags"\ |
"OK \[PERMANENTFLAGS (\\Answered \\Deleted \\Seen)\] Permanent flags"\ |
47 |
"OK \[READ-WRITE\] SELECT Completed" |
"OK \[READ-WRITE\] SELECT Completed" |
48 |
|
|
49 |
|
# <message set> Messages with message sequence numbers |
50 |
|
# corresponding to the specified message sequence |
51 |
|
# number set |
52 |
|
|
53 |
imap4d_test "SEARCH 1:*" \ |
imap4d_test "SEARCH 1:*" \ |
54 |
"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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95" \ |
"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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95" \ |
55 |
"OK" |
"OK" |
56 |
|
|
57 |
|
# ALL All messages in the mailbox; the default initial |
58 |
|
# key for ANDing. |
59 |
|
|
60 |
imap4d_test "SEARCH ALL" \ |
imap4d_test "SEARCH ALL" \ |
61 |
"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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95" \ |
"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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95" \ |
62 |
"OK" |
"OK" |
63 |
|
|
64 |
|
# NEW Messages that have the \Recent flag set but not the |
65 |
|
# \Seen flag. This is functionally equivalent to |
66 |
|
# "(RECENT UNSEEN)". |
67 |
|
|
68 |
# All messages are still new |
# All messages are still new |
69 |
imap4d_test "SEARCH NEW" \ |
imap4d_test "SEARCH NEW" \ |
70 |
"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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95" \ |
"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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95" \ |
71 |
"OK" |
"OK" |
72 |
|
|
73 |
|
# FROM <string> Messages that contain the specified string in the |
74 |
|
# envelope structure's FROM field. |
75 |
|
|
76 |
imap4d_test "SEARCH FROM alice" \ |
imap4d_test "SEARCH FROM alice" \ |
77 |
"SEARCH 2 4 6 8 10 12 14 20 25 27 29 33 36 38 40 43 45 47 51 53 55 57 59 63 66 68 70 72 74 76 78 80 82 85 87 90 93 95" \ |
"SEARCH 2 4 6 8 10 12 14 20 25 27 29 33 36 38 40 43 45 47 51 53 55 57 59 63 66 68 70 72 74 76 78 80 82 85 87 90 93 95" \ |
78 |
"OK" |
"OK" |
81 |
"SEARCH 1 3 5 7 9 11 13 16 22 24 35 42 58 62 71" \ |
"SEARCH 1 3 5 7 9 11 13 16 22 24 35 42 58 62 71" \ |
82 |
"OK" |
"OK" |
83 |
|
|
84 |
|
# LARGER <n> Messages with an [RFC-822] size larger than the |
85 |
|
# specified number of octets. |
86 |
|
|
87 |
imap4d_test "SEARCH LARGER 512" \ |
imap4d_test "SEARCH LARGER 512" \ |
88 |
"SEARCH 41 46" \ |
"SEARCH 41 46" \ |
89 |
"OK" |
"OK" |
90 |
|
|
91 |
|
# SMALLER <n> Messages with an [RFC-822] size smaller than the |
92 |
|
# specified number of octets. |
93 |
|
|
94 |
imap4d_test "SEARCH SMALLER 300" \ |
imap4d_test "SEARCH SMALLER 300" \ |
95 |
"SEARCH 12 20 35" \ |
"SEARCH 12 20 35" \ |
96 |
"OK" |
"OK" |
97 |
|
|
98 |
|
# SUBJECT <string> Messages that contain the specified string in the |
99 |
|
# envelope structure's SUBJECT field. |
100 |
|
|
101 |
imap4d_test "SEARCH SUBJECT \"watch\"" \ |
imap4d_test "SEARCH SUBJECT \"watch\"" \ |
102 |
"SEARCH 19 20 21 22 23 24 25 26 27 28 29"\ |
"SEARCH 19 20 21 22 23 24 25 26 27 28 29"\ |
103 |
"OK" |
"OK" |
104 |
|
|
105 |
|
# HEADER <field-name> <string> |
106 |
|
# Messages that have a header with the specified |
107 |
|
# field-name (as defined in [RFC-822]) and that |
108 |
|
# contains the specified string in the [RFC-822] |
109 |
|
# field-body. |
110 |
|
|
111 |
imap4d_test "SEARCH HEADER Message-Id \"<200207292200.3303@wonder.land>\"" \ |
imap4d_test "SEARCH HEADER Message-Id \"<200207292200.3303@wonder.land>\"" \ |
112 |
"SEARCH 3" \ |
"SEARCH 3" \ |
113 |
"OK" |
"OK" |
114 |
|
|
115 |
|
# CC <string> Messages that contain the specified string in the |
116 |
|
# envelope structure's CC field. |
117 |
|
|
118 |
imap4d_test "SEARCH CC dormouse" \ |
imap4d_test "SEARCH CC dormouse" \ |
119 |
"SEARCH 60" \ |
"SEARCH 60" \ |
120 |
"OK" |
"OK" |
121 |
|
|
122 |
|
# TO <string> Messages that contain the specified string in the |
123 |
|
# envelope structure's TO field. |
124 |
|
|
125 |
imap4d_test "SEARCH TO hare"\ |
imap4d_test "SEARCH TO hare"\ |
126 |
"SEARCH 2 4 6 8 10 12 14 21 23 42 59 72" \ |
"SEARCH 2 4 6 8 10 12 14 21 23 42 59 72" \ |
127 |
"OK" |
"OK" |
128 |
|
|
129 |
|
# SENTBEFORE <date> |
130 |
|
# Messages whose [RFC-822] Date: header is earlier |
131 |
|
# than the specified date. |
132 |
|
|
133 |
imap4d_test "SEARCH SENTBEFORE \"29-Jul-2002 22:00:02 +0100\"" \ |
imap4d_test "SEARCH SENTBEFORE \"29-Jul-2002 22:00:02 +0100\"" \ |
134 |
"SEARCH 1"\ |
"SEARCH 1"\ |
135 |
"OK" |
"OK" |
136 |
|
|
137 |
|
# SENTSINCE <date> |
138 |
|
# Messages whose [RFC-822] Date: header is within or |
139 |
|
# later than the specified date. |
140 |
|
|
141 |
imap4d_test "SEARCH SENTSINCE \"29-Jul-2002 22:01:32 +0100\""\ |
imap4d_test "SEARCH SENTSINCE \"29-Jul-2002 22:01:32 +0100\""\ |
142 |
"SEARCH 92 93 94 95"\ |
"SEARCH 92 93 94 95"\ |
143 |
"OK" |
"OK" |
146 |
"SEARCH 92 93 94 95"\ |
"SEARCH 92 93 94 95"\ |
147 |
"OK" |
"OK" |
148 |
|
|
149 |
|
# BEFORE <date> Messages whose internal date is earlier than the |
150 |
|
# specified date. |
151 |
|
|
152 |
imap4d_test "SEARCH BEFORE \"29-Jul-2002 22:00:09 +0000\""\ |
imap4d_test "SEARCH BEFORE \"29-Jul-2002 22:00:09 +0000\""\ |
153 |
"SEARCH 1"\ |
"SEARCH 1"\ |
154 |
"OK" |
"OK" |
155 |
|
|
156 |
|
# SINCE <date> Messages whose internal date is within or later |
157 |
|
# than the specified date. |
158 |
|
|
159 |
imap4d_test "SEARCH SINCE \"29-Jul-2002 22:01:36 +0000\""\ |
imap4d_test "SEARCH SINCE \"29-Jul-2002 22:01:36 +0000\""\ |
160 |
"SEARCH 89 90 91 92 93 94 95"\ |
"SEARCH 89 90 91 92 93 94 95"\ |
161 |
"OK" |
"OK" |
166 |
"89 FETCH FLAGS (\\Answered \\Recent)"\ |
"89 FETCH FLAGS (\\Answered \\Recent)"\ |
167 |
"OK" |
"OK" |
168 |
|
|
169 |
|
# ANSWERED Messages with the \Answered flag set. |
170 |
|
|
171 |
imap4d_test "SEARCH ANSWERED"\ |
imap4d_test "SEARCH ANSWERED"\ |
172 |
"SEARCH 3 5 89"\ |
"SEARCH 3 5 89"\ |
173 |
"OK" |
"OK" |
174 |
|
|
175 |
|
# TEXT <string> Messages that contain the specified string in the |
176 |
|
# header or body of the message. |
177 |
|
|
178 |
imap4d_test "SEARCH TEXT wine"\ |
imap4d_test "SEARCH TEXT wine"\ |
179 |
"SEARCH 1 2 3"\ |
"SEARCH 1 2 3"\ |
180 |
"OK" |
"OK" |
181 |
|
|
182 |
|
## Boolean operations |
183 |
|
|
184 |
|
# When multiple keys are specified, the result is the intersection |
185 |
|
# (AND function) of all the messages that match those keys. |
186 |
|
|
187 |
imap4d_test "SEARCH TEXT wine FROM alice"\ |
imap4d_test "SEARCH TEXT wine FROM alice"\ |
188 |
"SEARCH 2"\ |
"SEARCH 2"\ |
189 |
"OK" |
"OK" |
190 |
|
|
191 |
|
# OR <search-key1> <search-key2> |
192 |
|
# Messages that match either search key. |
193 |
|
|
194 |
imap4d_test "SEARCH OR FROM alice ANSWERED"\ |
imap4d_test "SEARCH OR FROM alice ANSWERED"\ |
195 |
"SEARCH 2 3 4 5 6 8 10 12 14 20 25 27 29 33 36 38 40 43 45 47 51 53 55 57 59 63 66 68 70 72 74 76 78 80 82 85 87 89 90 93 95"\ |
"SEARCH 2 3 4 5 6 8 10 12 14 20 25 27 29 33 36 38 40 43 45 47 51 53 55 57 59 63 66 68 70 72 74 76 78 80 82 85 87 89 90 93 95"\ |
196 |
"OK" |
"OK" |
197 |
|
|
198 |
|
## Check precedence |
199 |
|
|
200 |
imap4d_test "SEARCH (OR FROM alice ANSWERED) SENTSINCE \"29-Jul-2002 22:00:33 +0100\""\ |
imap4d_test "SEARCH (OR FROM alice ANSWERED) SENTSINCE \"29-Jul-2002 22:00:33 +0100\""\ |
201 |
"SEARCH 33 36 38 40 43 45 47 51 53 55 57 59 63 66 68 70 72 74 76 78 80 82 85 87 89 90 93 95" \ |
"SEARCH 33 36 38 40 43 45 47 51 53 55 57 59 63 66 68 70 72 74 76 78 80 82 85 87 89 90 93 95" \ |
202 |
"OK" |
"OK" |
212 |
imap4d_test "SEARCH OR FROM alice (ANSWERED SENTSINCE \"29-Jul-2002 22:00:33 +0100\" SENTBEFORE \"29-Jul-2002 22:00:56 +0100\")"\ |
imap4d_test "SEARCH OR FROM alice (ANSWERED SENTSINCE \"29-Jul-2002 22:00:33 +0100\" SENTBEFORE \"29-Jul-2002 22:00:56 +0100\")"\ |
213 |
"SEARCH 2 4 6 8 10 12 14 20 25 27 29 33 36 38 40 43 45 47 51 53 55 57 59 63 66 68 70 72 74 76 78 80 82 85 87 90 93 95"\ |
"SEARCH 2 4 6 8 10 12 14 20 25 27 29 33 36 38 40 43 45 47 51 53 55 57 59 63 66 68 70 72 74 76 78 80 82 85 87 90 93 95"\ |
214 |
"OK" |
"OK" |
215 |
|
|
216 |
|
#end of search.exp |