Desktop in a shell: mutt

Continuing my series about a desktop in a shell, today I will present you my mutt setup. I use mutt because it has no bugs and is a really good MUA for people loving consoles ;) First of all you have to know, that all my mail is forwarded to my server and sorted into Maildirs via maildrop, so I do not care about sorting on my "desktop", which just fetches the mail via IMAP from the server ;) I'm running mutt-patched from Debian Squeeze, so not all options may be available for you if you do not have the same patchset as I do. First, tell mutt to fetch mail from imap.die-welt.net via IMAP:

set imap_user=username
set imap_pass=password
set folder="imaps://imap.die-welt.net/INBOX"
set spoolfile="imaps://imap.die-welt.net/INBOX"
Now, enable IMAP-IDLE, list subscribed folders, reconnect to the server if needed and mark mail as read when you open it:
set imap_idle
set imap_check_subscribed
unset imap_passive
unset imap_peek
Let mutt save sent mail to the Sent directory on the IMAP server, and postponed mail to Drafts:
set record=+Sent
set postponed=+Drafts
Read mail should stay where it is:
set mbox="!"
We use IMAP-IDLE, thus check for new mail manually only every 90 seconds:
set mail_check=90
Instead timeout after 15 seconds if no user input is given:
set timeout=15
Set default mail from address to my default mail address:
set from=evgeni@golov.de
And send mail via mstmp (see below for mstmp configuration):
set sendmail="/usr/bin/msmtp"
Tell mutt which addresses I recieve mail to (danger, ugly regex!):
alternates (evgeni@(debian.org|golov.(de|eu))|sargentd@(die-welt|sargentd).net|evgeni.golov@uni-duesseldorf.de)
As mutt knows where I receive mail, let it set From accordingly:
set reverse_name
Let mutt cache some stuff and find its certificates:
set header_cache="~/.mutt/cache/headers"
set message_cachedir="~/.mutt/cache/bodies"
set certificate_file=~/.mutt/certificates
set ssl_ca_certificates_file=/etc/ssl/certs/ca-certificates.crt
Show only interesting headers in an useful order:
ignore headers *
unignore headers from to subject date cc
hdr_order from to cc subject date
Fix stupid MUAs behaviour (e.g. filenames like =?iso-8859-1?Q?file=5F=E4=5F991116=2Ezip?=):
set rfc2047_parameters
Beep on new mail, will generate a "!" in the window name in screen:
set beep_new
mutt-patched has the great sidebar patch, assign ctrl-n, ctrl-p to select next, prev folder, ctrl-o to open selected folder:
bind index \Cp sidebar-prev
bind index \Cn sidebar-next
bind index \Co sidebar-open
And toggle sidebar visibility with ctrl-b:
macro index \Cb '<enter-command>toggle sidebar_visible<enter><refresh>'
macro pager \Cb '<enter-command>toggle sidebar_visible<enter><redraw-screen>'
Since 1.5.20-2, mutt patched contains my sidebar-dotted and sidebar-sorted patches. Let mutt shorten the displayed path (e.g. debian-devel instead of INBOX.ml.debian-devel) and sort the folders (the are returned in random order when using imap_check_subscribed):
set sidebar_shortpath
set sidebar_sort
Now let's set some colors (that match the rest of my "desktop"):
color sidebar_new yellow default
color normal white default
color hdrdefault brightcyan default
color signature green default
color attachment brightyellow default
color quoted green default
color quoted1 white default
color tilde blue default
And add some useful macros for marking new and old messages as read:
macro index .n "<tag-pattern>~N<enter><tag-prefix><clear-flag>N<clear-flag>*" "Catchup all new messages"
macro index .o "<tag-pattern>~O<enter><tag-prefix><clear-flag>O<clear-flag>*" "Catchup all old messages"
When forwarding mail, I like it to be forwarded as an attachment (YMMV):
set mime_forward=yes
I'm using goobook in mutt to fetch my addressbook from Google. As there is no Debian package for goobook (yet), you have to install it yourself (via easy_install):
apt-get install python-argparse python-gdata python-simplejson python-keyring python-nose
easy_install goobook
Configuration is easy via ~/.goobookrc:
[DEFAULT]
# If not given here, email and password is taken from .netrc using
# machine google.com
email: me@gmail.com
password: password
And then add the following to your .muttrc:
set query_command="goobook query '%s'"
bind editor  complete-query
macro index,pager a "<pipe-message>goobook add<return>" "add the sender address to Google contacts"
That's all for mutt, but... We are running mutt in a screen, so let's add the following to .screenrc to fix transparency and cut&paste (see http://wiki.mutt.org/?MuttFaq/Appearance):
 defbce on
 term screen-bce
And as mutt uses mstmp (yes, I know, mutt can handle SMTP itself...), this is my .msmtprc:
defaults
domain dorei.kerker.die-welt.net
tls on
account die-welt.net
host smtp.die-welt.net
from sargentd@die-welt.net
auth on
user username
password password
tls_starttls on
tls_certcheck off
# Set a default account
account default : die-welt.net
C'est tout! That is my personal mutt configuration, you can download it as one file here: my .muttrc. And as everyone loves screenshots, here is one: the default view of my mutt Oh, the next chapter will be about irssi, but not before next Sunday (March 6th) as I'll be offline for a week, skiing in Austria :)

Comments

MrJoel wrote on 2011-02-25 15:43:

What is the advantage of set mbox=”!” instead of set move=no?

evgeni wrote on 2011-02-25 15:44:

I guess there is none :)

jve wrote on 2011-02-25 16:35:

Alright, your article convinced me to give mutt a 2nd/3rd shot. We’ll see how it competes with roundcube.

zobel wrote on 2011-02-27 22:26:

Hi Evgeni,

i found a very nice way recently to not have the IMAP password in clear text in the .muttrc. This requires gnome and the gnome-keyring though.

a) Fetch gnome-keyring-query.c from http://www.gentoo-wiki.info/HOWTO_Use_gnome-keyring_to_store_SSH_passphrases and compile it. I put the binary in my $HOME/bin.

b) Set the following in your .muttrc:

set my_pw_ftbfs=`~/bin/gnome-keyring-query get mutt_ftbfs`

account-hook ftbfs.de ‘set imap_user=zobel@ftbfs.de imap_pass=$my_pw_ftbfs’

c) Now set the password in the gnome Keyring:

# echo “yoursecretpassword ” | ~/bin/gnome-keyring-query set mutt_ftbfs

Yes, gnome-keyring-query could be a bit smarter, but it works for me quite well.

evgeni wrote on 2011-02-27 22:38:

Hi Martin, goobook supports gnome-keyring via python-keyring too. I should have a look at it. Thanks for the tip.

Screwtape wrote on 2011-02-28 02:13:

I’d long given up using mutt at $EMPLOYER because of strange crashes and hangs – reading your guide, I’m betting the problem is that I left ‘timeout’ (and perhaps ‘imap_passive’) set at the default. I’ve changed my config and I’m going to try it out!

Thanks very much!

Jubal wrote on 2011-03-03 15:42:

Evgeni,

This looks really nice (and mutt is blazingly fast when you compare it to other IMAP clients); I might give it another try now…

There’s one small problem, though – it seems that your ‘sidebar dotted’ patch assumes that the folder name has to start with INBOX (and thus does not shorten any non-INBOX-contained hierarchies I’m using). Perhaps adding a configuration option to set the hierarchy prefix or prefix list (preferably using a regexp) would be a solution here?

Send your comments to evgeni+blogcomments@golov.de and I will publish them here (if you want).