]> git.cworth.org Git - notmuch-wiki/blob - howto.mdwn
add (pointers to) howto use notmuch with mutt
[notmuch-wiki] / howto.mdwn
1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
2 #How to...
3
4 Some tips about how to do some useful things with notmuch, and the
5 various "third party" notmuch utilities.
6
7 * <span id="receive_mail">**Receive mail**</span>
8
9   Notmuch requires either [maildir
10   flag](http://cr.yp.to/proto/maildir.html) or a "mh"-style
11   maildirectory to operate on.  Basically any setup in which each mail
12   is in a file of it's own will work.  Here are some generally
13   well-regarded mail retrieval tools:
14
15   * [offlineimap](https://github.com/jgoerzen/offlineimap/wiki/) -
16     quite useful and widely tested, it also offers a handy hook that
17     will come in useful a bit later in our setup.  Also supports
18     "presynchook" and "postsynchook" command that will get run
19     whenever you sync.  Point _postsynchook_ to a script that gets run
20     on every sync and that will do the automatic updating and tagging
21     of your notmuch database.
22
23   * [mbsync](http://isync.sourceforge.net/)
24
25   * [getmail](http://pyropus.ca/software/getmail/)
26
27   * [fetchmail](http://fetchmail.berlios.de/)
28
29   See the [[initial_tagging]] page for more info on intial tagging of messages.
30
31 * <span id="print_filenames">**Print only filenames of a search (python bindings)**</span>
32
33   Notmuch includes python bindings to the notmuch shared library,
34   called [cnotmuch](http://pypi.python.org/pypi/cnotmuch).  Extensive
35   API documentation available.
36
37   The bindings are very simple to use.  As an example, given you have
38   the python bindings installed (or simply set your PYTHONPATH
39   environment variable to point to the .../bindings/python directory),
40   this script will print the filenames of a matching search:
41
42                              #!/usr/bin/env python
43                              import sys
44                              import notmuch
45                              search = " ".join(sys.argv[1:])
46                              q = notmuch.Database().create_query(search)
47                              for m in q.search_messages():
48                                  print m.get_filename()
49
50 * <span id="sync_maildir_flags">**Sync notmuch tags and maildir flags**</span>
51
52   notmuch **since version 0.5** syncs maildir flags and respective
53   tags in both directions.  This how to applies only to notmuch
54   prior version 0.5:
55
56   Some IMAP users rely on maildir flags that convey the status "seen",
57   "replied", "trashed", in order to synchronize the status of their
58   mail across mail clients (a [maildir
59   flag](http://cr.yp.to/proto/maildir.html) is simply a defined part
60   of their filename).  Notmuch will by default happily ignore those
61   flags and will never modify them either, as there is no built-in
62   support for sunchronizing your notmuch tags with your imap maildir
63   flags (seen, replied, trashed, etc). However there are currently 2
64   ways in which you can achieve synchronization.
65
66   [notmuchsync](http://spaetz.github.com/notmuchsync/) is a utility
67   (based on the cnotmuch python bindings) that allows synchronization
68   in either direction, as well as pruning of deleted files.
69
70   The second solution allows for fast maildir flag to notmuch tag
71   synchronization (and only in that direction) requires patching the
72   notmuch source code. The patch has been posted in this mail
73   *id:1267450136-31749-1-git-send-email-Sebastian@SSpaeth.de* and can
74   be viewed as a [source diff in this git
75   repository](http://github.com/spaetz/notmuch-all-feature/commit/df3b087cefb85e9d16fd17540e348bcb854dd7ee).
76
77 * <span id="print_filenames">**Using notmuch with Mutt**</span>
78
79   Notmuch is a great mail indexing tool than can also be used *in conjunction*
80   with existing Mail User Agents (MUA) instead of replacing them. The advantage
81   of such mixed solutions is that users can benefit from notmuch features (such
82   as full-text search and thread reconstruction) without *having to* change
83   MUA.
84   
85   A popular geek MUA is [the Mutt e-mail client](http://www.mutt.org);
86   integrating notmuch with Mutt is fairly straightforward. An
87   [**how to use Notmuch with Mutt**](http://upsilon.cc/~zack/blog/posts/2011/01/how_to_use_Notmuch_with_Mutt/)
88   has been written by Stefano Zacchiroli, together with some glue code. Check
89   out the
90   [howto](http://upsilon.cc/~zack/blog/posts/2011/01/how_to_use_Notmuch_with_Mutt/)
91   for more information.
92   
93   <small>(Note by the howto author: I've linked the howto from this wiki rather
94   than splicing it in, in order to avoid duplication of information. If you
95   think it would be better to have it here, feel free to copy the text
96   here. The howto is
97   [available](http://git.upsilon.cc/cgi-bin/gitweb.cgi?p=zack-homepage.git;a=history;f=blog/posts/2011/01/how_to_use_Notmuch_with_Mutt.mdwn)
98   in markdown syntax from the Git repository of my homepage.)</small>
99