1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
3 Notmuch is a great mail indexing tool that can also be used *in conjunction*
4 with existing Mail User Agents (MUA) instead of replacing them. The advantage of
5 such mixed solutions is that users can benefit from notmuch features (such as
6 full-text search and thread reconstruction) without *having to* change MUA.
8 A popular geek MUA is [the Mutt e-mail client](http://www.mutt.org); integrating
9 notmuch with Mutt is not seamless, but fairly straightforward. There are two
10 principal possibilities, either using a patched mutt that handles internally
11 notmuch, or use a sets of scripts/handler within mutt to achieve something close.
15 # Using Notmuch with the good old mutt
17 There's a page about the [[notmuch-mutt]] scripts that are distributed along
18 with notmuch, in its contrib directory.
20 # Using Notmuch with neomutt
22 *Note*: This discussion was updated by a non-mutt user from talking about mutt-kz to
23 [neomutt](https://neomutt.org/). Caveat lector!
28 See [the neomutt install page](https://neomutt.org/distro). If
29 building from source see [build
30 instructions](https://neomutt.org/dev/build/build). Note in particular
31 the `--notmuch` configuration option.
35 *N.B.* From here is unmodified previous discussion about `mutt-kz`,
36 which hopefully also applies to neomutt.
38 Here is my `.muttrc` I use with `mutt-kz`, explanations as comments:
41 set nm_default_uri="notmuch:///PATH/TO/MY/Maildir" # path to the maildir
42 set virtual_spoolfile=yes # enable virtual folders
43 set sendmail="/PATH/TO/bin/nm_sendmail" # enables parsing of outgoing mail
45 "INBOX" "notmuch://?query=tag:INBOX and NOT tag:archive"\
46 "Unread" "notmuch://?query=tag:unread"\
47 "Starred" "notmuch://?query=tag:*"\
48 "Sent" "notmuch://?query=tag:sent" # sets up queries for virtual folders
50 macro index \\\\ "<vfolder-from-query>" # looks up a hand made query
51 macro index A "<modify-labels>+archive -unread -inbox<enter>" # tag as Archived
52 macro index I "<modify-labels>-inbox -unread<enter>" # removed from inbox
53 macro index S "<modify-labels-then-hide>-inbox -unread +junk<enter>" # tag as Junk mail
54 macro index + "<modify-labels>+*<enter><sync-mailbox>" # tag as starred
55 macro index - "<modify-labels>-*<enter><sync-mailbox>" # tag as unstarred
57 set sidebar_width = 20
58 set sidebar_visible = yes # set to "no" to disable sidebar view at startup
59 color sidebar_new yellow default
61 bind index <left> sidebar-prev # got to previous folder in sidebar
62 bind index <right> sidebar-next # got to next folder in sidebar
63 bind index <space> sidebar-open # open selected folder from sidebar
65 macro index ,@) "<enter-command> set sidebar_visible=no; macro index ~ ,@( 'Toggle sidebar'<Enter>"
66 macro index ,@( "<enter-command> set sidebar_visible=yes; macro index ~ ,@) 'Toggle sidebar'<Enter>"
67 macro index ~ ,@( 'Toggle sidebar' # toggle the sidebar
69 There is no major difference with the standard mutt. Just a new concept (and URL) the
70 virtual folder, that is addressed as `notmuch://`, a few new settings and commands.
74 when you open `mutt` you get the INBOX opened. There you can crawl through your
75 mails, and tag them as appropriate, either manually using the " ` " command, or using
76 the bindings defined in configuration (such as A/I/S/+/-).
78 ## Mail tagging on sending
80 You may have noticed in `neomutts`'s configuration that I set the `sendmail` variable
81 of mutt to a `nm_sendmail` script. This is for tagging outgoing mail each time I send
82 a mail. Here is the content of the script (which may be used directly in mutt's
83 variable, I did not try).
85 Source of `nm_sendmail`:
88 tee >(notmuch insert --folder=Sent +sent) | sendmail $*
90 ## Mail filtering/tagging
92 For mail tagging on arrival, I prefer to use a simple procmail delivery along with
95 Of course, you could use formail or maildrop, instead of procmail, but it is flexible
96 enough for my needs, and here is an example of configuration that can be useful:
98 PATH=/bin:/usr/bin:/usr/local/bin
100 # ensure each mail is unique
102 | formail -D 8192 msgid.cache
104 # update addressbook with current mail
106 | /usr/local/bin/notmuch_abook update
111 # manage dynamic tagging, using the ' + ' token in mail addresses
112 # e.g.: user+TAG@fqdn.tld will generate the tag TAG
114 * ^TO\/user\+[a-z0-9]+@fqdn\.tld
115 * MATCH ?? ^user\+\/[a-z0-9]+
120 # match all mails from mailing-lists, don't let them go to inbox, but tag them with ml
124 TAGS="${TAGS} +ml -inbox"
127 # tag all mails coming from mutt-kz mailing list
129 * .*mutt-kz\.lists\.fedoraproject\.org.*
130 | notmuch insert $TAGS +mutt +notmuch
132 # tag all mails coming from notmuch mailing list
134 * .*notmuch\.notmuchmail\.org.*
135 | notmuch insert $TAGS +notmuch
137 # Mark all spams as junk mail
139 * ^X-Spam-Status: Yes
140 | notmuch insert +junk
144 | notmuch insert +junk
146 ### All unmatched mails
149 | notmuch insert $TAGS
151 there's a line that updates the addressbook with addresses of current mail, and you'll
152 be able to read more about it on the [[vimtips]] page.