Configuring the Mutt Mail User Agent

This page contains my personal configuration of Mutt. Mutt is a text-mode (ncurses-based) email-client or Mail User Agent (MUA). Mutt has been around for quite some time, and although there have been discussions about creating a GUI-version, it has not happened yet (at least to my knowledge). Dispite this, many people still use mutt, for a variety of reasons. Personally I really like the to be able to login to my box from any computer that has SSH, and browse my emails. Some other nice features are:

For a great deal of information about configuring Mutt, check out the Mutt web-site, which also contains some screen-shots showing various configurations.

Below is a screen-shot of my current configuration:

Mutt screen-shot

My Mutt configuration is listed below. It can be downloaded as .muttrc.

NOTE: All email-addresses and domains have been removed from this file, in an attempt to fight spam. Hopefully it makes sense anyway.

# .muttrc - Spaceman Spiff's configuration file for Mutt
# Last edited 27 apr, 2005
#

# Local addresses are @domain.dk
set hostname = "domain.dk"

# My other addresses
set alternates="(xxx|yyy)@domain\.dk"

# Mailboxes are in ~/Mail
set folder=~/Mail

# Don't include "Delivered to"-header when bouncing (I'm using postfix)
unset bounce_delivered

# Don't suspend on Ctrl-Z
unset suspend

# Check for new mail every 1½ min
set timeout = 90

# Don't ask for subj and recepients when replying or subj when forwarding
set fast_reply = yes

# Check for new messages
set check_new = yes

# Don't beep on new messages (I made a mail-notifyer using procmail) 
set beep_new = no

# Default text to put in replys
set attribution = "On %d, %n wrote:"

# Default from - may be overridden by reverse_name
set from="Mikkel Holm Olsen <zzz@domain.dk>"

# Put a different reply-to addr on the mails
#set hdrs = yes
#my_hdr Reply-To: Mikkel Holm Olsen <qqq@domain.net>

# There wasn't a good keybinding for prev/next line of the messages, so
# this binds left arrow to up and right arrow to down
bind pager <left> previous-line
bind pager <right> next-line

# Use vim as email-editor and set automatic line-breaks at coloumn 72
set editor="vim -c 'set tw=72'"

# Show the headers when editing a mail (allows you to modify subj etc.)
#set edit_headers

# Set colors
color normal green black
color hdrdefault brightred black
color quoted brightblue black
color signature brightgreen black
color indicator brightyellow red
color error brightred black
color status white blue
color tree magenta black	# the thread tree in the index menu
color tilde magenta black
color message brightmagenta black
color markers magenta black
color attachment brightmagenta black
color search black green	# how to hilite search patterns in the pager

# Special patterns to show with different colors
color header brightgreen black ^(From|Subject):
color body brightmagenta black "(ftp|http)://[^ ]+"	# point out URLs
color body brightmagenta black [-a-z_0-9.]+@[-a-z_0-9.]+	# e-mail addresses
color body brightyellow black  [mM]ikkel
color underline brightgreen black

#
# Save stuff
#

# Default location to save outgoing mail
set record=+outbox	        

# Where to store read messages
#set mbox=+mbox

# Always save a copy of outgoing messages
set copy=yes

# Do not flag unread messages as old
unset mark_old

# always include message when replying
set include

# Remove my address from receipient list when replying
unset metoo

# Ignore all headers by default
ignore *

# We want these headers
unignore from: subject to cc date
# x-mailer x-url

# Sort messages by thread
set sort=threads

# What does a quote look like?
set quote_regexp="^ *[a-zA-Z]*[>#}]"

# Regexp which recognizes reply messages when replying and for threading.
set reply_regexp="^(re|aw|sv):[ \t]*"

# Show 6 lines of the pager when message is shown
set pager_index_lines=6

# Show full name for addresses found in the alias-list
set reverse_alias 

# Don't ask when saving messages to existing mailbox
unset confirmappend

# Don't move read messages to mbox
set move=no

# But DO ask before creating a new mailbox
set confirmcreate

# Don't ask if messages should be deleted
set delete=yes

# Do not ask user for key after message piping and shell-excapes. Will only 
# ask for key when exitcode was non-zero.
unset wait_key

# Print emails using script to determine if mail fits on one or two pages
set print_command="~/bin/a2psmail"
# Print emails using a2ps, two pages per sheet
# set print_command="a2ps -2 -gEmail"

# Call sendmail with -B8BITMIME to use ESMTP
set use_8bitmime

# Don't convert 8-bit data to 7-bit
set allow_8bit

# Set up character set for זרו
#set locale="da_DK"
set locale="dansk"
set charset="iso8859-1"

# The default signature should be generated by the gensig program
set signature="/usr/bin/gensig -o|"

# Show all mailboxes in ~/Mail directory (except outbox and procmail.log)
mailboxes `find /home/spacemanspiff/Mail/* -printf " =%f" | sed 's/ =\(procmail.log\|outbox\)//g'`

# I am on the following aliases
subscribe advancemame-users@lists\.sourceforge\.net
subscribe zeoslib-general@lists\.sourceforge\.net

# No reply-to address is the default
folder-hook . unmy_hdr Reply-To:
folder-hook . "set from=\"Mikkel Holm Olsen <xxx@domain.dk>\"" 
folder-hook . "set signature=\"/usr/bin/gensig -o|\""

# When replying to/writing messages in the folder advancemame-users, add the
# correct from-address
folder-hook advancemame-users "set from=\"Mikkel Holm Olsen <yyy@domain.dk>\""
folder-hook zeoslib-general "set from=\"Mikkel Holm Olsen <yyy@domain.dk>\""

# Modify signature in certain folders.
folder-hook advancemame-users "set signature=\"/usr/bin/gensig -o -s .signature-dk|\""

# Where to store new aliases
set alias_file=~/.mutt-aliases

# Include file containing aliases
source ~/.mutt-aliases

If you decide to use this configuration, it might be nice to tell vim what a quote looks like. This allows vim to color lines according to the number of quotes, and also allows various commands to be used on quotes. For instance, you can try to use the vim-command gq for reformatting comments. Select an email in Mutt and hit r to reply. Then go to the bottom of the message (just press G). Now press gq1G, and all text from line 1 in the mail to the current cursor position will be reformatted.

Anyways, to tell vim what quotes look like, put the follwing line in .vimrc:

set comments=nb:>

Perhaps you would also like to sort your incoming emails into separate mailboxes. This is easily achieved using procmail. See my procmail quickguide, for information on how to do this.

Fetching mail from a POP3-server (probably at your internet provider), can be achieved by using fetchmail. See my Extremely Short Fetchmail Guide for information.

Last updated: 2005.04.27