My Mutt Setup

For a good five years I was a loyal user of the text based Mutt e-mail client, which may sound archaic, but actually turns out to be a pretty amazingly powerful program and great for your productivity. (provided you don't spend too much time pimping out your ~/.muttrc) In 2004 I started weakening when I got hooked up with Gmail and eventually in May of 2005, it's simplicity and ease of use won me over and I left Mutt behind. Today however I've been thinking about and laying the groundwork for switching back.

Gmail is admittedly great. Their interface for managing large quantities of email in a browser is really revolutionary. Conversation views, easy to use labels and filters, multiple identities, POP access (which I only really use for backups), and of course, exceptional search capabilities. The only things I really don't like are having my e-mail hosted on US soil, always staring at a white background, and lack of PGP encryption support.

When it comes to Mutt, I actually have substantially more complaints. It's a pain in the ass and immensely complicated to setup, very fragile if you're prone to switching operating systems (which I was), can't display image attachments, and can't even send e-mail by itself. It is exclusively an e-mail "reader". Regardless, once it's properly set up, the power of what you can do from your keyboard can be quite amazing, and at this point I have very few complaints.

Why am I even considering subjecting myself to this kind of abuse again when I'm actually quite satisfied with Gmail? Boredom, a desire to reconvince myself of the decision I made a couple years ago, who knows. Regardless, here's my setup.

  • I use maildir folders instead of the old mbox files. Check the link for details on why, but basically they're more reliable and faster for mutt to work with. I haven't figured out how to create them on Fedora yet, I just let procmail make some for me, took one and deleted all the messages in it, then copy it whenever I want to create a new one. Will update when I find the appropriate command.

    My mail is all stored in ~/mail/, inboxes are located in ~/mail/in/, one for my main inbox and one for each mailing list I'm on. ~/mail/archives/ is another maildir where I dump all my archived mail, I try to keep my inbox empty, or at least only filled with messages I have to reply to or do something about. ~/mail/ham/ and ~/mail/spam/ will be described later.

  • Getmail is a simple command line tool that pulls down your mail from a POP server and, in my case, feeds it over to procmail for sorting to the appropriate mailbox. All you need is a configuration file, my ~/.getmail/getmailrc looks like so:

    [retriever]
    type = SimplePOP3SSLRetriever
    server = pop.gmail.com
    username = mygmailaccount
    password = mygmailpassword
    
    [destination]
    type = MDA_external
    path = /usr/bin/procmail
    arguments = ("-f", "%(sender)")
    

    Previously I was relying on fetchmail for this, but a learned reader made a good case for switching by pointing me to the getmail FAQ.

  • You might need to modify your shell login script a bit, I use it to define a mutt alias pointing it to my inbox maildir, I suspect you can easily do this with an env variable instead.

    alias mutt='mutt -f ~/mail/in/inbox/'
  • Procmail isn't the world's most intuitive way to filter mail, but it gets the job done. Procmail lets you move incoming mailing lists to seperate inboxes, feed mail into Spamassassin (coming up shortly), and probably a lot of other interesting things. All you need is a .procmailrc and the above getmailrc config to call procmail on incoming mail.
  • The cornerstone of any good mutt setup is your .muttrc. I don't want to guess how many hours I spent tweaking this when I used to use mutt and I also don't want to think how many I spent just recently when switching back. Regardless, if you're bored and enjoy infinite customization, have fun.
  • Run getmail and monitor the procmail log (~/.procmail/log in my setup) to make sure emails are going where they're supposed to. You can also configure getmail to log if you're so inclined.
  • To manage spam you'll likely want to install Spamassassin. My setup uses F11 to send an email to the "ham folder" (emails you want spamassassin to know are legit) and F12 to send mail to the "spam folder". I then run a script like this nightly to train based on whats in the ham/spam maildir's as well as my archives:

    #!/bin/bash
    #
    # Train Spamassassin filters.
    
    sa-learn --ham "~/mail/archives/*"
    sa-learn --ham "~/mail/ham/*"
    sa-learn --spam "~/mail/spam/*"
    

  • Configure cron to run the spamlearn script nightly and fetchmail as often as you like.

    # Run getmail every 5 minutes:
    */5 * * * * /usr/bin/getmail -q
    
    # Run spamlearn nightly at 3am:
    0 3 * * * sh /home/dev/bin/spamlearn.sh
    

  • Test sending an e-mail. If it doesn't make it, chances are sendmail isn't properly configured on your system. nbsmtp is probably a good alternative.
  • Modify /etc/mailcap to display HTML email with w3m. (My system was opening every HTML message in a Firefox tab, very slowly)

    text/html; w3m %s; nametemplate=%s.html
    text/html; w3m -dump %s; nametemplate=%s.html; copiousoutput
    

I modified my key bindings in the following ways:

  • c - Switch between your inboxes that receive new mail. (tab to see the whole list)
  • h - Return to the main inbox.
  • o - Switch to "old" or archive mailbox.
  • d - Send messages to trash. (instead of actually deleting them)
  • F6 - Archive message.
  • F7 - Move message to inbox.
  • F11 - Mark message as "ham" and delete.
  • F12 - Mark message as "spam" and delete.
  • In the message reader (love these):
    • j - Next message.
    • k - Previous message.
    • l - Next half screen of text on the current message.
    • h - Previous half screen of text on the current message.

Mutt has a lot of great default key bindings as well, some of my favorites:

  • t - Tag a message. (repeat, then perform some action to have it applied to all messages tagged.)
  • T - Tag by a pattern.
  • l - Limit to messages matching a pattern. (index view only)
  • F - Flag a message.

I think that's about it. Not sure if I'll be able to stick it out with mutt and all this insanity, I kinda miss being able to browse my mail single handed with a mouse and actually see attached images. Regardless if I make it, I'll be updating this entry with any improvements I discover.

Hopefully that'll be of use to somebody out there. This page and all the associated dotfiles will be updated as I discover more, feel free to drop me a line via email or comments if you've got any kind of feedback.

Comments

Great howto. I may actually

Great howto. I may actually consider using mutt more than I do. At work I use Thunderbird with fetchmail. When I ssh into my workstation and need to read new message quickly, I use mutt. No need for vnc to read my email.

For my personal email, I've completely switched to gmail. I forward all of my ISP email to gmail and don't use any mail client at home.

I'm switching to mutt.

I'm switching to mutt. You're right, it's a pain setting it up. But I need more control over my emails (extreme volume, multiple accounts, mousing around is killing my wrist, ...). I definitely appreciate that you share your mutt experience. Without folks like you, I wouldn't have a chance at getting it set up properly.

You should really think

You should really think about checking out fdm for fetching and sorting your mail. 3l9048g520[4 times better than procmail :P

Good stuff, quite similar to

Good stuff, quite similar to my setup. I should do a full writeup, but just wanted to mention I've also been using nmzmail for searching across folders with some success.

gsf

I use mutt @ home and at

I use mutt @ home and at work, both setup with malidir via procmail. at home everything is maildir and i can search all folders very quickly with mairix, it indexes mail and is crazy fast to search large volumes of mail. at work, i also have mairix, but there i access several very large mbox format 'shared mailboxes' and i don't think mairix can index those, otherwise my email searching at work would be a lot better.

the note on fetchmail, and getmail was interesting.. i'll think about switching myself soon.

just a FYI, but the latest

just a FYI, but the latest version of mutt 1.5.15 has internal SMTP support.

http://www.mutt.org/doc/devel/manual.html#smtp-url

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
14 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.