HEX
Server: Apache/2
System: Linux nexus-01 4.18.0-553.120.1.el8_10.x86_64 #1 SMP Mon Apr 20 18:04:27 EDT 2026 x86_64
User: aglcoke (1118)
PHP: 8.2.31
Disabled: mail,exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/share/man/man7/doveadm-search-query.7
.TH "DOVEADM-SEARCH-QUERY" "7" "May 2026" "e5ac02a" "Dovecot"
.SH "NAME"
\fBdoveadm-search-query\fR - Overview of search queries for doveadm mailbox commands
.SH "DESCRIPTION"
.P
Several doveadm(1) commands use a \fIsearch_query\fR in order to act only on matching messages. This manual page describes all \fISEARCH KEYS\fR, which can be used in a \fIsearch_query\fR. The query is mostly compatible with the IMAP SEARCH command parameters, although there are some differences.
.P
Each \fIsearch_query\fR consists at least of one \fISEARCH KEY\fR. Most of the \fISEARCH KEYS\fR require an argument. All \fISEARCH KEYS\fR are case-insensitive. The shortest valid \fIsearch_query\fR is \fBALL\fR. For example:
.P
.RS 2
.nf
doveadm search ALL
.fi
.RE
.P
Multiple search query expressions will be combined with the \fBAND\fR operator by default. To find all messages that are new and greater than 50 kilobyte, one can use:
.P
.RS 2
.nf
doveadm search NEW LARGER 50k
.fi
.RE
.P
\fBOR\fR-ed \fISEARCH KEYS\fR have to be written in parenthesis, when mixing ANDs and ORs. Shells commonly require escaping for parentheses. To find messages that were saved on the "13th of April 2007" AND have the \[rs]Seen and/or \[rs]Flagged flag set, one can use for example:
.P
.RS 2
.nf
doveadm search SAVEDON 2007-04-13 \[rs]( SEEN OR FLAGGED \[rs])
.fi
.RE
.P
It's also possible to specify the mailbox, in which should be searched. Use either the keyword \fBmailbox\fR and the name of the mailbox or the keyword \fBmailbox-guid\fR and the mailbox's globally unique identifier in the \fIsearch_query\fR. To find all messages in the mailbox with the GUID "44f68b13ce97044b837f000035ca9452" use:
.P
.RS 2
.nf
doveadm search mailbox-guid 44f68b13ce97044b837f000035ca9452 ALL
.fi
.RE
.P
To list all deleted messages in the "Trash" folder use:
.P
.RS 2
.nf
doveadm search mailbox Trash DELETED
.fi
.RE
.SH "SEARCH KEYS"
.P
The following search keys from the specification of IMAP version 4 revision 1 (see: RFC 3501) are supported:
.P
\fIsequence-set\fR
.RS 0
.RS 4
.P
Matches messages with the given sequence numbers. The \fIsequence-set\fR may be a single sequence number. Can be a sequence range, written as \fIfrom\fR:\fIto\fR, e.g. \fB100\fR:\fB125\fR. As comma separated list of sequences, e.g. \fB11,50,4\fR. It's also possible to combine multiple sequences, e.g. \fB1,3,5,7,10:20\fR. Using * selects the last mail in the mailbox.
.P
For example 1:100 matches the first 100 mails and 101:200 the next second hundred mails. 1,5,* matches the first, the fifth and the last email.
.P
Use \fBUID\fR (see below) to search by unique ID.
.RE 0

.RE 0

.P
\fBALL\fR
.RS 0
.RS 4
.P
Matches all messages.
.RE 0

.RE 0

.P
\fBANSWERED\fR
.RS 0
.RS 4
.P
Matches messages with the IMAP flag \[rs]Answered set.
.RE 0

.RE 0

.P
\fBBCC\fR \fIstring\fR
.RS 0
.RS 4
.P
Matches messages, which contain \fIstring\fR in the BCC field of the message's IMAP envelope structure.
.RE 0

.RE 0

