An Introduction to Mutt

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," I reply. I have done an article on Mutt before, and I will do it again for clarity's sake.

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

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

vim ~/.muttrc
# SENDING MAIL
set copy=yes
set smtp_url="smtp://user@smtp.gmail.com:587/"
set smtp_pass="password"
set from="user@gmail.com"
set realname="User User"
# RECEIVING MAIL
set imap_user="user@gmail.com"
set imap_pass="password"
set folder="imaps://imap.gmail.com:993"
set spoolfile="imaps://imap.gmail.com/INBOX"
set record="imaps://imap.gmail.com/Sent"
set postponed="imaps://imap.gmail.com/Drafts"
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates
# LOCAL FOLDER
set mbox_type=Maildir
set folder=~/Mail
# READING MAIL
set timeout=10
set mail_check=10
set sort=threads
set sort_aux=reverse-date-received
set move=no
set mark_old=no
# COMPOSING MAIL
set editor=vim
set markers=no
set signature=~/.sig
set include=yes
set forward_format="Fwd: %s"
# VIEWING ATTACHMENTS
set mailcap_path=~/.mailcap
auto_view text/html
# OOH PRETTY 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 brightyellow default ~N
color index yellow default ~O
color index magenta default '~f foo@example.com'

In the above example, everything is set up for GMail's servers in particular. You would need to change things according to your email provider's server settings. For example, ports, URLs, and server folders are going to be different if you use Charter's email.

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.


© MMIX - MMXVII absurd.wtf
Licentiam Absurdum