1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
2 # Getting Started with Notmuch
4 *This is a work in progress.*
8 This is your friendly guide and tutorial to getting started with Notmuch. It
9 will help you through the first steps of setting up Notmuch.
11 All Notmuch commands have [manual
12 pages](https://notmuchmail.org/doc/latest/). Please refer to them for
17 In order to use Notmuch, you will need to have your email messages stored in
18 your local filesystem, one message per file. For example,
19 [Maildir](http://cr.yp.to/proto/maildir.html), Maildir++, and MH formats work
20 like this, while [mbox](https://en.wikipedia.org/wiki/Mbox) does not. Storing
21 the messages one message per file is the only hard dependency for trying out
24 We will get back to delivering messages later, for now we'll just assume you
25 already have messages in this format.
29 On Linux, the easiest way to install Notmuch is through your distribution's
30 package repository. If you're installing Notmuch from a [git
31 checkout](https://git.notmuchmail.org/git/notmuch) or a [source
32 release](https://notmuchmail.org/releases/), please refer to the
33 [INSTALL](https://git.notmuchmail.org/git/notmuch/blob/HEAD:/INSTALL) document.
37 To configure Notmuch, just run
41 This will interactively guide you through the setup process, and save the
42 configuration to `$HOME/.notmuch-config`. If you'd like to change the
43 configuration in the future, you can either edit that file directly, or run
46 This step only modifies the configuration file.
50 Notmuch needs a search database to operate. The next step is to run
54 to index all your messages in the search database. The database will be stored
55 in `.notmuch` directory under your mail store. The database is not a replacement
56 or storage for your messages; it's just an index to find the right message
59 Notmuch does not modify or delete your mails. This is one of the main design
60 principles of Notmuch. (The only exception is renaming files upon tagging
61 according to the Maildir specification if the `maildir.synchronize_flags`
62 configuration option is set.) It should be safe to try Notmuch.
64 Depending on the amount of mail you have the initial indexing process can take a
65 long time, so expect that. Also, the resulting database will require roughly the
66 same amount of storage space as your current collection of email.
68 After this step, you can try out the [Notmuch command line
69 interface](https://notmuchmail.org/doc/latest/man1/notmuch.html), or
70 [[Notmuch Emacs interface|notmuch-emacs]].
72 ## Converting Existing mbox to Maildir
74 The [`mb2md`](http://batleth.sapienti-sat.org/projects/mb2md/) tool can be used
75 to convert existing mbox files to Maildir.
77 Beware that the source and destination directory options to `mb2md` are relative
78 to the user's home directory, not relative to the current working directory.
80 ## Delivering New Messages
82 Notmuch itself does not receive messages. There is no IMAP or POP support. You
83 will need to set up other tools, such as fetchmail, offlineimap, or mbsync, to
86 There are two ways to deliver and index messages:
88 * Use an external tool (such as offlineimap or mbsync) to deliver the messages
89 to your mail store, and run `notmuch new` to discover and index the newly
90 delivered messages (and any other changes in the mail store).
92 * Use an external tool (such as fetchmail) receive the messages, and configure
93 the tool to use `notmuch insert` as a Mail Delivery Agent to deliver the
94 messages to your mail store and index them.
96 ## Automation Via Hooks
98 Notmuch supports running [user defined
99 hooks](https://notmuchmail.org/doc/latest/man5/notmuch-hooks.html)
100 before or after certain commands. Hooks can be arbitrary executable
101 programs or scripts. For example, if you always run your mail delivery
102 tool first and `notmuch new` after that, you can run the tool from
103 Notmuch `pre-new` hook, and simply run `notmuch new` to do both. If
104 you always do some tagging after indexing of new messages, you may
105 want to set up a `post-new` or `post-insert` hook to do that
108 ## Backing Up and Restoring the Database
110 The Notmuch database contains a search index of your messages, along with all
111 the tags you've added to your messages. The search index can be regenerated by
112 indexing the messages again, but the tags will be lost if the database is
113 lost. (If you have `maildir.synchronize_flags` configuration option enabled,
114 also some of the tags can be regenerated from maildir flags.)
116 To create a plain-text dump of the tags, run
118 notmuch dump --output=dump.txt
120 To restore the tags from the dump, run
122 notmuch restore --input=dump.txt
126 Did not like it after all? All you need to do is remove the database and the
127 configuration file. The database is stored in the `.notmuch` directory under
128 your mail store. And your mail store is at `notmuch config get database.path`.
130 You may want to use the `notmuch dump` command to create a backup of any tags
131 you've added before removing the database.