Managing Mail Madness with Mutt


A few weeks ago, I tweeted about a great blog post on a technique for managing the massive amounts of email many of us navigate daily.

I’d become frustrated with the state of my own inbox1 and had been on the prowl for a new method to manage the email torrent.

Having used it for a little over a week now, I can say: it works wonders!

One caveat: the author uses Postbox, which has some core features that are the cornerstone of the technique.

Now, I’ve been a longtime proponent of Postbox, and I use it as my work client. But for a variety of historical reasons, my personal email-life is centered around the venerable Mutt mail client2. So, the technique described in the article works perfectly if you use Postbox.

This is how I successfully re-created the work flow with Mutt.


The technique relies heavily on the ability to label mail, as Gmail and Postbox both easily and handily support.

Mutt calls this “tagging,” and while there’s been support for reading the X-Label header since 1.4, support to edit labels isn’t in a currently-released Mutt.

The good news: there’s a patch to support label/tag editing.

The bad news: the patch is against a pretty old version of Mutt3.

I’m a Gentoo user, so I updated the patch4 to apply to [Gentoo's] 1.5.205,6 and also wrote an ebuild8 you can add into a local overlay to make it easier to install9.

After that, add the following to your muttrc to bind label-editing to keys and display labels:

# Add X-Label to your unignored headers
unignore From: To: Subject: Date: Cc: Reply-To: X-Label:
color header brightwhite default '^X-Label:'
macro index Cy " ~y " "Limit view to label"

The patch binds the ‘y’ key to adding, deleting, or changing a message label in both Mutt’s message and index views; the above config binds Ctrl-y to limiting the view of the folder based on a specific label.

When editing labels, they are space-separated.

Search, Don’t Sort

The “Search, don’t sort”-mantra isn’t new; but when all you have is grep, you still tend to sort your email as an initial step to being able to easily find it later.

Enter mairix10.

Setup is relatively easy: configure it with an rc file, and run it. I run it from cron every four hours to keep the index fresh, and reset the entire index every month11

Since mairix provides its results as an mbox or Maildir folder, I wrote a simple wrapper that only launches Mutt if there are results to my search and makes the folder read-only, to keep the conceptual model—these are search results, and I shouldn’t edit them—consistent.

As for sorting, I still do sort some email, mostly Twitter, Facebook, and other automated notifications, as well as mail from important people that tends to fit neatly into boundaries (my parents, certain friends, etc.)

Keeping Folders Tidy

Now that my mail is searchable, where we save it isn’t as important. Now I can move to a model of just saving everything to mutt’s default saved-messages and going from there.

Only problem is, won’t that folder balloon over time? Probably.

Cron comes to our rescue again; I have the following entry:

5 0 1 * * MAILBOX="/home/preed/mail/saved-messages-archive/saved-messages-$(/bin/date +%Y-%m)" && /usr/bin/find /home/preed/mail/ -maxdepth 1 -type l -name 'saved-messages' -exec rm {} ; && /bin/touch $MAILBOX && /bin/ln -s $MAILBOX /home/preed/mail/saved-messages

This makes “saved-messages” a symlink that automatically gets updated at 12:05 am every month to point to a folder with the year and month.

And mairix updates its index with these new folders the index gets reset every month.

I use this same technique for my sent-messages, spamassassin-populated spam folder, and deleted-messages folder; the last two are auto-deleted by cron six months later.

Filtering Assaults On Your Inbox

The last tenent of this email management technique is probably the most important: if you don’t want it in your inbox again, set up a filter immediately. Don’t wait.

I’d been getting spam mails from Ticketmaster forevar. I didn’t set up a filter for them until I started using this technique.
It’s a bit costly at first, but it pays off and quicker than you think.

To help with this, I set up an easy way to test procmail rules without running them on my live inbox.

I stole the scripts from this page and slightly modified them to fit paths on my system.

Inbox Zero?!!

After using this method for about a week, I was able to dump most of my inbox into a saved-messages-archive folder, and begin using the dated saved-messages folder.

I’ve been able to find any message I’ve needed to find, and my inbox now hovers around 50 messages.

Finally, people emailing me are getting responses on the order of 72 hours; before, if their message got lost in my inbox, it was hit and miss; I just restarted a four month old thread, because I’d lost track of it, and couldn’t tag it “todo.”

Have I reached Inbox Zero? No. But as the original post points out: “I don’t care about ‘Inbox Zero’ because there’ll be more [email] tomorrow as soon as the sun comes up.”

But using this technique, I’ve been able to turn my inbox into something manageable, without the fear12 that I’ll lose a message.

All in all, I’ve been very impressed with how it’s been working so far. Hats off to Mr. Ignition for the inspiration!

1 Over 2,000 messages in 75 megabytes before I started this project
2 Having used them since I was 13, my customized Mutt key bindings, cribbed from Pine, are hopelessly burned into my muscle memory
3 It’s against 1.5.1; the current released version is 1.5.21
4 PGP sig
5 Which I’m using because of an attachment handling bug in 1.5.21
6 I also hacked up patches against pristine-1.5.20 (PGP sig) and pristine-1.5.217 (PGP sig)
7 This patch doesn’t include the documentation changes; that’s left as an exercise for the reader
8 I just added one to the ebuild revision; I’d love to hear from a Gentoo-dev on whether this is the correct way to do this, because I’m betting it’s not…
9 There’s also a method to allow editing of labels using an external script, but I didn’t use this script, so I can’t vouch for how well it works
10 Which I have @scanlime to thank for turning me on to
11 A full index of my 1.6 gigabytes of mail takes 97 seconds; reindexes only look at new messages, so it’s pretty low cost
12 Which was probably largely irrational anyway