Hack and / - Take Mutt for a Walk

 in
Skip ahead on the mutt learning curve with real-life mutt configuration examples.

Mutt is my favorite e-mail client and the one I use every day both professionally and personally. The greatest yet most challenging thing about mutt is how incredibly configurable it is. As you use a program, you might think “I wish it did X, Y or Z”, but in the case of mutt, most of the major settings you want to tweak are available for you to change. If you have used mutt for many years like I have, you find that you go through a few phases with your .muttrc (the main configuration file for mutt). When you start using mutt, you spend a lot of time just trying to figure out how to set up mutt to read your mail (usually with the help of someone else's .muttrc). After you get mutt working, the next phase involves tweaking more and more sophisticated options, such as folder hooks. Eventually though, your .muttrc is finely tuned just the way you like it, and you change it only rarely. These days, I usually change my .muttrc only to add a new mailbox.

What I realize is that no matter how great I might think mutt is, if someone else wants to give it a try for the first time, the learning curve is a bit intimidating. In past columns I've discussed advanced settings for mutt, but in this column, my goal is to walk you through the one thing that intimidates mutt users the most when they start out: mutt configuration. Hopefully, by the end of the column you will have a basic, functional mutt configuration you can use to check your e-mail.

Mutt Is an MUA

These days, mutt should be available as a package for just about any major distribution, so I'm not going to cover how to install it—just use your package manager. If you are used to a regular, graphical e-mail client, two main things are different about mutt. For one, it is designed to run completely from a terminal controlled by your keyboard. Second, mutt is strictly a Mail User Agent (MUA) and not a Mail Transfer Agent (MTA). Most graphical e-mail clients not only can access and read your e-mail as a MUA, but they also know how to be an MTA (they can communicate with a mail server directly via SMTP to send out e-mail). Unlike those clients, mutt is strictly concerned with accessing and reading your mail, and it relies on a separate MTA. This means if your Linux system doesn't already have a mail server configured, you will need to set up a basic one. If you need some tips on how to do that, check out my “Make a Local Mutt Mail Server” column in the February 2010 issue.

Well-Organized Mutt Configuration

Although you certainly can set up your mutt configuration any way you want (as long as the core config is in ~/.muttrc), because you are doing this for the first time, you might as well set up a system of configuration files instead of one giant .muttrc. Because mutt allows you to reference other configuration files from within the .muttrc, many mutt users organize their options into different files. What I like to do is separate the configuration into different categories stored under ~/.mutt. I also store my .muttrc file there with the ~/.muttrc file symlinked to it. Finally, I create a ~/.muttrc.local file that I use to store any options I want to keep local to this machine. These are options like whether to access a remote IMAP server versus a local maildir, or other such local settings. Now this may seem like a lot of work, but the point is that once you get your mutt configuration how you want it, you simply can rsync the ~/.mutt directory to the rest of your machines without wiping out any local settings.

I realize that no sample mutt config is going to please everyone, but here are some basic settings that I think should get you off to the right start. I've added comments to options where I feel they need extra explanation, but plenty of options are uncommented, so if you are curious about what an option does, the best resource is the official mutt documentation at mutt.org. Every now and then I find myself browsing through the documentation there just to look for some new (or new to me) options that I didn't know I couldn't live without.

First, let's look at my main ~/.mutt/.muttrc file. Remember that I actually create a symlink from this file to ~/.muttrc with:

ln -s ~/.mutt/.muttrc ~/.muttrc

Also, it may go without saying, but you need to create the ~/.mutt directory as well. Listing 1 shows a basic starter ~/.mutt/.muttrc.

As you can see, this muttrc file is quite involved. Besides the rather large list of options I defined, I also have included separate configuration files with the source option. For instance, I have separated out all my mutt color configuration into ~/.mutt/colors. Listing 2 shows a good sample ~/.mutt/colors file you can use to get started.

______________________

Kyle Rankin is a director of engineering operations in the San Francisco Bay Area, the author of a number of books including DevOps Troubleshooting and The Official Ubuntu Server Book, and is a columnist for Linux Journal.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix