logo
Jiff Slater
🤔 About
✍️ Contact
📚Knowledge
30 Jul 2021
These articles have been archived. You may find them useful but I am no longer offering support for them. Check out my latest articles on plkt.io.
Setting up Mutt
12 July 2008

Mutt is an extremely fast and flexible text-based mail user agent with local maildir, POP3, and IMAP support.  It is my default mail client by choice.  Today, I will show you my Mutt configuration; perhaps it’ll help you to setup Mutt as well.

The diagram to the left (created with $latex Xy-pic$) shows my ~/.mutt hierarchy.  I’ll explain what each file/directory contains and then I’ll concatenate my the main configuration file, ~/.mutt/muttrc.

~/.mutt/aliases.rc – contains a list of my contacts in the format:

alias shortname Firstname Lastname email@address.com

~/.mutt/cache/ – contains a cache my mail headers for faster access

~/.mutt/gpg.rc – contains the commands for use with pgp/gpg encryption

~/.mutt/lists.rc – contains the subscribe command for each mailing-list I am subscribed to.  The subscribe command makes Mutt behave differently when reading mailing-lists (changes the default reply-to to the mailing list).

~/.mutt/muttrc – the main configuration file.  It is heavily commented below for your convenience.

~/.mutt/muttrc.local{1,2,3} – supplemental configuration files used for when I switch email accounts.

~ %  cat ~/.mutt/muttrc

#==============================================================================#
set realname="Antony Jepson"    # My real name.
set sendmail="/usr/bin/msmtp"   # Sends the mail.
set edit_headers=no             # Can I edit headers of a message?
set index_format="%4C %Z %d %-15.15L (%-5c) %s" # Specify the index format.
# %4C - index number
# %Z - status flags
# %-15.15F - left justify the From: with a max of 15 characters
# %c - number of characters in the message
# %s - subject line

set date_format="%F"
set wait_key=no                 # Don't wait after using external programs.
set editor="vim + -c 'setlocal tw=72'" # Use vim as my default editor.
set signature="~/.signature"    # Set the default signature file.
#==============================================================================#
set alias_file=~/.mutt/aliases.rc  # Store aliases here.
source ~/.mutt/aliases.rc       # Source the aliases file.
source ~/.mutt/lists.rc         # Source the mailing-lists file.
source ~/.mutt/macros.rc        # Source the macros file.
source ~/.mutt/gpg.rc		# Source the GPG file.
set sort_alias=alias            # Sort the alias list (alphabetically).
set header_cache=~/.mutt/cache/ # Cache headers for speedier message reading.
#==============================================================================#
set folder=/home/antony/mail    # Default mail folder.
set mbox_type=Maildir           # Type of mbox (inbox).
set postpone=yes                # Postpone messages when not sent immediately?
set postponed=+drafts           # Where to store postponed messages.
set spoolfile=+inbox            # Replaces the environment variable $MAIL.
set copy=yes                    # Save a copy of messages?
#==============================================================================#
set include=yes                 # Include copy of message in reply?
set fast_reply=yes              # Prompt for recipients and subjects?
set beep=no                     # Beep when an error occurs?
set move=no                     # Do not move read messages.
set mark_old=no                 # New unread messages = old after exiting mbox?
set sort=threads                # How to sort messages in index menu.
set mail_check=60               # How often to check for mail (every hour).
set smart_wrap                  # Wrap long lines by words.
#==============================================================================#

# mailboxes - which folders receive mail and will be checked for messages.
mailboxes =inbox =quarantined =college

# my_hdr - Create custom header fields which are added to every message sent.
my_hdr From: Antony Jepson 

# ignore * - ignore all headers then specify only the ones wanted.
ignore *
unignore From:
unignore To:
unignore Reply-To:
unignore Subject:
unignore Date:
unignore CC:
unignore BCC:
unignore X-Virus-Status:

folder-hook .           set record="^"
# ^ = save sent messages in currently open folder

# hdr_order - specify the order to present headers.
hdr_order From: To: Reply-To: CC: BCC: Date: Subject: X-Virus-Status:

# pager_context - specify how many lines that are given when changing pages.
set pager_context=5

# pager_index_lines - specify how many lines of the index to show in the pager.
set pager_index_lines=7

# print_command - defines how should mutt print files
# First convert the file for printing with pr and then pipe the output to
# the printer (without a banner)
set print_command="/usr/bin/pr | /usr/bin/lpr -h"

#==============================================================================#
# custom colour scheme
color   hdrdefault      brightcyan      blue
color   header          brightwhite     blue  "^from:"
color   header          brightwhite     blue  "^subject:"
color   quoted          brightgreen     blue
color   signature       brightwhite     blue
color   indicator       blue            green
color   error           red             black
mono    error           bold
color   status          black cyan
mono    status          bold
color   tree            yellow          blue
color   tilde           blue            blue
color   body            brightwhite     blue  "[-a-z_0-9.]+@[-a-z_0-9.]+"
mono    body            bold                  "[-a-z_0-9.]+@[-a-z_0-9.]+"
color   body            brightyellow    black "^Good signature"
mono    body            bold                  "^Good signature"
color   body            brightwhite     red   "^Bad signature from.*"
mono    body            bold                  "^Bad signature from.*"
color   normal          white           blue
color   message         green           black
color   attachment      brightgreen     blue

Diagram

If you wondered how I created the diagram, it’s pretty simple:

tmp %  cat mutt.tex

\documentclass{article}
\usepackage[all]{xy}
\begin{document}

\xymatrix{
& aliases.rc \\
& cache/ \\
& gpg.rc \\
& lists.rc \\
.mutt \ar@/^/[uuuur]
      \ar@/^/[uuur]
      \ar@/^/[uur]
      \ar@/^/[ur]
      \ar[r]
      \ar@/_/[dr]
      \ar@/_/[ddr]
      \ar@/_1pc/[dddr]
      \ar@/_1.8pc/[ddddr] & macros.rc \\
& muttrc \\
& muttrc.local1 \\
& muttrc.local2 \\
& muttrc.local3
}
\end{document}

Take a look at my article on using Xy-pic for some more examples of its capabilities.