]> git.notmuchmail.org Git - notmuch/blob - notmuch.1
emacs: support "notmuch new" as a notmuch-poll-script
[notmuch] / notmuch.1
1 .\" notmuch - Not much of an email program, (just index, search and tagging)
2 .\"
3 .\" Copyright © 2009 Carl Worth
4 .\"
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.
9 .\"
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.
14 .\"
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/ .
17 .\"
18 .\" Author: Carl Worth <cworth@cworth.org>
19 .TH NOTMUCH 1 2011-12-04 "Notmuch 0.10.2"
20 .SH NAME
21 notmuch \- thread-based email index, search, and tagging
22 .SH SYNOPSIS
23 .B notmuch
24 .IR command " [" args " ...]"
25 .SH DESCRIPTION
26 Notmuch is a command-line based program for indexing, searching,
27 reading, and tagging large collections of email messages.
28
29 The quickest way to get started with Notmuch is to simply invoke the
30 .B notmuch
31 command with no arguments, which will interactively guide you through
32 the process of indexing your mail.
33 .SH NOTE
34 While the command-line program
35 .B notmuch
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.
42 .SH COMMANDS
43 The
44 .BR setup
45 command is used to configure Notmuch for first use, (or to reconfigure
46 it later).
47 .RS 4
48 .TP 4
49 .B setup
50
51 Interactively sets up notmuch for first use.
52
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
60 .B "notmuch setup"
61 again to change the configuration.
62
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
68 them.
69
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
74 .B "notmuch setup" .
75
76 Invoking
77 .B notmuch
78 with no command argument will run
79 .B setup
80 if the setup command has not previously been completed.
81 .RE
82
83 The
84 .B new
85 command is used to incorporate new mail into the notmuch database.
86 .RS 4
87 .TP 4
88 .BR new " [options...]"
89
90 Find and import any new messages to the database.
91
92 The
93 .B new
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
98 tags.
99
100 You should run
101 .B "notmuch new"
102 once after first running
103 .B "notmuch setup"
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
107 .B "notmuch new"
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
110 run.
111
112 Invoking
113 .B notmuch
114 with no command argument will run
115 .B new
116 if
117 .B "notmuch setup"
118 has previously been completed, but
119 .B "notmuch new"
120 has not previously been run.
121
122 The
123 .B new
124 command supports hooks. See the
125 .B "HOOKS"
126 section below for more details on hooks.
127
128 Supported options for
129 .B new
130 include
131 .RS 4
132 .TP 4
133 .BR \-\-no\-hooks
134
135 Prevents hooks from being run.
136 .RE
137 .RE
138
139 Several of the notmuch commands accept search terms with a common
140 syntax. See the
141 .B "SEARCH SYNTAX"
142 section below for more details on the supported syntax.
143
144 The
145 .BR search ", " show " and " count
146 commands are used to query the email database.
147 .RS 4
148 .TP 4
149 .BR search " [options...] <search-term>..."
150
151 Search for messages matching the given search terms, and display as
152 results the threads containing the matched messages.
153
154 The output consists of one line per thread, giving a thread ID, the
155 date of the newest (or oldest, depending on the sort option) matched
156 message in the thread, the number of matched messages and total
157 messages in the thread, the names of all participants in the thread,
158 and the subject of the newest (or oldest) message.
159
160 Supported options for
161 .B search
162 include
163 .RS 4
164 .TP 4
165 .BR \-\-format= ( json | text )
166
167 Presents the results in either JSON or plain-text (default).
168 .RE
169
170 .RS 4
171 .TP 4
172 .B \-\-output=(summary|threads|messages|files|tags)
173
174 .RS 4
175 .TP 4
176 .B summary
177
178 Output a summary of each thread with any message matching the search
179 terms. The summary includes the thread ID, date, the number of
180 messages in the thread (both the number matched and the total number),
181 the authors of the thread and the subject.
182 .RE
183 .RS 4
184 .TP 4
185 .B threads
186
187 Output the thread IDs of all threads with any message matching the
188 search terms, either one per line (\-\-format=text) or as a JSON array
189 (\-\-format=json).
190 .RE
191 .RS 4
192 .TP 4
193 .B messages
194
195 Output the message IDs of all messages matching the search terms,
196 either one per line (\-\-format=text) or as a JSON array
197 (\-\-format=json).
198 .RE
199 .RS 4
200 .TP 4
201 .B files
202
203 Output the filenames of all messages matching the search terms, either
204 one per line (\-\-format=text) or as a JSON array (\-\-format=json).
205 .RE
206 .RS 4
207 .TP 4
208 .B tags
209
210 Output all tags that appear on any message matching the search terms,
211 either one per line (\-\-format=text) or as a JSON array
212 (\-\-format=json).
213 .RE
214 .RE
215
216 .RS 4
217 .TP 4
218 .BR \-\-sort= ( newest\-first | oldest\-first )
219
220 This option can be used to present results in either chronological order
221 .RB ( oldest\-first )
222 or reverse chronological order
223 .RB ( newest\-first ).
224
225 Note: The thread order will be distinct between these two options
226 (beyond being simply reversed). When sorting by
227 .B oldest\-first
228 the threads will be sorted by the oldest message in each thread, but
229 when sorting by
230 .B newest\-first
231 the threads will be sorted by the newest message in each thread.
232
233 By default, results will be displayed in reverse chronological order,
234 (that is, the newest results will be displayed first).
235 .RE
236
237 .RS 4
238 .TP 4
239 .BR \-\-offset=[\-]N
240
241 Skip displaying the first N results. With the leading '\-', start at the Nth
242 result from the end.
243 .RE
244
245 .RS 4
246 .TP 4
247 .BR \-\-limit=N
248
249 Limit the number of displayed results to N.
250 .RE
251
252 .RS 4
253 See the
254 .B "SEARCH SYNTAX"
255 section below for details of the supported syntax for <search-terms>.
256 .RE
257 .TP
258 .BR show " [options...] <search-term>..."
259
260 Shows all messages matching the search terms.
261
262 The messages will be grouped and sorted based on the threading (all
263 replies to a particular message will appear immediately after that
264 message in date order). The output is not indented by default, but
265 depth tags are printed so that proper indentation can be performed by
266 a post-processor (such as the emacs interface to notmuch).
267
268 Supported options for
269 .B show
270 include
271 .RS 4
272 .TP 4
273 .B \-\-entire\-thread
274
275 By default only those messages that match the search terms will be
276 displayed. With this option, all messages in the same thread as any
277 matched message will be displayed.
278 .RE
279
280 .RS 4
281 .TP 4
282 .B \-\-format=(text|json|mbox|raw)
283
284 .RS 4
285 .TP 4
286 .BR text " (default for messages)"
287
288 The default plain-text format has all text-content MIME parts
289 decoded. Various components in the output,
290 .RB ( message ", " header ", " body ", " attachment ", and MIME " part ),
291 will be delimited by easily-parsed markers. Each marker consists of a
292 Control-L character (ASCII decimal 12), the name of the marker, and
293 then either an opening or closing brace, ('{' or '}'), to either open
294 or close the component. For a multipart MIME message, these parts will
295 be nested.
296 .RE
297 .RS 4
298 .TP 4
299 .B json
300
301 The output is formatted with Javascript Object Notation (JSON). This
302 format is more robust than the text format for automated
303 processing. The nested structure of multipart MIME messages is
304 reflected in nested JSON output. JSON output always includes all
305 messages in a matching thread; in effect
306 .B \-\-format=json
307 implies
308 .B \-\-entire\-thread
309
310 .RE
311 .RS 4
312 .TP 4
313 .B mbox
314
315 All matching messages are output in the traditional, Unix mbox format
316 with each message being prefixed by a line beginning with "From " and
317 a blank line separating each message. Lines in the message content
318 beginning with "From " (preceded by zero or more '>' characters) have
319 an additional '>' character added. This reversible escaping
320 is termed "mboxrd" format and described in detail here:
321
322 .nf
323 .nh
324 http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/mail-mbox-formats.html
325 .hy
326 .fi
327 .
328 .RE
329 .RS 4
330 .TP 4
331 .BR raw " (default for a single part, see \-\-part)"
332
333 For a message, the original, raw content of the email message is
334 output. Consumers of this format should expect to implement MIME
335 decoding and similar functions.
336
337 For a single part (\-\-part) the raw part content is output after
338 performing any necessary MIME decoding.
339
340 The raw format must only be used with search terms matching single
341 message.
342 .RE
343 .RE
344
345 .RS 4
346 .TP 4
347 .B \-\-part=N
348
349 Output the single decoded MIME part N of a single message.  The search
350 terms must match only a single message.  Message parts are numbered in
351 a depth-first walk of the message MIME structure, and are identified
352 in the 'json' or 'text' output formats.
353 .RE
354
355 .RS 4
356 .TP 4
357 .B \-\-verify
358
359 Compute and report the validity of any MIME cryptographic signatures
360 found in the selected content (ie. "multipart/signed" parts). Status
361 of the signature will be reported (currently only supported with
362 --format=json), and the multipart/signed part will be replaced by the
363 signed data.
364 .RE
365
366 .RS 4
367 .TP 4
368 .B \-\-decrypt
369
370 Decrypt any MIME encrypted parts found in the selected content
371 (ie. "multipart/encrypted" parts). Status of the decryption will be
372 reported (currently only supported with --format=json) and the
373 multipart/encrypted part will be replaced by the decrypted
374 content.
375 .RE
376
377 A common use of
378 .B notmuch show
379 is to display a single thread of email messages. For this, use a
380 search term of "thread:<thread-id>" as can be seen in the first
381 column of output from the
382 .B notmuch search
383 command.
384
385 See the
386 .B "SEARCH SYNTAX"
387 section below for details of the supported syntax for <search-terms>.
388 .RE
389 .RS 4
390 .TP 4
391 .BR count " [options...] <search-term>..."
392
393 Count messages matching the search terms.
394
395 The number of matching messages (or threads) is output to stdout.
396
397 With no search terms, a count of all messages (or threads) in the database will
398 be displayed.
399
400 Supported options for
401 .B count
402 include
403 .RS 4
404 .TP 4
405 .B \-\-output=(messages|threads)
406
407 .RS 4
408 .TP 4
409 .B messages
410
411 Output the number of matching messages. This is the default.
412 .RE
413 .RS 4
414 .TP 4
415 .B threads
416
417 Output the number of matching threads.
418 .RE
419 .RE
420 .RE
421 .RE
422
423 The
424 .B reply
425 command is useful for preparing a template for an email reply.
426 .RS 4
427 .TP 4
428 .BR reply " [options...] <search-term>..."
429
430 Constructs a reply template for a set of messages.
431
432 To make replying to email easier,
433 .B notmuch reply
434 takes an existing set of messages and constructs a suitable mail
435 template. The Reply-to header (if any, otherwise From:) is used for
436 the To: address. Vales from the To: and Cc: headers are copied, but
437 not including any of the current user's email addresses (as configured
438 in primary_mail or other_email in the .notmuch\-config file) in the
439 recipient list
440
441 It also builds a suitable new subject, including Re: at the front (if
442 not already present), and adding the message IDs of the messages being
443 replied to to the References list and setting the In\-Reply\-To: field
444 correctly.
445
446 Finally, the original contents of the emails are quoted by prefixing
447 each line with '> ' and included in the body.
448
449 The resulting message template is output to stdout.
450
451 Supported options for
452 .B reply
453 include
454 .RS
455 .TP 4
456 .BR \-\-format= ( default | headers\-only )
457 .RS
458 .TP 4
459 .BR default
460 Includes subject and quoted message body.
461 .TP
462 .BR headers\-only
463 Only produces In\-Reply\-To, References, To, Cc, and Bcc headers.
464 .RE
465
466 See the
467 .B "SEARCH SYNTAX"
468 section below for details of the supported syntax for <search-terms>.
469
470 Note: It is most common to use
471 .B "notmuch reply"
472 with a search string matching a single message, (such as
473 id:<message-id>), but it can be useful to reply to several messages at
474 once. For example, when a series of patches are sent in a single
475 thread, replying to the entire thread allows for the reply to comment
476 on issue found in multiple patches.
477 .RE
478 .RE
479
480 The
481 .B tag
482 command is the only command available for manipulating database
483 contents.
484
485 .RS 4
486 .TP 4
487 .BR tag " +<tag>|\-<tag> [...] [\-\-] <search-term>..."
488
489 Add/remove tags for all messages matching the search terms.
490
491 Tags prefixed by '+' are added while those prefixed by '\-' are
492 removed. For each message, tag removal is performed before tag
493 addition.
494
495 The beginning of <search-terms> is recognized by the first
496 argument that begins with neither '+' nor '\-'. Support for
497 an initial search term beginning with '+' or '\-' is provided
498 by allowing the user to specify a "\-\-" argument to separate
499 the tags from the search terms.
500
501 See the
502 .B "SEARCH SYNTAX"
503 section below for details of the supported syntax for <search-terms>.
504 .RE
505
506 The
507 .BR dump " and " restore
508 commands can be used to create a textual dump of email tags for backup
509 purposes, and to restore from that dump.
510
511 .RS 4
512 .TP 4
513 .BR dump " [<filename>] [--] [<search-terms>]"
514
515 Creates a plain-text dump of the tags of each message.
516
517 Output is to the given filename, if any, or to stdout.  Note that
518 using the filename argument is deprecated.
519
520 These tags are the only data in the notmuch database that can't be
521 recreated from the messages themselves.  The output of notmuch dump is
522 therefore the only critical thing to backup (and much more friendly to
523 incremental backup than the native database files.)
524
525 With no search terms, a dump of all messages in the database will be
526 generated.  A "--" argument instructs notmuch that the
527 remaining arguments are search terms.
528
529 See the
530 .B "SEARCH SYNTAX"
531 section below for details of the supported syntax for <search-terms>.
532 .RE
533
534 .TP
535 .BR restore " [--accumulate] [<filename>]"
536
537 Restores the tags from the given file (see
538 .BR "notmuch dump" ")."
539
540 The input is read from the given filename, if any, or from stdin.
541
542 Note: The dump file format is specifically chosen to be
543 compatible with the format of files produced by sup-dump.
544 So if you've previously been using sup for mail, then the
545 .B "notmuch restore"
546 command provides you a way to import all of your tags (or labels as
547 sup calls them).
548
549 The --accumulate switch causes the union of the existing and new tags to be
550 applied, instead of replacing each message's tags as they are read in from the
551 dump file.
552 .RE
553
554 The
555 .B part
556 command can used to output a single part of a multipart MIME message.
557
558 .RS 4
559 .TP 4
560 .BR part " \-\-part=<part-number> <search-term>..."
561
562 Output a single MIME part of a message.
563
564 A single decoded MIME part, with no encoding or framing, is output to
565 stdout. The search terms must match only a single message, otherwise
566 this command will fail.
567
568 The part number should match the part "id" field output by the
569 "\-\-format=json" option of "notmuch show". If the message specified by
570 the search terms does not include a part with the specified "id" there
571 will be no output.
572
573 See the
574 .B "SEARCH SYNTAX"
575 section below for details of the supported syntax for <search-terms>.
576 .RE
577
578 The
579 .B config
580 command can be used to get or set settings int the notmuch
581 configuration file.
582
583 .RS 4
584 .TP 4
585 .BR "config get " <section> . <item>
586
587 The value of the specified configuration item is printed to stdout. If
588 the item has multiple values, each value is separated by a newline
589 character.
590
591 Available configuration items include at least
592
593         database.path
594
595         user.name
596
597         user.primary_email
598
599         user.other_email
600
601         new.tags
602 .RE
603
604 .RS 4
605 .TP 4
606 .BR "config set " <section> . "<item> [values ...]"
607
608 The specified configuration item is set to the given value.  To
609 specify a multiple-value item, provide each value as a separate
610 command-line argument.
611
612 If no values are provided, the specified configuration item will be
613 removed from the configuration file.
614 .RE
615
616 .SH SEARCH SYNTAX
617 Several notmuch commands accept a common syntax for search terms.
618
619 The search terms can consist of free-form text (and quoted phrases)
620 which will match all messages that contain all of the given
621 terms/phrases in the body, the subject, or any of the sender or
622 recipient headers.
623
624 As a special case, a search string consisting of exactly a single
625 asterisk ("*") will match all messages.
626
627 In addition to free text, the following prefixes can be used to force
628 terms to match against specific portions of an email, (where
629 <brackets> indicate user-supplied values):
630
631         from:<name-or-address>
632
633         to:<name-or-address>
634
635         subject:<word-or-quoted-phrase>
636
637         attachment:<word>
638
639         tag:<tag> (or is:<tag>)
640
641         id:<message-id>
642
643         thread:<thread-id>
644
645         folder:<directory-path>
646
647 The
648 .B from:
649 prefix is used to match the name or address of the sender of an email
650 message.
651
652 The
653 .B to:
654 prefix is used to match the names or addresses of any recipient of an
655 email message, (whether To, Cc, or Bcc).
656
657 Any term prefixed with
658 .B subject:
659 will match only text from the subject of an email. Searching for a
660 phrase in the subject is supported by including quotation marks around
661 the phrase, immediately following
662 .BR subject: .
663
664 The
665 .B attachment:
666 prefix can be used to search for specific filenames (or extensions) of
667 attachments to email messages.
668
669 For
670 .BR tag: " and " is:
671 valid tag values include
672 .BR inbox " and " unread
673 by default for new messages added by
674 .B notmuch new
675 as well as any other tag values added manually with
676 .BR "notmuch tag" .
677
678 For
679 .BR id: ,
680 message ID values are the literal contents of the Message\-ID: header
681 of email messages, but without the '<', '>' delimiters.
682
683 The
684 .B thread:
685 prefix can be used with the thread ID values that are generated
686 internally by notmuch (and do not appear in email messages). These
687 thread ID values can be seen in the first column of output from
688 .B "notmuch search"
689
690 The
691 .B folder:
692 prefix can be used to search for email message files that are
693 contained within particular directories within the mail store. Only
694 the directory components below the top-level mail database path are
695 available to be searched.
696
697 In addition to individual terms, multiple terms can be
698 combined with Boolean operators (
699 .BR and ", " or ", " not
700 , etc.). Each term in the query will be implicitly connected by a
701 logical AND if no explicit operator is provided, (except that terms
702 with a common prefix will be implicitly combined with OR until we get
703 Xapian defect #402 fixed).
704
705 Parentheses can also be used to control the combination of the Boolean
706 operators, but will have to be protected from interpretation by the
707 shell, (such as by putting quotation marks around any parenthesized
708 expression).
709
710 Finally, results can be restricted to only messages within a
711 particular time range, (based on the Date: header) with a syntax of:
712
713         <initial-timestamp>..<final-timestamp>
714
715 Each timestamp is a number representing the number of seconds since
716 1970\-01\-01 00:00:00 UTC. This is not the most convenient means of
717 expressing date ranges, but until notmuch is fixed to accept a more
718 convenient form, one can use the date program to construct
719 timestamps. For example, with the bash shell the following syntax would
720 specify a date range to return messages from 2009\-10\-01 until the
721 current time:
722
723         $(date +%s \-d 2009\-10\-01)..$(date +%s)
724 .SH HOOKS
725 Hooks are scripts (or arbitrary executables or symlinks to such) that notmuch
726 invokes before and after certain actions. These scripts reside in
727 the .notmuch/hooks directory within the database directory and must have
728 executable permissions.
729
730 The currently available hooks are described below.
731 .RS 4
732 .TP 4
733 .B pre\-new
734 This hook is invoked by the
735 .B new
736 command before scanning or importing new messages into the database. If this
737 hook exits with a non-zero status, notmuch will abort further processing of the
738 .B new
739 command.
740
741 Typically this hook is used for fetching or delivering new mail to be imported
742 into the database.
743 .RE
744 .RS 4
745 .TP 4
746 .B post\-new
747 This hook is invoked by the
748 .B new
749 command after new messages have been imported into the database and initial tags
750 have been applied. The hook will not be run if there have been any errors during
751 the scan or import.
752
753 Typically this hook is used to perform additional query\-based tagging on the
754 imported messages.
755 .RE
756 .SH ENVIRONMENT
757 The following environment variables can be used to control the
758 behavior of notmuch.
759 .TP
760 .B NOTMUCH_CONFIG
761 Specifies the location of the notmuch configuration file. Notmuch will
762 use ${HOME}/.notmuch\-config if this variable is not set.
763 .SH SEE ALSO
764 The emacs-based interface to notmuch (available as
765 .B notmuch.el
766 in the Notmuch distribution).
767
768 The notmuch website:
769 .B http://notmuchmail.org
770 .SH CONTACT
771 Feel free to send questions, comments, or kudos to the notmuch mailing
772 list <notmuch@notmuchmail.org> . Subscription is not required before
773 posting, but is available from the notmuchmail.org website.
774
775 Real-time interaction with the Notmuch community is available via IRC
776 (server: irc.freenode.net, channel: #notmuch).