Hack and / - Take Mutt for a Walk
Listing 2. Sample ~/.mutt/colors
# color settings color normal white default color attachment brightyellow default color hdrdefault cyan default color indicator brightwhite default color markers brightred default color quoted green default color signature cyan default color tilde blue default color tree red default color quoted1 green default color index brightyellow default ~N # New color index yellow default ~O # Old #example of how to colorize based on FROM: #color index magenta default '~f foo@example.com'
All of the color options follow the same syntax. First, the word color, then which object should be colorized and finally the foreground and background colors to use. I use default as my background color, so if I have a transparent window, the background is also transparent. You'll notice that the color options for the index (the mutt window that lists all of the messages in a mailbox) has an extra option at the end that lets you control what attributes it should match before it applies that color. For instance, in these two options:
color index brightyellow default ~N # New color index yellow default ~O # Old
the ~N and ~O arguments match any new or old messages, respectively. You can use mutt's extensive matching language to match on all sorts of message attributes. In the above file, I provide a commented example for how to colorize a message based on its FROM: header.
As I mentioned earlier, I like to separate any settings that might differ between machines into a ~/.muttrc.local file. Here's an example of the settings you might want to keep there if you had all of your e-mail stored in a local Maildir folder:
# local mbox settings set mbox_type=Maildir set folder=~/Maildir set spoolfile=+INBOX set record=+sent-mail save-hook . "+saved-messages-`date +%Y`" mailboxes "=INBOX"
Here is an example .muttrc.local for a system that accesses mail remotely via IMAP:
set folder=imaps://mail.example.net/INBOX set imap_user=username set imap_pass=password set spoolfile=+ set record=+.sent-mail save-hook . "=.saved-messages-`date +%Y`"
Note here that I specify both the IMAP user name and IMAP password. If you want extra security, you will want to leave out the imap_pass option so your password is not in plain text. If no password is specified, mutt will prompt you when it connects to that IMAP server.
After you define your main mail folder settings, you also will want to define any other mailboxes you have besides INBOX. I keep these mailboxes defined in ~/.mutt/mailboxes, and I should note that the order does matter here. Whatever mailboxes you define in your configuration files will be checked by mutt for new mail. When you tell mutt to change to a different mailbox, it automatically will fill in the mailbox name with the next mailbox that has new mail. I use this feature a lot, especially at work, as it allows me to make sure I go through all of the high-priority mailboxes with new mail first. Here is a sample mailboxes file. Note that the = sign tells mutt that these folders are off the main folder:
mailboxes "=linuxjournal" mailboxes "=consulting" mailboxes "=nblug" mailboxes "=saved-messages" mailboxes "=sent-mail"
The final configuration file worth mentioning is ~/.mutt/hooks where I store all of my folder hooks and other settings. Hooks are a powerful feature in mutt that allow you to change your mutt settings on the fly based on your current folder, the recipient of an e-mail or contents in an e-mail when you reply to it. Hook syntax can get a bit complicated, so I recommend if you want to know more about a particular option, especially the index_format and folder_format syntax, that you reference the official documentation on mutt.org. Listing 3 shows a few example hooks I use to change how messages are sorted in some folders, tweak what signature to use on certain e-mail messages and even change my TO address when I reply to a message.
Listing 3. Example Hooks
# The first options set defaults
unset sig_on_top
# default hook is 'set index_format="%4C %Z %{%b %d}
# %-15.15L (%4l) %s"'
folder-hook . 'set index_format="%4C %Z %{%b %d} %-15.15L (%4l) %s"'
folder-hook . 'set sort=date'
folder-hook . 'my_hdr From: Kyle Rankin <foo@example.com>'
send-hook . unset signature
# Set special options when I'm in my nblug folder
folder-hook nblug 'set index_format="%4C %Z %{%b %d}
↪%-15.15F (%4l) %s"'
folder-hook . 'set sort=date'
folder-hook nblug 'set sort=threads'
folder-hook nblug 'set signature="~/.mutt/.sig.nblug"
#default folder_format="%2C %t %N %F %sl %-8.8u %-8.8g %8s %d %f"
set folder_format="%2C %t %N %8s bytes - %d %f"
# these settings will pick a different signature file to use
# depending on whether I'm sending email to nblug.org (one of my
# mailing lists) or one of my consulting clients
send-hook '~t @nblug\.org$' 'set signature="~/.mutt/.sig.nblug";
↪my_hdr From: My Name <foo@example.com>'
send-hook '~t client@example\.com$'
↪'set signature="~/.mutt/.sig.consulting"; my_hdr From:
↪My Name <bar@example.com>'
# This is the actual hook I use to make sure emails to my
# Linux Journal address have the proper FROM headers
reply-hook '~t lj@greenfly\.net' 'my_hdr
↪From: Kyle Rankin <lj@greenfly.net>'
So there you have it. If your interest in mutt is piqued, these options should be more than enough to get you started. I also know that these settings won't appeal to everyone. That's the beauty of mutt—you can change the options until they do suit you. I still recommend once you get your base options configured that you spend a little time with the official documentation on mutt.org. There are many great examples and also many more options than I listed here that might solve a particular configuration problem you are having.
Kyle Rankin is a Systems Architect in the San Francisco Bay Area and the author of a number of books, including The Official Ubuntu Server Book, Knoppix Hacks and Ubuntu Hacks. He is currently the president of the North Bay Linux Users' Group.
Kyle Rankin is a systems architect; and the author of DevOps Troubleshooting, The Official Ubuntu Server Book, Knoppix Hacks, Knoppix Pocket Reference, Linux Multimedia Hacks, and Ubuntu Hacks.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- RSS Feeds
- New Products
- Using Salt Stack and Vagrant for Drupal Development
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- Validate an E-Mail Address with PHP, the Right Way
- New Products
- Readers' Choice Awards
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
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.




4 hours 17 min ago
10 hours 17 min ago
10 hours 39 min ago
10 hours 50 min ago
10 hours 54 min ago
11 hours 24 min ago
14 hours 15 min ago
14 hours 51 min ago
14 hours 52 min ago
14 hours 53 min ago