.P
\fBBEFORE\fR \fIdate specification\fR
.RS 0
.RS 4
.P
Matches messages with an internal date before \fIdate specification\fR.
.RE 0

.RE 0

.P
\fBBODY\fR \fIstring\fR
.RS 0
.RS 4
.P
Matches messages, which contain \fIstring\fR in the body part.
.RE 0

.RE 0

.P
\fBCC\fR \fIstring\fR
.RS 0
.RS 4
.P
Matches messages, which contain \fIstring\fR in the CC field of the message's IMAP envelope structure.
.RE 0

.RE 0

.P
\fBDELETED\fR
.RS 0
.RS 4
.P
Matches messages with the IMAP flag \[rs]Deleted set.
.RE 0

.RE 0

.P
\fBDRAFT\fR
.RS 0
.RS 4
.P
Matches messages with the IMAP flag \[rs]Draft set.
.RE 0

.RE 0

.P
\fBFLAGGED\fR
.RS 0
.RS 4
.P
Matches messages with the IMAP flag \[rs]Flagged set.
.RE 0

.RE 0

.P
\fBFROM\fR \fIstring\fR
.RS 0
.RS 4
.P
Matches messages, which contain \fIstring\fR in the FROM field of the message's IMAP envelope structure.
.RE 0

.RE 0

.P
\fBHEADER\fR \fIfield\fR \fIstring\fR
.RS 0
.RS 4
.P
Matches messages, which either have the named header \fIfield\fR, when empty \fIstring\fR was given. Or messages, where the given header \fIfield\fR's value contains the specified \fIstring\fR.
.RE 0

.RE 0

.P
\fBKEYWORD\fR \fIkeyword\fR
.RS 0
.RS 4
.P
Matches messages with the given IMAP \fIkeyword\fR (e.g. $Forwarded) flag set.
.RE 0

.RE 0

.P
\fBLARGER\fR \fIsize\fR
.RS 0
.RS 4
.P
Matches messages that are larger than the specified \fIsize\fR.
.RE 0

.RE 0

.P
\fBMAILBOX\fR \fIname\fR
.RS 0
.RS 4
.P
Matches messages in the mailbox with the specified \fIname\fR.
.RE 0

.RE 0

.P
\fBMAILBOX-GUID\fR \fIguid\fR
.RS 0
.RS 4
.P
Matches messages in the mailbox with the specified \fIguid\fR.
.RE 0

.RE 0

.P
\fBNEW\fR
.RS 0
.RS 4
.P
Matches messages, which have the IMAP flag \[rs]Recent set \fBbut not\fR the IMAP flag \[rs]Seen.
.RE 0

.RE 0

.P
\fBNOT\fR \fIsearch key\fR
.RS 0
.RS 4
.P
Inverse matching - matches massages, where the search doesn't match the specified \fIsearch key\fR or its value.
.RE 0

.RE 0

.P
\fBOLD\fR
.RS 0
.RS 4
.P
Matches messages, which do not have the IMAP flag \[rs]Recent set.
.RE 0

.RE 0

.P
\fBON\fR \fIdate specification\fR
.RS 0
.RS 4
.P
Matches messages whose internal date matches the given \fIdate specification\fR.
.RE 0

.RE 0

.P
\fIsearch key\fR \fBOR\fR \fIsearch key\fR
.RS 0
.RS 4
.P
Matches messages where one of the OR-ed search keys matches.
.P
Note: IMAP4rev1 uses the syntax: \fBOR\fR \fIsearch key search key\fR
.RE 0

.RE 0

.P
\fBRECENT\fR
.RS 0
.RS 4
.P
Matches messages with the IMAP flag \[rs]Recent set.
.RE 0

.RE 0

.P
\fBSEEN\fR
.RS 0
.RS 4
.P
Matches messages with the IMAP flag \[rs]Seen set.
.RE 0

.RE 0

