chainmail search
Search mail with Gmail-style operators. Terms are joined by AND, -term negates, OR joins (it binds tighter than AND, as in Gmail), parentheses group, and values with spaces are quoted.
word, "a phrase" text anywhere in the message
from: to: cc: bcc: address or display name contains
subject: subject contains
is:unread is:read is:starred
newer_than: older_than: days, weeks, months or years: 7d, 2w, 3m, 1y
after: before: YYYY-MM-DD
larger: smaller: bytes, or KiB and MiB: 10K, 5M
has:attachment filename: label:
Google accounts, and other accounts once
their cache is complete (see chainmail
cache status); label: there matches IMAP
keywords
in: inbox, sent, drafts, archive, trash, spam
(or junk), anywhere, or a folder name
account: this account; each account: term and each
--account adds one
item: mail in threads linked to this item or any
item below it; item:none, mail in threads
linked to no item. Only the cache answers
these, never the mail server
Every folder except Trash and Spam is searched unless in: says otherwise. On accounts other than Google, dates work at day granularity on the arrival date, so newer_than:1d there matches since the start of yesterday.
Each account is answered from the local cache when the cache can answer the whole query and is fresh, and by its mail server otherwise. The table output ends with a source line naming which answered each account. --source cache answers from the cache even when it is incomplete or stale, and says why; --source server skips the cache.
The shell removes quotes, so quote the whole query when it holds a phrase or a quoted value, as in the second example below. Put -- before the query when a term starts with -, so it is not read as a flag:
chainmail search -- invoice -from:acme
Usage
chainmail search [query...] [flags]
Examples
chainmail search invoice from:acme newer_than:30d
chainmail search 'subject:"q3 report" OR has:attachment' --account gmail
chainmail search is:unread in:inbox --count
chainmail search from:acme --source server
Flags
--account stringArray only this account (repeatable)
--count count matches instead of listing them
--cursor string continue from the previous page's cursor
--limit uint32 rows per page, at most 500 (default 50)
--snippet add a snippet of up to 200 characters to each row
--source string where answers come from: auto, cache or server (default auto: the cache when it is complete and fresh)
--threads show the newest message of each thread
Global flags
--output string output format: json or table (default $CHAINMAIL_OUTPUT, then cli.toml, then table on a terminal, json otherwise)
--socket string daemon socket (default $CHAINMAIL_SOCKET, then cli.toml, then /run/chainmail/chainmail.sock)