Difference between revisions of "Mutt"

From Noah.org
Jump to navigationJump to search
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:Engineering]]
 
[[Category:Engineering]]
 +
[[Category:Mail]]
 +
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.
  
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.
+
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.
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
+
A very good page that documents a more advanced Mutt configuration can be found at [http://www.spocom.com/users/gjohnson/mutt/ Gary Johnson's Mutt Page].
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.
+
== 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.
  
== Building Mutt ==
 
They finally added built-in SMTP support in version 1.5.15.
 
 
<pre>
 
<pre>
 
apt-get install libncurses5-dev
 
apt-get install libncurses5-dev
Line 17: Line 22:
 
make
 
make
 
make install
 
make install
 +
</pre>
 +
 +
== 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:
 +
 +
<pre>
 +
macro attach S <save-entry><bol>~/a/<enter><shell-escape>chmod\ -R\ 666\ ~/a/.<enter>
 
</pre>
 
</pre>
  
 
== Mutt error ==
 
== Mutt error ==
 +
 
If you get an error like this then you forgot to use --enable-ssl in your configure step.
 
If you get an error like this then you forgot to use --enable-ssl in your configure step.
 +
 
<pre>
 
<pre>
 
Error in /home/user/.mutt/muttrc, line 23: certificate_file: unknown variable
 
Error in /home/user/.mutt/muttrc, line 23: certificate_file: unknown variable
 
</pre>
 
</pre>
 +
 
The configure help doesn't show this option, but certificates wouldn't work without it for me.
 
The configure help doesn't show this option, but certificates wouldn't work without it for me.
  
 
== Basic .muttrc or ~/.mutt/muttrc ==
 
== Basic .muttrc or ~/.mutt/muttrc ==
 +
 
This is a .muttrc. This is nothing fancy.
 
This is a .muttrc. This is nothing fancy.
 
This seems to be the minimum to get Mutt working with IMAP.  
 
This seems to be the minimum to get Mutt working with IMAP.  
Line 61: Line 78:
 
set certificate_file=".mutt_known_hosts"
 
set certificate_file=".mutt_known_hosts"
 
</pre>
 
</pre>
 +
 +
== ~/.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 ==
 
== 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.
 
  
<include src="http://www.noah.org/engineering/dotfiles/.mutt/muttrc" />
+
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

Latest revision as of 05:35, 16 September 2010

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