.P
\fBSENTBEFORE\fR \fIdate specification\fR
.RS 0
.RS 4
.P
Matches messages with a Date: header before \fIdate specification\fR.
.RE 0

.RE 0

.P
\fBSENTON\fR \fIdate specification\fR
.RS 0
.RS 4
.P
Matches messages with a Date: header matching the given \fIdate specification\fR.
.RE 0

.RE 0

.P
\fBSENTSINCE\fR \fIdate specification\fR
.RS 0
.RS 4
.P
Matches messages with a Date: header matching or after the given \fIdate specification\fR.
.RE 0

.RE 0

.P
\fBSINCE\fR \fIdate specification\fR
.RS 0
.RS 4
.P
Matches messages whose internal date is within or after the given \fIdate specification\fR.
.RE 0

.RE 0

.P
\fBSMALLER\fR \fIsize\fR
.RS 0
.RS 4
.P
Matches messages with a size smaller than the given \fIsize\fR.
.RE 0

.RE 0

.P
\fBSUBJECT\fR \fIstring\fR
.RS 0
.RS 4
.P
Matches messages, which contain \fIstring\fR in the SUBJECT field of the message's IMAP envelope structure.
.RE 0

.RE 0

.P
\fBTEXT\fR \fIstring\fR
.RS 0
.RS 4
.P
Matches messages, which contain \fIstring\fR in the message headers or body.
.RE 0

.RE 0

.P
\fBTO\fR \fIstring\fR
.RS 0
.RS 4
.P
Matches messages, which contain \fIstring\fR in the TO field of the message's IMAP envelope structure.
.RE 0

.RE 0

.P
\fBUID\fR \fIsequence-set\fR
.RS 0
.RS 4
.P
Matches messages with the given IMAP UID(s). See the \fBsequence-set\fR description for details on it. For example \fB1:10,100:200,\fR* matches the UIDs from 1 to 10, 100 to 200 and also the last mail.
.RE 0

.RE 0

.P
\fBUNANSWERED\fR
.RS 0
.RS 4
.P
Matches messages, which do not have the IMAP flag \[rs]Answered set.
.RE 0

.RE 0

.P
\fBUNDELETED\fR
.RS 0
.RS 4
.P
Matches messages, which do not have the IMAP flag \[rs]Deleted set.
.RE 0

.RE 0

.P
\fBUNDRAFT\fR
.RS 0
.RS 4
.P
Matches messages, which do not have the IMAP flag \[rs]Draft set.
.RE 0

.RE 0

.P
\fBUNFLAGGED\fR
.RS 0
.RS 4
.P
Matches messages, which do not have the IMAP flag \[rs]Flagged set.
.RE 0

.RE 0

.P
\fBUNKEYWORD\fR \fIkeyword\fR
.RS 0
.RS 4
.P
Matches messages, which do not have the given IMAP \fIkeyword\fR flag set
.RE 0

.RE 0

.P
\fBUNSEEN\fR
.RS 0
.RS 4
.P
Matches messages, which do not have the IMAP flag \[rs]Seen set.
.RE 0

.RE 0

.SH "DOVEADM SEARCH KEYS"
.P
Additional search keys, provided by doveadm(1).
.P
\fBSAVEDBEFORE\fR \fIdate specification\fR
.RS 0
.RS 4
.P
Matches messages, which were saved before \fIdate specification\fR.
.RE 0

.RE 0

.P
\fBSAVEDON\fR \fIdate specification\fR
.RS 0
.RS 4
.P
Matches messages whose save date matches the given \fIdate specification\fR.
.RE 0

.RE 0

.P
\fBSAVEDSINCE\fR \fIdate specification\fR
.RS 0
.RS 4
.P
Matches messages with a save date matching or after the given \fIdate specification\fR.
.RE 0

.RE 0

.SH "DATE SPECIFICATION"
.P
doveadm(1) supports a few additional \fIdate specification\fR formats. They can be used anywhere, where a \fIdate specification\fR value is obligatory.
.P
\fIdd-mon-yyyy\fR
.RS 0
.RS 4
.P
Default IMAP4rev1 date format.
.P
Date components:
.RS 4
.P
\fIday\fR : the day of month: \fB1\fR-\fB31\fR.
.RE 0

