kaashif's blog

Programming, with some mathematics on the side

Configuring Mutt


On all of my computers, I like being efficient. That means eliminating everything which uses all that precious CPU time and using applications which are very customisable and configurable. These sorts of applications tend to be text-based, which is, in my eyes, a good thing, since they'll show you the information you need with a minimum of


Mutt is a text based email client, and I think it's very well suited to the task - generally, when reading emails, you are dealing with text. The few times there are images, they're usually annoying HTML emails from websites or as an attachment, meaning it's not integral to the viewing of the email body itself.

Now that you're sold on the idea of a text-only email client, we can get started installing, configuring, and using it.

Installing Mutt

Mutt should be in the package manager repository for your OS. On FreeBSD, you can install it with pkg install mutt. On Debian, it's apt-get install mutt. The command to run should be similar on most operating systems. If you're on Windows, I suggest you install Cygwin and build from source, since that's really the only way you can get Mutt.

Configuring Mutt

If you just run mutt, you'll see that you've opened the local mail box for your current user. In decades past, local mail was actually really important - people sent mail to and from each other's servers, not centralised servers like Outlook or Gmail. In any case, you don't want this - you likely want to access your Gmail account, which is what I'll be showing you how to do. The instructions for Yahoo or Outlook should be similar, but consult their help pages for the server address and port.

You need to create/edit the file ~/.muttrc and input the following:

# The bit before @gmail.com in your address
set imap_user = "myname" 

# Google's IMAP server, used to view mail
set folder = "imaps://imap.gmail.com:993"

# Google's SMTP server, used to send mail
set smtp_url = "smtp://myname@smtp.gmail.com:587/"

# Displayed in the "from" field of your mail
set from = "myname@gmail.com"

# Change this to your preferred editor
set editor = "vim + -c 'set textwidth=72' -c 'set wrap'"

# Sets your default inbox to the one on the IMAP server
set spoolfile = "+INBOX"

# Makes sure all your folders are polled for new mail
set imap_check_subscribed=yes

# Interval to check for new mail
set mail_check = 120

# Time to wait for server if connection drops
set timeout = 300
set imap_keepalive = 300

# Where Mutt keeps drafts
set postponed = "+[GMail]/Drafts"

# Mutt's cache settings, important for speed
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies

# Where mutt stores SSL certificates
set certificate_file=~/.mutt/certificates

# Mutt will never move mail from Gmail to your local mailbox
set move = no

# Include message you're replying to in the reply
set include

# Sorting by threads is very useful for keeping your mail in order
set sort = 'threads'
set sort_aux = 'reverse-last-date-received'

# Sets the height of the window opened to view a message
set pager_index_lines = 10

# I prefer not to show some of the headers, they get in the way
ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc

# A useful key binding to refresh your inbox
bind index "^" imap-fetch-mail

That might seem like a lot of variables, but they're all well-named and well-documented in Mutt's online manual. The manual is very extensive, and documents every variable you see above.

Opening Mutt and logging in

With the settings above, you're all set to open Mutt again. Type mutt into a terminal and you'll see a prompt telling you whether to accept Google's SSL certificates. Press "a" for "accept always" a few times until all the certs are accepted.

Next, you'll see a password prompt, like this:

Password for kaashifhymabaccus@gmail.com@imap.gmail.com:

Of course, type in your password, and it'll be sent off over an SSL connection to Google's IMAP server.

If all goes well, the next thing you see should be your inbox. If it hasn't worked, I advise that you ask on an IRC channel. Although it isn't strictly related to Arch, #archlinux on irc.freenode.net is very, very active, so you're likely to get an answer there.

Using Mutt

You can use the up and down arrow keys to scroll through the mail, as well as the standard Page Down and Page Up keys. You can also type in a number and a prompt should appear like this:

Jump to message: 1

If you look ot the far left of Mutt, you should see a column of numbers. Type in any one of those, and Mutt will jump to it.

If you want to open a message, press enter over one, and the bottom 4/5 of the screen should display the message, with the message inde open in the top 1/5.

When you're at the index (the screen you see just after loggging in), you should see this at the top:

q:Quit  d:Del  u:Undel  s:Save  m:Mail  r:Reply  g:Group  ?:Help

You'll see bars like this at all screens of Mutt, so press "?" if you forget what a key does.

To send a message, press "m". You'll have to say who it's for and what it's subject is, then your editor will open, where you can type out the body of the message. It's best to keep the message to 72 columns wide, to maximise viewing pleasure for everyone involved.

After quitting your editor, you'll be taken to a screen with this at the top:

y:Send  q:Abort  t:To  c:CC  s:Subj  a:Attach file  d:Descrip  ?:Help

It should be obvious how to send the mail or change the headers.

If you use mailing lists a lot (like I do), then you'll want to change mailboxes. You do that by pressing "c", typing "=mymailbox", and pressing enter. Of course, replace "mymailbox" with the actual name of the mailbox.

At this point, you should be able to use your new email client for most day-to-day tasks. If you need to do something more advanced, you should look at the manual I linked earlier.

For other interesting and useful text-based programs, this blog isn't a bad place to go.