mutt + notmuch : searching multiple mailboxes in mutt

This post explains the installation of the email indexing programme notmuch and its integration with the mutt email programme under openSuSE 11.4.

I have recently changed the way I use email. Previously, I had my email auto-sorted into folders, which meant that I had unread emails scattered over several folders and often neglected to read emails in categories that I felt were not immediately important.
In order to change that, I emptied my INBOX, which contained hundreds of unsorted messages, and moved them all into folders. It is now my resolution to work through my email once it comes in, and then move it into an appropriate folder. This way I should keep a nice and empty INBOX and I know that anything which is still in there, has yet to be addressed.

However, mutt does not allow you to search in more than one mailbox at a time. Now, if I need to look up a certain email, I would have to run the same search in all my folders. This is unacceptable. To address the issue, I looked into indexers that work with mutt. After reading zack’s post from 2009 on mairix, maildir-utils and nmzmail, and his newer post on notmuch, I decided to go with notmuch.

Notmuch is not currently in any of the openSuSE repositories, so you will have to grab it from the web. I simply google searched for “notmuch rpm” and found the latest version (notmuch-0.5-4.fc15.i686.rpm) on

The following dependencies have to be satisfied:

  • libgmime-2.6
  • libtalloc (version > 2.0.2)



This requirement may be fulfilled by installing the gmime-2.5.1-4.fc15.i686.rpm (this is a fedore package from


libtalloc may be found in the openSuSE online package search. I used the
libtalloc-2.0.5-8.fc15.i686.rpm package from Make sure that the installed version of libtalloc is 2.0.2 or higher.


The following packages aren’t required at the time of the installation, but if you later get an error when you first try to use notmuch from mutt, then it may be because you are missing the following packages:

  • perl
  • perl-MailTools
  • perl-Email-Sender
  • perl-Mail-Box

You will also need libxapian and sqlite3, but those dependencies may be resolved automatically when you install notmuch.

setup and indexing

Now that notmuch has been successfully installed, you need to run the configuration and then the indexing. In order to run the setup, open a terminal and enter “notmuch setup”, then press enter. This will take you through a short setup procedure which should be self-explanatory.

Once the setup is complete, it asks you to start the indexing by executing “notmuch new” in the terminal. Depending on how much mail you have, this may take some time. Future indexing is done incremental and will only take a very short time.

notmuch integration with mutt

As explained in Zack’s post, you should download the mutt-notmuch script and save it to a location of your choice. Then make it executable by the user (chmod u+x ./mutt-notmuch). Now you only need to include a macro in your mutt configuration file. The instructions are here.

notmuch integration with offlineimap

You could use a cron job to repeatedly run the “notmuch new” command, but I personally prefer to use the posthook command in the offlineimap configuration file. This way, every time I gab new mail, the indexer runs automatically. Since I grab mail from several imap servers, I set the number of simultaneous connections to 1 in the offlineimaprc config file (maxconnections = 1), this way offlineimap works through the accounts one after the next and I simply set the postsynchook in the last account i.e.

[Account last-account]
postsynchook = notmuch new

Alternatively you could write a short bash script, first calling offlineimap and then notmuch new

Now, if all went well, you should be able to call a search from within mutt simply by pressing the F8 key. It works wonderfully for me.