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 mutt-kz
22 Here is a tip about how to set up [mutt-kz](https://github.com/karelzak/mutt-kz), a fork
23 of the mutt MUA with support of notmuch integrated.
27 You'll need to first have notmuch installed and the notmuch library available to
28 configure. Otherwise, it is a good old autoconf setup, so here it goes:
30 git clone https://github.com/karelzak/mutt-kz.git
32 ./configure && make && make install
36 Here is my `.muttrc` I use with `mutt-kz`, explanations as comments:
39 set nm_default_uri="notmuch:///PATH/TO/MY/Maildir" # path to the maildir
40 set virtual_spoolfile=yes # enable virtual folders
41 set sendmail="/PATH/TO/bin/nm_sendmail" # enables parsing of outgoing mail
43 "INBOX" "notmuch://?query=tag:INBOX and NOT tag:archive"\
44 "Unread" "notmuch://?query=tag:unread"\
45 "Starred" "notmuch://?query=tag:*"\
46 "Sent" "notmuch://?query=tag:sent" # sets up queries for virtual folders
48 macro index \\\\ "<vfolder-from-query>" # looks up a hand made query
49 macro index A "<modify-labels>+archive -unread -inbox\\n" # tag as Archived
50 macro index I "<modify-labels>-inbox -unread\\n" # removed from inbox
51 macro index S "<modify-labels-then-hide>-inbox -unread +junk\\n" # tag as Junk mail
52 macro index + "<modify-labels>+*\\n<sync-mailbox>" # tag as starred
53 macro index - "<modify-labels>-*\\n<sync-mailbox>" # tag as unstarred
55 set sidebar_width = 20
56 set sidebar_visible = yes # set to "no" to disable sidebar view at startup
57 color sidebar_new yellow default
59 bind index <left> sidebar-prev # got to previous folder in sidebar
60 bind index <right> sidebar-next # got to next folder in sidebar
61 bind index <space> sidebar-open # open selected folder from sidebar
63 macro index ,@) "<enter-command> set sidebar_visible=no; macro index ~ ,@( 'Toggle sidebar'<Enter>"
64 macro index ,@( "<enter-command> set sidebar_visible=yes; macro index ~ ,@) 'Toggle sidebar'<Enter>"
65 macro index ~ ,@( 'Toggle sidebar' # toggle the sidebar
67 There is no major difference with the standard mutt. Just a new concept (and URL) the
68 virtual folder, that is addressed as `notmuch://`, a few new settings and commands.
72 when you open `mutt` you get the INBOX opened. There you can crawl through your
73 mails, and tag them as appropriate, either manually using the " ` " command, or using
74 the bindings defined in configuration (such as A/I/S/+/-).
76 ## Mail tagging on sending
78 You may have noticed in `mutt-kz`'s configuration that I set the `sendmail` variable
79 of mutt to a `nm_sendmail` script. This is for tagging outgoing mail each time I send
80 a mail. Here is the content of the script (which may be used directly in mutt's
81 variable, I did not try).
83 Source of `nm_sendmail`:
86 tee >(notmuch-deliver -t sent -f Sent) | sendmail $*
88 ## Mail filtering/tagging
90 For mail tagging on arrival, I prefer to use a simple procmail delivery along with
91 notmuch-delivery (which can be compiled in the `contrib/` directory of notmuch's sources).
93 Of course, you could use formail or maildrop, instead of procmail, but it is flexible
94 enough for my needs, and here is an example of configuration that can be useful:
96 PATH=/bin:/usr/bin:/usr/local/bin
98 # ensure each mail is unique
100 | formail -D 8192 msgid.cache
102 # update addressbook with current mail
104 | /usr/local/bin/notmuch_abook update
109 # manage dynamic tagging, using the ' + ' token in mail addresses
110 # e.g.: user+TAG@fqdn.tld will generate the tag TAG
112 * ^TO\/user\+[a-z0-9]+@fqdn\.tld
113 * MATCH ?? ^user\+\/[a-z0-9]+
118 # match all mails from mailing-lists, don't let them go to inbox, but tag them with ml
122 TAGS="${TAGS} -t ml -r inbox"
125 # tag all mails coming from mutt-kz mailing list
127 * .*mutt-kz\.lists\.fedoraproject\.org.*
128 | notmuch-deliver $TAGS -t mutt -t notmuch
130 # tag all mails coming from notmuch mailing list
132 * .*notmuch\.notmuchmail\.org.*
133 | notmuch-deliver $TAGS -t notmuch
135 # Mark all spams as junk mail
137 * ^X-Spam-Status: Yes
138 | notmuch-deliver -t junk
142 | notmuch-deliver -t junk
144 ### All unmatched mails
147 | notmuch-deliver -v $TAGS
149 there's a line that updates the addressbook with addresses of current mail, and you'll
150 be able to read more about it on the [[vimtips]] page.