01/06

An Introduction to Mutt

20110106

It seems as though every time someone sees me at my desk reading my mail, they ask what it is I am doing. I tell them I am reading my mail, and they're shocked. They see me pull up image attachments, and office and all this, and they think I am some kind of wizard. "How is it that you can do that in command line?" they ask. "I use Mutt."

Alright, Mutt is a little different from other email applications. First, it's an MUA (Mail User Agent), and it typically relies on an MTA (Mail Transport Agent). These days, this is no longer entirely accurate. Mutt can be used without an MTA if your email provider uses SMTP and IMAP. On Slackware and similar systems, you will need to specify some compile options. This is because on Slackware, the precompiled binary included in the distribution does not have IMAP and SMTP support enabled. A very simple configuration might be something like this

./configure --enable-imap --with-ssl --enable-smtp \
--enable-hcache --with-sasl && \
make && \
sudo make install

On Ubuntu (which is the African word for "cannot configure Debian"), or on Debian or on Mint the process is a bit simpler.

apt-get install mutt

On Macintosh OS X, you will need macports. Once you have macports installed just do:

sudo port install mutt-devel +compress +date_conditional \
+deepif +gdbm +gpgme +headercache +idn +sidebar +smtp +ssl +trash +sasl

Once you have Mutt installed, we are ready to continue.

Mutt will require us to write two different files, and create two directories. The first file is the muttrc, which acts as our mutt configuration file. The second file is the mailcap file, which tells mutt how to handle certain types of data (mostly how to handle attachments). The two directories are ~/mutt and ~/mutt/cache. I prefer to use ne (the nice editor) as my text editor, but you can use any editor you wish throughout this tutorial.

Let's start with the directories.

mkdir -p ~/.mutt/{cache,mail}

That was easy wasn't it? Now let's move on to our muttrc file.

vim ~/.muttrc

########################
# LOCAL FILES AND SUCH #
########################

set mbox_type=Maildir
set folder=~/.mutt/mail
set signature=~/.sig
set mailcap_path=~/.mailcap
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates
mailboxes =Inbox =Sent =Trash

########
# SMTP #
########

set smtp_url="smtp://yourUserName@yourProvider.org@yourProviderServer.org:587/"
set smtp_pass="yourPasswordHere"
set from="yourUserName@yourProvider.org"
set realname="Your Name"
set smtp_authenticators = ‘gssapi:login’

########
# IMAP #
########

set imap_user="yourUserName@YourProvider.org"
set imap_pass="yourPasswordHere"
set folder="imaps://yourUserName@yourProviderServer.org/"
set postponed = "+Drafts"
set spoolfile="imaps://yourUserName@yourProviderServer.org@yourProviderServer.org/INBOX"
set record = "+Sent"
set imap_pipeline_depth=0

###################
# VARIOUS OPTIONS #
###################

set timeout=10
set mail_check=10
set sort=threads
set sort_aux=reverse-date-received
set move=no
set mark_old=no
set editor=vim
set markers=no
set include=yes
set forward_format="Fwd: %s"
set ssl_force_tls=yes
set ssl_starttls=yes
set copy=yes
set sig_on_top=yes 
auto_view text/html

##########
# COLORS #
##########

color normal     white        default
color attachment brightyellow default
color hdrdefault cyan         default
color indicator  brightred    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      yellow       default "~N"
color index      yellow       default "~U"

#############################
# HIGHLIGHT IMPORTANT STUFF #
#############################

color index magenta default '~f someone@reallyImportantPlace.org'

# EOF

Let's move on to the mailcap file.

text/html; echo && /usr/bin/w3m -dump %s; nametemplate=%s.html; copiousoutput
application/pdf; /usr/bin/evince %s
image/jpg; /usr/bin/display %s
image/gif; /usr/bin/display %s
image/jpeg; /usr/bin/display %s
image/png; /usr/bin/display %s
application/vnd.ms-powerpoint; soffice %s
application/x-mspowerpoint; soffice %s
application/ppt; soffice %s
application/excel; soffice %s
application/msexcel; soffice %s
application/vnd.ms-excel; soffice %s
application/x-excel; soffice %s
application/x-msexcel; soffice %s
application/ms-Excel; soffice %s
application/msword; soffice %s
application/vnd.msword; soffice %s

There are some things you are likely going to change here. If you are using a KDE based distribution, you would want to change 'soffice %s' to something like 'kword %s'. If you have a favorite image application, you may want to change '/usr/bin/display %s' to something like 'zgv %s'. If you are on an older distribution, evince may not be your PDF reader. In that case try 'xpdf %s' or 'kpdf %s'. You can also add things here for music, video, or pretty much anything else you think that you may get via email attachment.