Training My First Mutt

At work, I deal with a lot of mail. Not as much as some people, but still, it is a non-trivial amount. I don't have to respond to all of it, nor is it all of the same importance. For example, I get emailed by various cron jobs, some of which are critical to read and others are more informational. All in all, it averages out to 60-80 emails a day, depending on how crazy things are. This adds up fast, with the last two years each landing about 14,000 emails. Since I need to keep my email, I am getting quite a stash -- about 51,000 messages totalling 1.2GB. How in the world do you keep that organized? More importantly, what mail client can present all those without choking?

When I first started my current job, I chose Evolution, since that was about the best thing at the time. But somehow, it got dumber. Each new release took away features that I had come to love and depend on. When it started changing the key bindings without allowing me to have a say in the matter, I finally gave up and went with Kontact and Kmail. There are some things about KDE that I really like. One of the things is how customizable things are. I set all my key bindings so things worked for me. By this time, I had accumulated a fair amount of email and I noticed that it took a second or two to change folders. Annoying, but I just dealt with it. But on one of my upgrades, I noticed that Kmail was constantly crashing. That is beyond annoying. I moved to Thunderbird. I installed the Lightning extension to allow me to integrate my calendar with my email client like Evo and Kontact. Another year or two goes by and I notice a sufficient number of things about Thunderbird that drive me nuts. Time to move again. I look through the options. I test some out. But they all are SO SLOW.

I start looking at some of the second-tier mail clients, you know, the ones that only have a small following, like Sup, and Notmuch. I like a lot of things about both of those, but neither one is really ready to handle my abusive behavior. They both have powerful searching using the Xapian engine. They both deal very well in threads. Sup even has a UI. Notmuch doesn't have a UI. I wrote the beginnings of one and decided that there was still way to far to go before I could really use it. I threw my hands up and adopted a Mutt.

Mutt is really a full featured MUA. It doesn't speak SMTP, it only knows how to speak with a local process such as the venerable Unix Sendmail program. This is perfectly okay, since there are any number of ways to get around this. I chose MSMTP, which runs like sendmail and then makes an SMTP connection to your configured MTA to actually get your mail out there. So my entire mail stack looks something like this:

My Mail
My Mail
We have any number of IMAP servers to collect incoming mail. Fetchmail contacts the servers and delivers the mail to my local machine, filtering and tagging the messages on the way. Mutt notices the newly delivered mail and I read it. I reply or send mail and Mutt passes it off to MSMTP, which looks at the envelope from address and chooses the appropriate SMTP server to contact and pass the message off to. The entire stack suits me quite nicely. Each piece does its thing well and does not depend on the other pieces being of any particular brand. I am now free!

But let me tell you, taming your first Mutt is a non-trivial process. I still have not read the entire 12,000 line manual, but I have read much of it, some parts many times. I have spent many hours learning how Mutt does things, what I can change (almost anything) and what I can't change (very little), customizing key bindings, writing macros, etc. I finally feel like my Mutt and I are getting along. One of the things I really LOVE about my Mutt is that I get to use a *real* editor to compose my mail. Not some clunky built-in, unconfigurable, piece of junk. I use VIM to compose my mail. With a few key settings, it even does syntax highlighting (mail headers, quoted text, etc.), spellchecking and automatic line wrapping for my typed text. It also allows me to paste verbatim text in without messing up its format. I can paste a patch in without whitespace mangling. Hooray. How many other email composers allow this? None that I know of. You don't like VIM? You can use any editor you like.

When I first switched to Mutt, I was considering writing up a patch that would work with labels, giving me virtual folders for my labels. But after exploring the current label support that Mutt has, I found that to be uneccessary. All my incoming mail get passed through fetchmail, which does filtering and delivery. Part of my filtering process is to remove the junkmail and tag all the rest of the mail with labels according to some regular expressions. I have a little script I wrote that will read the headers of a message and spit out the 'X-Label:' header to add to the message. Once delivered, Mutt caches this in its header cache, making for some VERY speedy searches by label. Not only can it search by labels, but it has a very powerful search pattern language. For example, I can limit my view of my messages to '~(~d 6m-8m*2w ~f ("telly"|"cookie") ~Z >1M ~s recipe)' which means "all messages from threads containing messages from 'telly' or 'cookie' with dates from 6 to 8 months ago, plus or minus 2 weeks, that were larger than one megabyte and had recipe in the subject". Tell me this is not a powerful search engine. All of those things it can do without actually re-reading the messages because of the header cache. Some of the modifiers do force Mutt to actually read the messages (like ~b or ~B, which end up searching the body of the message). The header cache does not save all the headers, only the ones that Mutt deems important. Personally, I think this should be configurable.

Besides the Mutt manual (available online at http://www.mutt.org/doc/manual/ or included with your Mutt installation (Debian/Ubuntu users can press F1)), there are loads of online resources to help configure and train your Mutt. I found this site to be very helpful: My First Mutt.

If you are curious what I have done, drop me a note, leave a comment or something and I will share configs or whatever with you. In the mean time, I have some mail to read.

[Edited 27 Jan 2010] Fabio wanted to see my config and my label script, so here goes... A little insight to the twisted mind of Vernon.

autolabel.sh399 bytes
message_labels.py.txt2.03 KB
muttrc.txt15.8 KB


You are not the first friend who switched to Mutt as MUA. I think you have now a pretty cool setup.

However I think that with your setup you loose one of the biggest advantages of IMAP: keeping your emails organized and stored on the server. This is crucial for me as I often want to check mail from various computers so when I'm home I use Thunderbird and when I'm away I just use a webmail (Roundcube).

Anyway, a cool reading.. thanks for sharing.


Fabio Varesano

p.s.: why should I solve the captcha twice (preview and submit of comment)?

offlineimap doesn't offer IMAP IDLEing

I switched from offlineimap to fetchmail because fetchmail allows me to use IMAP IDLE, which means I get new messages instantly, not every 5 minutes from a cron job. It also has the advantage of passing all new messages through procmail to filter them (for spam and to tag them with labels). I am still not sure what the ideal solution is, but I agree that there are drawbacks to my solution.

That said, all my mail is still safe and sound on the IMAP server. It is not tagged with the X-Label header, so it is slightly different. But all my mail is in the INBOX anyway, I don't have any organization other than that. It was taking t-bird and evo too long to switch mailboxes even with 8000 messages per folder. But I don't care too much what state the IMAP server is in because I really only use my one machine to check my mail. EVER. And now with Mutt, I can even log into my machine remotely and check my mail over a terminal.

As for the double captchas, that should be fixed now.

Also thunderbird support

Also thunderbird support IMAP IDLE: I get messages immediately with it.

I don't have a huge amount of emails as you but they are also not few emails..
Personally I'm using various IMAP folders for each email category and then I use thunderbird Message Filtering to automatically move the mails to the appropriate folder. This helps keeping the INBOX size acceptable.. One with a huge amount of mails as you might create an "archive" folder and then a filter which periodically fetch mails from all the other folders and then move it to the archive folder (to keep main folders light).

Btw, I'm sure that an swiss knife MUA tool like Mutt will result in much more power once one became used to it
(I remember my first days with vim - "This is shit, I can't do anything with this" .. then things changed "slightly" ...)

Take Care,

Fabio Varesano

p.s.: I'm not the one asking for the config files (btw the .sh files script is unaccessible - some security redirect/filter?)
p.p.s. Is it normal that I "may use [acidfree:xx] tags to display acidfree videos or images inline." into comments?

Config files

Hey Vernon, would you consider just posting your various config files and scripts. The label script and the keybinding config for example would be nice to see.