Mutt - Noah.org

Mutt

From Noah.org

Jump to: navigation, search

I use Mutt to read email. It's 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 takes a little bit more effort to begin with, but after a while I much prefer it to anything "modern". I started using Mutt because I got tired of slow email clients like Outlook and Thunderbird.

Mutt is text-only so it can make modern mail seem a little tricky sometimes, but it handles MIME attachments and HTML quite well. It can even read Word and PDF documents in Mutt without any trouble.

Below I document my Mutt configuration. I configured it so that the key bindings are a little closer to Vim.

Contents

Building Mutt

They finally added built-in SMTP support in version 1.5.15. I enable SMTP support so I can use a mail relay instead of relying on sendmail.

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

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"

My real muttrc file

I actually use a more complicated ~/.mutt/muttrc file that tweaks usability to make it more Vim-like. Mutt key bindings are already pretty close to Vim. See my dotfiles page.

# ~/.muttrc or ~/.mutt/muttrc
# This is a generic muttrc file.
# This is designed to not have any account specific information in it,
# so all my accounts can share the same base muttrc. For local overrides
# I put them in ~/.mutt/muttrc_local which is sourced at the end of this file.
# I usually put the following lines in my muttrc_local file:
#set use_from=yes
#set from="User Name <username@example.com>"
#set hostname="example.com"
#
# These are examples for setting up a connection to IMAP.
# I put these in ~/.mutt/muttrc_local file.
#
# Basic IMAP:
#set spoolfile="imap://username@example.com@imap.example.com/INBOX"
#
# Or if using a preconnect SSH tunnel use this:
#set preconnect="ssh -f -N -q -L 1143:localhost:143 username@imap.example.com"
#set spoolfile="imap://username@example.com@localhost:1143/INBOX"
#set imap_pass="not_the_best_password"

# SSL certs for IMAP are stored here.
set certificate_file="~/.mutt/known_hosts"
# set this if using Maildir format for local mail, but don't set this if using IMAP.
#set mbox_type=maildir

# This effects the default location of the cursor when Mutt starts Vim.
# Use the following 'editor' if you don't use a .signature file.
#set editor="vim +':set textwidth=77' +':set wrap' +\`awk '/^$/ {print i+2; exit} {i++}' %s\` %s" 
# Use the following if you have a .signature file. This assumes that 'sig_dashes' is yes.
set editor="vim +':set textwidth=77' +':set wrap' +\`awk '/^-- $/ {print i; exit} {i++}' %s\` %s" 

set mime_forward_decode=no
# see all mail headers in editor
set edit_headers=yes
# don't ask for To: and Subject: before switching to editor
set autoedit=yes
set sendmail_wait=10
# don't ask about purging deleted messages when quiting Mutt
set delete=yes
# this prevents Mutt from endlessly asking when you quit:
#     "Move read messages to ~/mbox? ([no]/yes):"
set move=no
# sort order in index view
set sort=mailbox-order
# sort order in file browser
set sort_browser=reverse-date
# this prevents Mutt from endlessly asking:
#     "~/Mail does not exist. Create it? ([yes]/no):"
# override this in mutrc_local if using IMAP. For example:
# set folder=imap://user@example.org@localhost/INBOX
set folder=/dev/null
# where to look for the header cache database
set header_cache="~/.mutt/headercache"
# for smooth scrolling
set menu_scroll=yes
# turn off asking to press a key after doing pipes
# set wait_key=no

ignore *
unignore Date: From: To: Cc: Subject: #Only these are shown in the header
hdr_order Date From To Cc Subject

#
# Color definitions
#
#color normal white default
color hdrdefault red default
color quoted brightblue default
color signature red default
color indicator brightyellow red
color error brightred default
color status yellow blue
color tree magenta default  # the thread tree in the index menu
color tilde magenta default
color message brightcyan default
color markers brightcyan default
color attachment brightmagenta default
color search default green  # how to hilite search patterns in the pager
color body magenta default "(ftp|http|https)://[^ ]+"   # point out URLs
color body magenta default [-a-z_0-9.]+@[-a-z_0-9.]+    # e-mail addresses
color underline brightgreen default
color header red black "^Date:"
color header red black "^From:"
color header red black "^To:"
color header red black "^Cc:"
color header red black "^Subject:"

set hidden_host=yes

# Use both Mutt aliases and Abook.
set alias_file=~/.mutt/aliases
source ~/.mutt/aliases
set query_command="abook --mutt-query '%s'"
macro index,pager A "<pipe-message>abook --add-email-quiet<return>"

# display the alias name if email address is found in aliases
set reverse_alias=yes
# save copies of outgoing mail
set copy
# use iso8601 dates
set date_format="!%Y-%m-%d %R%Z" 
# go directly to edit away when replying
set fast_reply 
set forward_format="Fwd: %s"
set history=100
# include original message when replying
set include 
set index_format="%4C %Z %{%b %d} %-15.15L (%4c) %s"
# check for new mail every 30 seconds
set mail_check=30
# mark new unread messages as old when leaving Mutt
set mark_old
# don't mangle wrapped lines (long URIs can be cut and pasted)
set nomarkers 
# don't move to the next message on next-page
set pager_stop 
# use format=flowed for text/plain emails
set text_flowed

# make Mutt's key bindings closer to Vim's
bind generic \Cu        half-up
bind generic \Cd        half-down
bind pager   \Cu        half-up
bind pager   \Cd        half-down
bind pager   b          half-up
bind pager   <Space>    half-down
bind index   \Cu        half-up
bind index   \Cd        half-down
bind generic G          last-entry
bind pager   G          bottom
bind index   G          last-entry
bind index   <Delete>   delete-message
bind index   j          next-entry
bind index   k          previous-entry
bind index   <Down>     next-entry
bind index   <Up>       previous-entry
bind generic <Space>    half-down
bind pager   <Space>    half-down
bind index   <Space>    half-down
bind index   <Left>     edit
bind index   <Right>    display-message
bind pager   <Left>     exit
bind pager   <Up>       previous-line
bind pager   <Down>     next-line
bind pager   <Right>    view-attachments
bind attach  <Left>     exit
bind generic <Home>     first-entry
bind generic <End>      last-entry
bind pager   <Home>     top
bind pager   <End>      bottom

# imitate the old search-body function
macro index \eb '/~b ' 'search in message bodies'

# simulate the old url menu
macro index \cb |urlview\n 'call urlview to extract URLs out of a message'
macro pager \cb |urlview\n 'call urlview to extract URLs out of a message'

# Show documentation when pressing F1
macro generic <f1> "!less /usr/share/doc/mutt-1.4.1/manual.txt\n" "Show Mutt documentation"
macro index   <f1> "!less /usr/share/doc/mutt-1.4.1/manual.txt\n" "Show Mutt documentation"
macro pager   <f1> "!less /usr/share/doc/mutt-1.4.1/manual.txt\n" "Show Mutt documentation"

push <show-version>
# always put the cursor at the last message when Mutt starts
folder-hook . 'exec last-entry' 

# personal settings go here -- I put my IMAP account settings here.
source ~/.mutt/muttrc_local

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

-->