|LWN.net needs you!|
Without subscribers, LWN would simply not exist. Please consider signing up for a subscription and helping to keep LWN publishing
Your editor has, for many years, been in search of a better email client. It is continually surprising — and frustrating — to see how hard it seems to be for our community to do a good job with one of the tools it relies upon most heavily. As part of this search, your editor reviewed Notmuch nearly four years ago. Since the email-client problem has not been solved in the meantime, your editor decided that perhaps Notmuch merited another look.
Shortly after the previous review, Notmuch development appeared to come to something approximating a complete stop after Carl Worth, the creator of the project, got busy with other work. In the last couple of years, though, David Bremner has accepted the challenge of pushing Notmuch forward; in response, a small but dedicated community of developers has come together. Notmuch is, once again, making semi-regular releases and adding new features; the current release is Notmuch 0.17, which came out at the end of December.
Notmuch remains more of a kit from which an email setup can be built than a complete solution in its own right. In particular, it doesn't handle email sending and receiving at all, and its approach to the user interface, while improving, may still feel a bit desultory to anybody who is used to a more polished client. So Notmuch will not be an appropriate solution for anybody who wants a ready-made point-and-click environment. But it may well be the right solution for users who deal with large amounts of mail and are willing to put some time into creating an optimal setup.
At its core, Notmuch is a command-line tool that manages a searchable index for a local mail repository. The mail itself must be stored in the filesystem, one message per file; the Maildir and MH formats both work. The local storage requirement has been a show-stopper for your editor in the past; there are real advantages to having one's email behind an IMAP server in a central location. It's nice to be able to access email from multiple machines, including tablets and handsets. For users who live their lives out of their laptops, perhaps a local mail store is an optimal solution, but, for many of us, mail locked into a laptop is inaccessible much of the time.
That's the bad news. The good news is that the Notmuch developers have been working to improve interoperability with mail stored on an IMAP server. Notmuch still needs a local copy of the mail; the tool of choice to manage that copy appears to be Offlineimap. Recent versions of Notmuch are able to manipulate the "has been read" flags stored in Maildir filenames and to perform folder-based searches, despite the fact that "folders" are a foreign concept in the Notmuch world. The afew tool can be used to move messages between folders based on Notmuch tags; that means that local tagging can be reflected in IMAP folders on the server. These changes make it possible to use Notmuch in some settings, but still fall back on an IMAP-based client in others.
The initial task of copying the mail directory to the local machine where Notmuch is to be run (assuming it's not already there) will still be painful, of course. But, then, anybody who has sat through Thunderbird's indexing routine will already be used to that kind of suffering and may not even notice. Then it's a simple matter of running:
and answering some questions to create the initial Notmuch configuration, then:
to read through and index all of the mail in the spool. The process can take a while for a very large mail spool, but it's surprisingly fast when one looks at how many messages are being processed.
The indexing of mail is done with the Xapian search engine. Xapian provides high-speed and flexible searching; it also performs "stemming," so that a search for "email" will also turn up "emails" and "emailed," for example. Stemming only works with English; extending it to other languages is not likely to be a simple task. Basic logical operators are supported; a search for, say:
from:torvalds AND crap
turns up a long list of messages on a linux-kernel archive. Searches can be date-constrained; it is also possible to search for words or phrases that are near each other in the text.
The other fundamental Notmuch operation is tagging. The "notmuch new" command will apply some initial tags ("unread", for example); it can be configured to do more complex tagging in response to search queries as well. Searching itself can be limited to specific tags. As is the way of the modern world, Notmuch has pretty much done away with the concept of folders; rather than existing in a single folder, a message will have any of a number of tags.
Low-level access to the Notmuch search feature is via the "notmuch search" command; it outputs a list of matching messages (or threads) in a line-oriented format. Most users, however, will want to actually do things with the result of a search — reading the messages, say, or replying to them. That is where core Notmuch throws up its hands and declares that the problem is to be solved by some higher layer of software.
Several projects are working on producing a useful user interface for people who actually want to work with mail. There are a few alternatives for those who want to integrate Notmuch with the Mutt email client, including the notmuch-mutt helper by Stefano Zacchiroli. Another terminal-based client is Alot. There is notmuch-vim for those who want to manage their mail through the vim editor, and notmuch-web to create a web interface.
The bulk of Notmuch users, though, would appear to be using the Emacs-based interface packaged with Notmuch itself. Starting the Emacs Notmuch mode is somewhat reminiscent of going to the main Google page; there is a search box and not a whole lot more. Once one picks a search ("unread" is a good starting place), the result is a dense screen showing the results in a one-line-per-thread format. Clicking on a line (or moving there and hitting "return") switches to a buffer with all messages in the thread, one after another. This view clearly works for many Notmuch users, but it's not entirely helpful for those of us who like to know what's in a thread before wandering into it.
Fortunately, the Notmuch 0.17 release added a new mode called notmuch-tree; it shows a tree-structured threaded view that is closer to what most other thread-oriented mail clients provide. In this view, one can move through threads and messages in a fairly straightforward manner. There is a full range of functionality in either mode, including the ability to pipe a message to a command — a feature that is surprisingly hard to find in most graphical clients. And, of course, it's Emacs, so the interface is infinitely flexible.
If Emacs is running in the graphical mode, the experience is mostly like that of a graphical mail reader. The illusion falls apart a bit, though, when it comes to dealing with attachments. Emacs can deal with various types of attachments internally; it can do inline image display, for example. But Notmuch makes little use of those capabilities, relying instead on external helpers to deal with attachments. Having external image viewers and web browser windows pop up for attachments feels a bit less integrated than a contemporary graphical mail client, but it works well enough most of the time.
Mail composition is handed off entirely to the Emacs "Message" mode, which, for the most part, handles the job nicely. There is nothing like trying to edit a complex message in a graphical mail client's composition window to make one appreciate the virtues of having a real text editor available. That said, handling of attachments is, once again, a bit primitive for those who are used to a native, graphical, point-and-click interface, but it gets the job done. Naturally, Notmuch doesn't get into the business of actually sending mail at all; it assumes there is a sendmail command around somewhere that can send a message toward its destination.
So, one might ask, will Notmuch become your editor's new email client? The jury is still out on that one, but it might just happen. To a great extent, it comes down to whether a practical way for accessing email from multiple hosts, including some that use IMAP, can be found. Offlineimap seems like one potential option; there is also a way of using a remote Notmuch installation over SSH from an Emacs client, though the instructions warn that "some things probably won't work perfectly." In either case, part of the proof will be usability over a painful conference network connection. Even without a full-scale switchover, Notmuch can be useful for tasks like searching through an extensive linux-kernel archive, of course.
In general, it often seems like progress in the area of email clients came to a halt some years ago. The clients that actually are evolving are, for the most part, tied to cloud services; offloading one's email to a cloud provider may be a viable solution for some users, but many of us disliked that idea even before the extent of national surveillance efforts became widely known. So it is good to see communities like Notmuch trying to get back to the basics of what makes an email client work well, and it is good to see that Notmuch, in particular, appears to be picking up speed. Notmuch remains a project worth watching.
Copyright © 2014, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds