1 .\" notmuch - Not much of an email program, (just index, search and tagging)
3 .\" Copyright © 2009 Carl Worth
5 .\" Notmuch is free software: you can redistribute it and/or modify
6 .\" it under the terms of the GNU General Public License as published by
7 .\" the Free Software Foundation, either version 3 of the License, or
8 .\" (at your option) any later version.
10 .\" Notmuch is distributed in the hope that it will be useful,
11 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
12 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 .\" GNU General Public License for more details.
15 .\" You should have received a copy of the GNU General Public License
16 .\" along with this program. If not, see http://www.gnu.org/licenses/ .
18 .\" Author: Carl Worth <cworth@cworth.org>
19 .TH NOTMUCH 1 2011-11-23 "Notmuch 0.10"
21 notmuch \- thread-based email index, search, and tagging
24 .IR command " [" args " ...]"
26 Notmuch is a command-line based program for indexing, searching,
27 reading, and tagging large collections of email messages.
29 The quickest way to get started with Notmuch is to simply invoke the
31 command with no arguments, which will interactively guide you through
32 the process of indexing your mail.
34 While the command-line program
36 provides powerful functionality, it does not provide the most
37 convenient interface for that functionality. More sophisticated
38 interfaces are expected to be built on top of either the command-line
39 interface, or more likely, on top of the notmuch library
40 interface. See http://notmuchmail.org for more about alternate
41 interfaces to notmuch.
45 command is used to configure Notmuch for first use, (or to reconfigure
51 Interactively sets up notmuch for first use.
53 The setup command will prompt for your full name, your primary email
54 address, any alternate email addresses you use, and the directory
55 containing your email archives. Your answers will be written to a
56 configuration file in ${NOTMUCH_CONFIG} (if set) or
57 ${HOME}/.notmuch-config . This configuration file will be created with
58 descriptive comments, making it easy to edit by hand later to change the
59 configuration. Or you can run
61 again to change the configuration.
63 The mail directory you specify can contain any number of
64 sub-directories and should primarily contain only files with individual
65 email messages (eg. maildir or mh archives are perfect). If there are
66 other, non-email files (such as indexes maintained by other email
67 programs) then notmuch will do its best to detect those and ignore
70 Mail storage that uses mbox format, (where one mbox file contains many
71 messages), will not work with notmuch. If that's how your mail is
72 currently stored, it is recommended you first convert it to maildir
73 format with a utility such as mb2md before running
78 with no command argument will run
80 if the setup command has not previously been completed.
85 command is used to incorporate new mail into the notmuch database.
90 Find and import any new messages to the database.
94 command scans all sub-directories of the database, performing
95 full-text indexing on new messages that are found. Each new message
96 will automatically be tagged with both the
97 .BR inbox " and " unread
102 once after first running
104 to create the initial database. The first run may take a long time if
105 you have a significant amount of mail (several hundred thousand
106 messages or more). Subsequently, you should run
108 whenever new mail is delivered and you wish to incorporate it into the
109 database. These subsequent runs will be much quicker than the initial
114 with no command argument will run
118 has previously been completed, but
120 has not previously been run.
123 Several of the notmuch commands accept search terms with a common
126 section below for more details on the supported syntax.
129 .BR search ", " show " and " count
130 commands are used to query the email database.
133 .BR search " [options...] <search-term>..."
135 Search for messages matching the given search terms, and display as
136 results the threads containing the matched messages.
138 The output consists of one line per thread, giving a thread ID, the
139 date of the newest (or oldest, depending on the sort option) matched
140 message in the thread, the number of matched messages and total
141 messages in the thread, the names of all participants in the thread,
142 and the subject of the newest (or oldest) message.
144 Supported options for
149 .BR \-\-format= ( json | text )
151 Presents the results in either JSON or plain-text (default).
156 .B \-\-output=(summary|threads|messages|files|tags)
162 Output a summary of each thread with any message matching the search
163 terms. The summary includes the thread ID, date, the number of
164 messages in the thread (both the number matched and the total number),
165 the authors of the thread and the subject.
171 Output the thread IDs of all threads with any message matching the
172 search terms, either one per line (\-\-format=text) or as a JSON array
179 Output the message IDs of all messages matching the search terms,
180 either one per line (\-\-format=text) or as a JSON array
187 Output the filenames of all messages matching the search terms, either
188 one per line (\-\-format=text) or as a JSON array (\-\-format=json).
194 Output all tags that appear on any message matching the search terms,
195 either one per line (\-\-format=text) or as a JSON array
202 .BR \-\-sort= ( newest\-first | oldest\-first )
204 This option can be used to present results in either chronological order
205 .RB ( oldest\-first )
206 or reverse chronological order
207 .RB ( newest\-first ).
209 Note: The thread order will be distinct between these two options
210 (beyond being simply reversed). When sorting by
212 the threads will be sorted by the oldest message in each thread, but
215 the threads will be sorted by the newest message in each thread.
217 By default, results will be displayed in reverse chronological order,
218 (that is, the newest results will be displayed first).
225 Skip displaying the first N results. With the leading '\-', start at the Nth
233 Limit the number of displayed results to N.
239 section below for details of the supported syntax for <search-terms>.
242 .BR show " [options...] <search-term>..."
244 Shows all messages matching the search terms.
246 The messages will be grouped and sorted based on the threading (all
247 replies to a particular message will appear immediately after that
248 message in date order). The output is not indented by default, but
249 depth tags are printed so that proper indentation can be performed by
250 a post-processor (such as the emacs interface to notmuch).
252 Supported options for
257 .B \-\-entire\-thread
259 By default only those messages that match the search terms will be
260 displayed. With this option, all messages in the same thread as any
261 matched message will be displayed.
266 .B \-\-format=(text|json|mbox|raw)
270 .BR text " (default for messages)"
272 The default plain-text format has all text-content MIME parts
273 decoded. Various components in the output,
274 .RB ( message ", " header ", " body ", " attachment ", and MIME " part ),
275 will be delimited by easily-parsed markers. Each marker consists of a
276 Control-L character (ASCII decimal 12), the name of the marker, and
277 then either an opening or closing brace, ('{' or '}'), to either open
278 or close the component. For a multipart MIME message, these parts will
285 The output is formatted with Javascript Object Notation (JSON). This
286 format is more robust than the text format for automated
287 processing. The nested structure of multipart MIME messages is
288 reflected in nested JSON output. JSON output always includes all
289 messages in a matching thread; in effect
292 .B \-\-entire\-thread
299 All matching messages are output in the traditional, Unix mbox format
300 with each message being prefixed by a line beginning with "From " and
301 a blank line separating each message. Lines in the message content
302 beginning with "From " (preceded by zero or more '>' characters) have
303 an additional '>' character added. This reversible escaping
304 is termed "mboxrd" format and described in detail here:
308 http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/mail-mbox-formats.html
315 .BR raw " (default for a single part, see \-\-part)"
317 For a message, the original, raw content of the email message is
318 output. Consumers of this format should expect to implement MIME
319 decoding and similar functions.
321 For a single part (\-\-part) the raw part content is output after
322 performing any necessary MIME decoding.
324 The raw format must only be used with search terms matching single
333 Output the single decoded MIME part N of a single message. The search
334 terms must match only a single message. Message parts are numbered in
335 a depth-first walk of the message MIME structure, and are identified
336 in the 'json' or 'text' output formats.
343 Compute and report the validity of any MIME cryptographic signatures
344 found in the selected content (ie. "multipart/signed" parts). Status
345 of the signature will be reported (currently only supported with
346 --format=json), and the multipart/signed part will be replaced by the
354 Decrypt any MIME encrypted parts found in the selected content
355 (ie. "multipart/encrypted" parts). Status of the decryption will be
356 reported (currently only supported with --format=json) and the
357 multipart/encrypted part will be replaced by the decrypted
363 is to display a single thread of email messages. For this, use a
364 search term of "thread:<thread-id>" as can be seen in the first
365 column of output from the
371 section below for details of the supported syntax for <search-terms>.
375 .BR count " [options...] <search-term>..."
377 Count messages matching the search terms.
379 The number of matching messages (or threads) is output to stdout.
381 With no search terms, a count of all messages (or threads) in the database will
384 Supported options for
389 .B \-\-output=(messages|threads)
395 Output the number of matching messages. This is the default.
401 Output the number of matching threads.
409 command is useful for preparing a template for an email reply.
412 .BR reply " [options...] <search-term>..."
414 Constructs a reply template for a set of messages.
416 To make replying to email easier,
418 takes an existing set of messages and constructs a suitable mail
419 template. The Reply-to header (if any, otherwise From:) is used for
420 the To: address. Vales from the To: and Cc: headers are copied, but
421 not including any of the current user's email addresses (as configured
422 in primary_mail or other_email in the .notmuch\-config file) in the
425 It also builds a suitable new subject, including Re: at the front (if
426 not already present), and adding the message IDs of the messages being
427 replied to to the References list and setting the In\-Reply\-To: field
430 Finally, the original contents of the emails are quoted by prefixing
431 each line with '> ' and included in the body.
433 The resulting message template is output to stdout.
435 Supported options for
440 .BR \-\-format= ( default | headers\-only )
444 Includes subject and quoted message body.
447 Only produces In\-Reply\-To, References, To, Cc, and Bcc headers.
452 section below for details of the supported syntax for <search-terms>.
454 Note: It is most common to use
456 with a search string matching a single message, (such as
457 id:<message-id>), but it can be useful to reply to several messages at
458 once. For example, when a series of patches are sent in a single
459 thread, replying to the entire thread allows for the reply to comment
460 on issue found in multiple patches.
466 command is the only command available for manipulating database
471 .BR tag " +<tag>|\-<tag> [...] [\-\-] <search-term>..."
473 Add/remove tags for all messages matching the search terms.
475 Tags prefixed by '+' are added while those prefixed by '\-' are
476 removed. For each message, tag removal is performed before tag
479 The beginning of <search-terms> is recognized by the first
480 argument that begins with neither '+' nor '\-'. Support for
481 an initial search term beginning with '+' or '\-' is provided
482 by allowing the user to specify a "\-\-" argument to separate
483 the tags from the search terms.
487 section below for details of the supported syntax for <search-terms>.
491 .BR dump " and " restore
492 commands can be used to create a textual dump of email tags for backup
493 purposes, and to restore from that dump.
497 .BR dump " [<filename>] [--] [<search-terms>]"
499 Creates a plain-text dump of the tags of each message.
501 Output is to the given filename, if any, or to stdout. Note that
502 using the filename argument is deprecated.
504 These tags are the only data in the notmuch database that can't be
505 recreated from the messages themselves. The output of notmuch dump is
506 therefore the only critical thing to backup (and much more friendly to
507 incremental backup than the native database files.)
509 With no search terms, a dump of all messages in the database will be
510 generated. A "--" argument instructs notmuch that the
511 remaining arguments are search terms.
515 section below for details of the supported syntax for <search-terms>.
519 .BR restore " [--accumulate] [<filename>]"
521 Restores the tags from the given file (see
522 .BR "notmuch dump" ")."
524 The input is read from the given filename, if any, or from stdin.
526 Note: The dump file format is specifically chosen to be
527 compatible with the format of files produced by sup-dump.
528 So if you've previously been using sup for mail, then the
530 command provides you a way to import all of your tags (or labels as
533 The --accumulate switch causes the union of the existing and new tags to be
534 applied, instead of replacing each message's tags as they are read in from the
540 command can used to output a single part of a multipart MIME message.
544 .BR part " \-\-part=<part-number> <search-term>..."
546 Output a single MIME part of a message.
548 A single decoded MIME part, with no encoding or framing, is output to
549 stdout. The search terms must match only a single message, otherwise
550 this command will fail.
552 The part number should match the part "id" field output by the
553 "\-\-format=json" option of "notmuch show". If the message specified by
554 the search terms does not include a part with the specified "id" there
559 section below for details of the supported syntax for <search-terms>.
564 command can be used to get or set settings int the notmuch
569 .BR "config get " <section> . <item>
571 The value of the specified configuration item is printed to stdout. If
572 the item has multiple values, each value is separated by a newline
575 Available configuration items include at least
590 .BR "config set " <section> . "<item> [values ...]"
592 The specified configuration item is set to the given value. To
593 specify a multiple-value item, provide each value as a separate
594 command-line argument.
596 If no values are provided, the specified configuration item will be
597 removed from the configuration file.
601 Several notmuch commands accept a common syntax for search terms.
603 The search terms can consist of free-form text (and quoted phrases)
604 which will match all messages that contain all of the given
605 terms/phrases in the body, the subject, or any of the sender or
608 As a special case, a search string consisting of exactly a single
609 asterisk ("*") will match all messages.
611 In addition to free text, the following prefixes can be used to force
612 terms to match against specific portions of an email, (where
613 <brackets> indicate user-supplied values):
615 from:<name-or-address>
619 subject:<word-or-quoted-phrase>
623 tag:<tag> (or is:<tag>)
629 folder:<directory-path>
633 prefix is used to match the name or address of the sender of an email
638 prefix is used to match the names or addresses of any recipient of an
639 email message, (whether To, Cc, or Bcc).
641 Any term prefixed with
643 will match only text from the subject of an email. Searching for a
644 phrase in the subject is supported by including quotation marks around
645 the phrase, immediately following
650 prefix can be used to search for specific filenames (or extensions) of
651 attachments to email messages.
655 valid tag values include
656 .BR inbox " and " unread
657 by default for new messages added by
659 as well as any other tag values added manually with
664 message ID values are the literal contents of the Message\-ID: header
665 of email messages, but without the '<', '>' delimiters.
669 prefix can be used with the thread ID values that are generated
670 internally by notmuch (and do not appear in email messages). These
671 thread ID values can be seen in the first column of output from
676 prefix can be used to search for email message files that are
677 contained within particular directories within the mail store. Only
678 the directory components below the top-level mail database path are
679 available to be searched.
681 In addition to individual terms, multiple terms can be
682 combined with Boolean operators (
683 .BR and ", " or ", " not
684 , etc.). Each term in the query will be implicitly connected by a
685 logical AND if no explicit operator is provided, (except that terms
686 with a common prefix will be implicitly combined with OR until we get
687 Xapian defect #402 fixed).
689 Parentheses can also be used to control the combination of the Boolean
690 operators, but will have to be protected from interpretation by the
691 shell, (such as by putting quotation marks around any parenthesized
694 Finally, results can be restricted to only messages within a
695 particular time range, (based on the Date: header) with a syntax of:
697 <initial-timestamp>..<final-timestamp>
699 Each timestamp is a number representing the number of seconds since
700 1970\-01\-01 00:00:00 UTC. This is not the most convenient means of
701 expressing date ranges, but until notmuch is fixed to accept a more
702 convenient form, one can use the date program to construct
703 timestamps. For example, with the bash shell the following syntax would
704 specify a date range to return messages from 2009\-10\-01 until the
707 $(date +%s \-d 2009\-10\-01)..$(date +%s)
709 The following environment variables can be used to control the
713 Specifies the location of the notmuch configuration file. Notmuch will
714 use ${HOME}/.notmuch\-config if this variable is not set.
716 The emacs-based interface to notmuch (available as
718 in the Notmuch distribution).
721 .B http://notmuchmail.org
723 Feel free to send questions, comments, or kudos to the notmuch mailing
724 list <notmuch@notmuchmail.org> . Subscription is not required before
725 posting, but is available from the notmuchmail.org website.
727 Real-time interaction with the Notmuch community is available via IRC
728 (server: irc.freenode.net, channel: #notmuch).