.RS 4
.P
\fImonth\fR : the abbreviated month name: \fBJan\fR, \fBFeb\fR, \fBMar\fR, \fBApr\fR, \fBMay\fR, \fBJun\fR, \fBJul\fR, \fBAug\fR, \fBSep\fR, \fBOct\fR, \fBNov\fR, or \fBDec\fR.
.RE 0

.RS 4
.P
\fIyear\fR : four digits of year, e.g. \fB2007\fR.
.RE 0

.P
For example the "13th of April 2007" will be represented as \fB13-Apr-2007\fR.
.RE 0

.RE 0

.P
\fIdd-mon-yyyy hh:mm:ss \[lB]+-\[rB]zzzz\fR
.RS 0
.RS 4
.P
Default IMAP4rev1 date-time format. See \fIdd-mon-yyyy\fR above for the date format.
.P
Time format components:
.RS 4
.P
\fIhh\fR : the hour
.RE 0

.RS 4
.P
\fImm\fR : the minute
.RE 0

.RS 4
.P
\fIss\fR : the second
.RE 0

.RS 4
.P
\fI\[lB]+-\[rB]zzzz\fR : the timezone as hhmm, e.g. \fB+0530\fR, \fB-0700\fR
.RE 0

.RE 0

.RE 0

.P
\fIinterval\fR
.RS 0
.RS 4
.P
Combination of a positive integer \fInumber\fR and a \fItime unit\fR.
.P
Available \fItime units\fR are:
.RS 4
.P
\fBweeks\fR : abbreviated: \fBw\fR
.RE 0

.RS 4
.P
\fBdays\fR : abbreviated: \fBd\fR
.RE 0

.RS 4
.P
\fBhours\fR : abbreviated: \fBh\fR
.RE 0

.RS 4
.P
\fBmins\fR : abbreviated: \fBm\fR
.RE 0

.RS 4
.P
\fBsecs\fR : abbreviated: \fBs\fR
.RE 0

.P
To match messages from last week, you may specify for example: \fBsince 1w\fR, \fBsince 1weeks\fR or \fBsince 7days\fR.
.RE 0

.RE 0

.P
\fIUnix timestamp\fR
.RS 0
.RS 4
.P
A 10 digit Unix timestamp, seconds since the 1st of January 1970, 00:00:00 UTC. For example the "13th of April 2007" will be represented as \fB1176418800\fR.
.RE 0

.RE 0

.P
\fIYYYY-MM-DD\fR
.RS 0
.RS 4
.P
Extended ISO-8601 calendar date format. For example the "13th of April 2007" will be represented as \fB2007-04-13\fR.
.RE 0

.RE 0

.SH "SIZE"
.P
doveadm(1) provides also an additional \fIsize\fR representation format. The following formats can be used anywhere, where a \fIsize\fR value is obligatory.
.P
\fIoctets\fR
.RS 0
.RS 4
.P
The message size in octets, as specified in the IMAP4rev1 specification.
.RE 0

.RE 0

.P
\fIsize\fR
.RS 0
.RS 4
.P
The message size in \fBB\fR (byte), \fBk\fR (kilobyte), \fBM\fR (megabyte), \fBG\fR (gigabyte) or \fBT\fR (terabyte). To match messages, bigger than 1 megabyte, you may specify for example: \fBlarger 1M\fR or \fBlarger 1024k\fR.
.RE 0

.RE 0

.SH "REPORTING BUGS"
.P
Report bugs, including \fIdoveconf -n\fR output, to the Dovecot Mailing List \fI\(ladovecot@dovecot.org\(ra\fR. Information about reporting bugs is available at: \fI\(lahttps://dovecot.org/bugreport.html\(ra\fR
.SH "SEE ALSO"
.P
doveadm(1)