DESCRIPTION

Several doveadm(1) commands use a search_query in order to act only on matching messages. This manual page describes all SEARCHKEYS, which can be used in a search_query.

Each search_query consists at least of one SEARCHKEY. Most of the SEARCH KEYS require an argument. All SEARCH KEYS are case-insensitive. The shortest valid search_query is ALL. For example:

doveadm search ALL

Multiple search query expressions will be combined with the AND operator by default. To find all messages that are new and greater than 50 kilobyte, one can use:

doveadm search NEW LARGER 50k

OR-ed SEARCH KEYS 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 \(rsSeen and/or \(rsFlagged flag set, one can use for example:

doveadm search SAVEDON 2007-04-13 \(rs( SEEN OR FLAGGED \(rs)

It's also possible to specify the mailbox, in which should be searched. Use either the keyword mailbox and the name of the mailbox or the keyword mailbox-guid and the mailbox's globally unique identifier in the search_query. To find all messages in the mailbox with the GUID "44f68b13ce97044b837f000035ca9452" use:

doveadm search mailbox-guid 44f68b13ce97044b837f000035ca9452 ALL

To list all deleted messages in the "Trash" folder use:

doveadm search mailbox Trash DELETED

SEARCH KEYS

The following search keys from the specification of IMAP version 4 revision 1 (see: RFC 3501, section 6.4.4) are supported:

ALL

Matches all messages.

ANSWERED

Matches messages with the IMAP flag \(rsAnswered set.

BCCpattern

Matches messages, which contain pattern in the BCC field of the message's IMAP envelope structure.

BEFOREdatespecification

Matches messages with an internal date before datespecification.

BODYpattern

Matches messages, which contain pattern in the body part.

CCpattern

Matches messages, which contain pattern in the CC field of the message's IMAP envelope structure.

DELETED

Matches messages with the IMAP flag \(rsDeleted set.

DRAFT

Matches messages with the IMAP flag \(rsDraft set.

FLAGGED

Matches messages with the IMAP flag \(rsFlagged set.

FROMpattern

Matches messages, which contain pattern in the FROM field of the message's IMAP envelope structure.

HEADER field pattern

Matches messages, which either have the named header field, when empty pattern was given. Or messages, where the given header field's value contains the specified pattern.

KEYWORDkeyword

Matches messages with the given IMAP keyword (e.g. \(DoForwarded) flag set.

LARGERsize

Matches messages that are larger than the specified size.

MAILBOXname

Matches messages in the mailbox with the specified name.

MAILBOX-GUIDguid

Matches messages in the mailbox with the specified guid.

NEW

Matches messages, which have the IMAP flag \(rsRecent set but not the IMAP flag \(rsSeen.

NOTsearchkey

Inverse matching - matches massages, where the search doesn't match the specified search key or its value.

OLD

Matches messages, which do not have the IMAP flag \(rsRecent set.

ONdatespecification

Matches messages whose internal date matches the given datespecification.

searchkeyORsearchkey

Matches messages where one of the OR-ed search keys matches.

Note: IMAP4rev1 uses the syntax: ORsearchkeysearchkey

RECENT

Matches messages with the IMAP flag \(rsRecent set.

SEEN

Matches messages with the IMAP flag \(rsSeen set.

SENTBEFOREdatespecification

Matches messages with a Date: header before datespecification.

SENTONdatespecification

Matches messages with a Date: header matching the given datespecification.

SENTSINCEdatespecification

Matches messages with a Date: header matching or after the given datespecification.

SINCEdatespecification

Matches messages whose internal date is within or after the given datespecification.

SMALLERsize

Matches messages with a size smaller than the given size.

SUBJECTpattern

Matches messages, which contain pattern in the SUBJECT field of the message's IMAP envelope structure.

TEXTpattern

Matches messages, which contain pattern in the message body.

TOpattern

Matches messages, which contain pattern in the TO field of the message's IMAP envelope structure.

UIDsequence

Matches messages with the given UID(s). A sequence may be a single UID. Can be a sequence range, written as from:to, e.g.100:125. As comma separated list of UIDs, e.g. 11,50,4. It's also possible to combine multiple sequences, e.g. 1,3,5,7,10:20.

UNANSWERED

Matches messages, which do not have the IMAP flag \(rsAnswered set.

UNDELETED

Matches messages, which do not have the IMAP flag \(rsDeleted set.

UNDRAFT

Matches messages, which do not have the IMAP flag \(rsDraft set.

UNFLAGGED

Matches messages, which do not have the IMAP flag \(rsFlagged set.

UNKEYWORDkeyword

Matches messages, which do not have the given IMAP keyword flag set

UNSEEN

Matches messages, which do not have the IMAP flag \(rsSeen set.

DOVEADM SEARCH KEYS

Additional search keys, provided by doveadm(1).

SAVEDBEFOREdatespecification

Matches messages, which were saved before datespecification.

SAVEDONdatespecification

Matches messages whose save date matches the given datespecification.

SAVEDSINCEdatespecification

Matches messages with a save date matching or after the given datespecification.

DATE SPECIFICATION

doveadm(1) supports a few additional date specification formats. They can be used anywhere, where a date specification value is obligatory.

day-month-year

Default IMAP4rev1 date format.

day, the day of month: 1-31.

month, the abbreviated month name: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Novor Dec.

year, four digits of year, e.g. 2007.

For example the "13th of April 2007" will be represented as 13-Apr-2007.

interval

Combination of a positive integer number and a timeunit.

Available time units are: weeks (abbr: w), days (abbr: d), hours (abbr: h), mins (abbr: m) and secs (abbr: s).

To match messages from last week, you may specify for example: since1w, since1weeksor since7days.

Unix timestamp

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 1176418800.

YYYY-MM-DD

Extended ISO-8601 calendar date format. For example the "13th of April 2007" will be represented as 2007-04-13.

SIZE

doveadm(1) provides also an additional size representation format. The following formats can be used anywhere, where a size value is obligatory.

octets

The message size in octets, as specified in the IMAP4rev1 specification.

size

The message size in B(byte), k(kilobyte), M(megabyte), G(gigabyte)or T(terabyte).

To match messages, bigger than 1 megabyte, you may specify for example: larger1Mor larger1024k.

RELATED TO doveadm-search-query…