Mutt

From Noah.org
Revision as of 04:35, 16 September 2010 by Root (Talk | contribs) (Building Mutt)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

I use Mutt to read email. Mutt is a command-line email client. It's super fast and works anywhere I can get to a shell. It's like Vim for email. It took a little bit more effort at the beginning, but after a while I much prefered it to anything "modern". I started using Mutt because I got tired of slow email clients like Outlook and Thunderbird. I just wanted my email to pop open instantly. Even when I kept Thunderbird running in the background it would take more than a blink for the window to restore when I needed it.

Mutt is text-only so it can make modern mail seem a little tricky sometimes, but it handles MIME attachments and HTML quite well. Mutt can even read Word and PDF documents without much trouble. Below is documentation for my Mutt configuration. I configured it so that the key bindings are a little closer to Vim.

A very good page that documents a more advanced Mutt configuration can be found at Gary Johnson's Mutt Page.

Abook

For some reason I always forget that CTRL-T is used to access the Abook from the Mutt "To:" line.

Building Mutt with built-in MTA

Mutt added built-in SMTP MTA support in version 1.5.15. I enable SMTP support so I can use an external mail relay instead of relying on sendmail. A simple mail relay MTA is trvially easy to write -- I could write one in Bash -- but requiring that I also run Sendmail or soME other MTA is stupid. Thankfully Mutt finally relented from the "pure" philosophy that a mail client shouldn't also be an MTA

Note that as of Ubuntu 8.04 the Mutt package provides version 1.5.17, so building Mutt from source is not necessary, but if you are on some other platform and you need to build Mutt from source then the following notes should help.

apt-get install libncurses5-dev
./configure --enable-pop --enable-imap --enable-smtp --enable-hcache --with-ssl
make
make install

Saving attachments easily

Mutt ignores the environment umask and saves all attachment files with umask 077. There is not option you can set to override this. This is stupid. At any rate, here is a fairly not too ugly hack to get around this flaw. This assumes you want to save all attachments in the following path: '~/a/'. This macro binds to the S key while under attachment view. Add the following to your muttrc config file:

macro attach S <save-entry><bol>~/a/<enter><shell-escape>chmod\ -R\ 666\ ~/a/.<enter>

Mutt error

If you get an error like this then you forgot to use --enable-ssl in your configure step.

Error in /home/user/.mutt/muttrc, line 23: certificate_file: unknown variable

The configure help doesn't show this option, but certificates wouldn't work without it for me.

Basic .muttrc or ~/.mutt/muttrc

This is a .muttrc. This is nothing fancy. This seems to be the minimum to get Mutt working with IMAP. For more documentation go to Mutt documentation.

set mbox_type=maildir
set editor="vim"
# I like to see all my mail headers in my editor:
set edit_headers=yes
# don't wait for sendmail to finish (this runs sendmail in the background)
set sendmail_wait=-1
# this prevents Mutt from endlessly asking when you quit:
#     "Move read messages to ~/mbox? ([no]/yes):"
set move=no
# this prevents Mutt from endlessly asking:
#     "~/Mail does not exist. Create it? ([yes]/no):"
set folder=""
# if you use virtual mail hosts then Maildir might not
# be in the default location... try looking in:
# /home/vpopmail/domains/example.com/$USER/Maildir/
set spoolfile=~/Maildir/

# IMAP
# For IMAP connections use the following settings.
# Some settings replace those used above for folder and spoolfile.
# Note that the full mail username is "username@example.com" and
# the server name is "localhost". If you wanted to connect to a
# remote server the full URL might be something like:
#     imap://username@example.com@example.com
set folder="imaps://username@example.com@localhost"
set spoolfile="imaps://username@example.com@localhost/INBOX"
set imap_pass="my_stupid_password"
set certificate_file=".mutt_known_hosts"

~/.mailcap file

This helps Mutt to read a few other non-text MIME types common in file attachments.

<include src="http://www.noah.org/engineering/dotfiles/.mailcap" />

My real muttrc file

For my daily use I use a slightly more complicated muttrc file that tweaks usability to make it more Vim-like. Mutt key bindings are already pretty close to Vim, but there are a few other bindings that make Mutt feel even more like home. See the dotfiles page for more info about dotfiles. The following should be put in ~/.mutt/muttrc with 600 for permissions.

<include src="http://www.noah.org/engineering/dotfiles/.mutt/muttrc" highlight="sh" />

mairix

This is an interesting Linux email indexer. What I really want is a big email database. Maybe I should just dump all my email into MySQL. http://www.rpcurnow.force9.co.uk/mairix/index.html