Search Functions

Quick Search

On the mailbox screen, you can quickly search for messages whose 'subject' or 'from' address ('to' address in the Sent Items folder) contains a particular string by entering the string into the search text box and clicking 'search'.

By default, it will search the current folder. To search all folders, click the "All" checkbox.

Advanced Search

To perform an advanced search, click the 'Advanced' link, this will take you to the advanced search screen. Enter your search criteria in the fields provided. Click the 'Search' button to return to the Mailbox screen and perform the search.

Enhanced search syntax

Instead of using the advanced search screen, you can also build advanced searches using a special syntax in the standard search box on the Mailbox screen. This is done by using special keywords, boolean flags and operators to combine multiple options together.

Keywords

The possible keywords are:

  • from:<phrase>
  • to:<phrase> (really both to/cc)
  • subject:<phrase>
  • body:<phrase>
  • flag:<flag name>
  • since|after|newer:<date spec>
  • before|older:<date spec>
  • date:<date spec>
  • smaller|maxsize:<size spec>
  • bigger|larger|minsize:<size spec>
  • msgid:<id>
  • header:"headername: phrase"
  • imap:<raw imap search>

Phrases are matched on a "contains" basis. Currently that means even partial words or within words will match. eg from:ber will match an email from "Robert" because "ber" is contained in "Robert".

Date spec can be quite flexible, either a particular date (e.g. date:"30 sep 2010") or a relative date (e.g. date:"2 weeks ago"). Internally it uses perl's Date::Manip module.

If you want a phrase with spaces in it, use quotes (either ' or ", but matched) for the phrase part, e.g. from:"Joe Citizen" or subject:'string with "double" quotes', but not "from:Joe Citizen" or subject:"must end with same'. You can also use \", \' and \\ to match a literal ", ' and \ respectively in a phrase.

Size is specified in bytes with optional suffix (k, m, g) - e.g. minsize:100k

Header is specified with a quote, e.g. header:"List-Id: cyrus-devel"

Booleans

These match messages that match a particular state (eg. read or unread or flagged or ...). These must all be specified in UPPERCASE to distinguish them from normal search words.

  • SEEN | READ
  • UNSEEN | UNREAD
  • FLAGGED
  • UNFLAGGED
  • REPLIED | ANSWERED
  • UNREPLIED | UNANSWERED
  • HASATT (only works for messages that have been displayed in the webui)
  • HASNOATT | NOATT (only works for messages that have been displayed in the webui)
  • SELECTED
  • UNSELECTED
  • DRAFT
  • UNDRAFT

For example, UNSEEN HASATT will show all unread messages with attachments.

Operators

Operators must also be uppercase

  • AND - doesn't do anything, since this is the default when multiple keywords/booleans are specified
  • OR - e.g. from:rob OR from:jeremy. Applies just to the terms on either side.
  • NOT - applies just to the term afterwards, e.g. has Rob emailed me about anything else this week? since:"1 week ago" from:rob NOT subject:"new web interface"
  • () - grouping, e.g. (from:rob subject:"new web interface") OR subject:urgent

Saving Searches

Enter the search criteria you want on the Advanced search screen, then enter a name you want to give the search in the "Save search" section. Click the "Save" button to store the search. You can then access this saved search from the Advanced screen in the future, or you can access it quickly from the Mailbox screen in the list under the search box (click the "Show saved" link if they're not visible).

Custom Criteria

A value in "Custom" is passed directly to the IMAP server. See the IMAP specification for full details. Here is a quick reference of the commands (thanks to forum user Sanjay Sheth for compiling this):

ALL

All messages in the mailbox; the default initial key for ANDing.

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 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 and that contains the specified string in the field-body.

KEYWORD <flag>

Messages with the specified keyword set.

LARGER <n>

Messages with an 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. Eg: NOT BODY "cat"

OLD

Messages that do not have the \Recent flag set. This is functionally equivalent to "NOT RECENT" (as opposed to "NOT NEW").

ON <date>

Messages whose internal date is within the specified date.

OR <search-key1> <search-key2>

Messages that match either search key. Eg: OR BODY "cat" BODY "dog"

RECENT

Messages that have the \Recent flag set.

SEEN

Messages that have the \Seen flag set.

SENTBEFORE <date>

Messages whose Date: header is earlier than the specified date.

SENTON <date>

Messages whose Date: header is within the specified date.

SENTSINCE <date>

Messages whose Date: header is within or later than the specified date.

SINCE <date>

Messages whose internal date is within or later than the specified date.

SMALLER <n>

Messages with an size smaller than the specified number 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 <message set>

Messages with unique identifiers corresponding to the specified unique identifier set.

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

UNSEEN

Messages that do not have the \Seen flag set.