Mutt at CERN
Installing, setting up and using mutt at CERN, as a regular user on interactive login services, and enabling those features which make e-mail terrific.
Mutt is a fast, convenient mail client offering powerful search and filtering tools and allowing you to compose messages with any editor you like. And it supports password-less authentication with Kerberos.
It doesn't seem to be particularly supported at CERN, although I certainly got help when I asked for it. The mutt
build installed in lxplus/aiadm doesn't seem to play well with Kerberos either, the authentication failing after hanging for a long time. This guide describes how to build and use mutt in lxplus/aiadm. It include some of the nicest features which make e-mail terrific in communication.
1 Installation
1.1 Version
At the time of writing, the officially stable version is mutt 1.4.2.3. However, it is also distributed in a development version, mutt 1.5.24 now, which is perfectly stable and adds interesting features.
1.2 Unnecessary chgrp in Makefile
The Makefile will attempt to run chgrp
even if you mean to install mutt locally without root privileges. This won't work, and it doesn't have to anyway. Open Makefile.in
in an editor, find the unique line with chgrp
in it and just delete it without further ado.
1.3 Build
A number of features should be enabled for a comfortable setup:
./configure --prefix ~/private/mutt --enable-imap --enable-pop --enable-smtp --with-ssl --enable-hcache --with-gss
make
make install
The --enable-gss
option is the key to enable Kerberos authentication.
1.4 SASL
Note that we haven't specified --with-sasl
, even though it would have normally been necessary to support SMTP. But it's exactly what makes the /usr/bin/mutt
installed by default in lxplus/aiadm hang forever trying to authenticate with Kerberos before failing. It seems that the way mutt does SASL disagrees with CERN mail servers.
We need another way to have mutt send mail, then, and that's msmtp. The latest version 1.6.3 that I tried at the time of writing works fine. But before building it, you'll need to change a constant in src/smtp.c
to cope with the apparently unusually long commands involved in talking to the CERN SMTP servers. Look for the SMTP_MAXCMDLEN
constant which you'll set as follows:
#define SMTP_MAXCMDLEN 16384
Then build and install as usual:
./configure --prefix ~/private/mutt
make
make install
2 Basic Config
It all takes place in ~/.muttrc
(except when it doesn't, as with msmtp, for instance).
2.1 Reading Mail
set folder=imaps://username@imap.cern.ch
set spoolfile=+INBOX
Set the spoolfile
variable to automatically open your INBOX. Note how you can conveniently use folder
to be able to use +
at the beginning of a path to expand it to that.
2.2 Sending Mail
As mentioned before, we'll have mutt send mail with msmtp, and you need to write an ~/.msmtprc
file. It may not look as such, but it's as canonical as it gets:
defaults
tls on
tls_trust_file /etc/ssl/certs/ca-bundle.crt
port 587
account cern
host smtp.cern.ch
from Firstname.Surname@cern.ch
auth gssapi
user username
Annoyingly enough, you'll want to set the from
field in both msmtp – because it's a compulsory command – and mutt – because it effectively sets that field. And of course you need to tell mutt to use msmtp. So back in ~/.muttrc
:
set from='Firstname.Surname@cern.ch'
set sendmail='~/private/mutt/bin/msmtp --account=cern'
3 Editing Mail Comfortably
If there's one thing that will make you love e-mail, it's the ability to write with any editor your fancy – mutt offers this sensible option:
set editor=vim
set autoedit
set edit_headers
The autoedit
and edit_headers
variables work together so you're not prompted for subject and recipients, but allowed to edit these with your editor too. A world of possibilities unfolds before you.
4 Clever Use of Folders
Use the postponed
variable to specify where your drafts should be kept. The record
variable specifies where sent mail should go: attracted to the Google Mail way of showing incoming and outgoing mail in the same view, I thought I'd set that to my INBOX too; this was a revelation, especially with threading, and I've been very happy to have this setup for years, now:
set postponed=+Drafts
set record=+INBOX
5 Performance Tips
These handful of settings are good enough to make working with mutt a smooth experience even with an INBOX of more than 70000 messages.
5.1 Caching
set header_cache=~/.muttcache
Headers can be cached in two ways: in a single file or multiple ones. If you work with multiple instances of mutt, it is useful to have multiple ones to avoid locking. To enable this, make sure you create a cache directory before mutt gets a chance to create a single file with the name set in header_cache
:
mkdir ~/.muttcache
5.2 Reactive Interface
The sleep_time
variable can be set to remove what I deem an unnecessary pause for displaying status messages:
set sleep_time=0
While it might be tempting to have mutt check mail regularly, it does make it frequently unresponsive whenever it does so. Let's be honest, checking mail every minute is more than often enough:
set mail_check=60
6 Window Manager Integration
A beep upon incoming mail might be considered as annoying at length, but not when mutt runs in a terminal setting an urgency hint when the bell rings:
set beep_new=yes
In some window managers like Notion, this allows you to jump to your mail window when you're receiving something and back again in a jiffy.
7 References
- The Mutt E-Mail Client official website
- msmtp
- Mutt - ArchWiki, as always, clear and full of nifty tricks
- Mutt configuration:
spoolfile
,folder
,autoedit
,edit_headers
,postponed
,record
,header_cache
,sleep_time
, - CERN Mail Services and support of mutt