Mutt: the least-bad mail client

Mutt is a powerful mailer somewhat like Elm, but better. There is a section about switching from Elm at the end of this page.

To use Mutt to read your mail, say

mutt

You then get a menu of commands, including "?" for "help," which gives you a list of many more commands. The commands are mostly pretty clear, except it may not be obvious that "g" for "group" means "reply to the group". This is really all you need to know. The rest of this is for those who want to do more than the minimum, or who want to know why it is worth doing.

Mutt has several nice features out of the box. It automatically folds long lines. It automatically makes quoted printable (the stuff with equal signs at the end of each line) readable. You can use it to edit messages with "e" after you have saved them or before you send them. I use this feature to write comments on student papers sent (as text) by email. You can also selectively delete attachments or parts (e.g., the redundant html parts of messages) with "v" (view attachments) and "d" (delete). You can also read attachments directly, and save some of them (doc files) in a much more compact format (text).

One thing not well documented is how to forward a message with attachments. One way is to bounce it (b). Another way is to go into the view menu (v), which allows you to view the list of attachments. The first one is the message itself. Then tag (t) all the parts you want to forward. While still in the menu, type ;f. The semicolon applies the forward command (f) to everything that is tagged.

Although Mutt is great as is, it is even better if you let your geek nature come out a bit, learn all the stuff it can do, and try to configure it. It is, to put it mildly, highly configurable. Here is a basic introduction to Mutt from Norman Matloff (which, again, you do not need to read in order to get started, since the basic commands are listed on the screen):

The full mutt manual is at http://www.mutt.org. But here are some other useful tidbits, or biscuits, as the case may be. (Mutt doesn't have bugs. It has fleas.) (See My First Mutt for another introduction that can also serve as a reference.)

You can also use Mutt to decode attachments of various sorts. For example, suppose you want to configure Mutt to read "html" files with Lynx (a browser that displays text only in a terminal window), "doc" files with "antiword" (a program on Mail.sas, which extracts the text), and "pdf" files with ps2ascii (which extracts the text, losing the formatting and images). The advantage of doing these things is that they are very fast and can be done in a terminal window.

A .mailcap file: To do these things write a .mailcap file (with the .). For example, using an editor like Pico or Emacs, write someting called .mailcap. The lines beginning with # are comments:

text/html; lynx -dump %s; copiousoutput; nametemplate=%s.html # decodes html messages text/plain; fold -s %s; copiousoutput # folds long lines automatically application/msword; antiword %s | more; copiousoutput; needsterminal # decodes Word documents application/rtf; unrtf --text %s | more; copiousoutput; needsterminal # decodes rtf documents application/octet-stream; antiword %s | more; copiousoutput; needsterminal # most "octet-stream" attachments are doc

Instead of
text/plain; fold -s %s; copiousoutput
you could try
text/plain; demoroniser.pl %s; copiousoutput
and copy (on mail.sas)
~baron/.bin/demoroniser.pl
to your own .bin directory. (If it doesn't exist, make it and add it to your path.) This translates Microsoft characters that arise from someone cutting and pasting from (e.g.) Word into a text email message.

A .muttrc file: The other thing you might want is a .muttrc file, which specifies your personal configuration. Here is one, with comments added with #, and with more lines than you might want:

auto_view text/plain text/html application/msword # see .mailcap section above auto_view application/rtf application/octet-stream alternative_order text/plain text/html # but read text first if it exists set abort_unmodified=no # allows sending of unmodified messages set askcc=yes # ask about cc set auto_tag=yes # make functions apply to all tagged messages set confirmappend=no # append to existing mailbox without asking set confirmcreate=no # save to new mailbox without asking set date_format="!%D %R" # include the year (with index_format) set index_format="%3C %Z %D %-15.15L (%4c) %s" # D means your timezone, not sender's set delete=yes # purge without prompting set fast_reply=yes # skips some prompts set folder="." # where to save messages set indent_string=">" # for forwarding set hostname="psych.upenn.edu" # for people with psych.upenn.edu addresses set use_domain=yes # adds hostname to all To: addresses without @ set mark_old=no # unread messages remain marked as new set metoo=yes # include me in group replies set pager_stop=yes # prevents automatically going to next message set sort=date # if you want to sort mailboxes by date ignore X # "ignore" is not printed in the header I see ignore List ignore Precedence ignore Errors source ~/.mutt.aliases # read in my aliases

The last line is my list of aliases, which you can see with:

more ~baron/.mutt.aliases

I like to separate the .muttrc file from the .mutt.aliases file because the latter is the same on all my computers, and the former is somewhat different.

The two lines about set hostname and set use_domain work together. When you send a message to somebody, without saying somebody@somewhere, the message goes to somebody@psych. This is useful for Psychology faculty, all of whom have a working email address of lastname@psych. For example, Dianne Chambless is dchamb, but also chambless@psych. If you have these two lines in your .muttrc file, you can use just chambless.

Name completion (from Warren Petrosky):

If you are using mutt, you can define a lookup query. We have a short script on mail.sas and web-facstaff called muttldap.pl, which can be used to query the public information from the Penn directory.

On mail.sas you would add this to your .muttrc:

set query_command = "/pkg/bin/muttldap.pl '%s'"

On web-facstaff you would use:

set query_command = "/usr/local/bin/muttldap.pl '%s'"

The integration with mutt is fairly nice. Type a name or partial name at the To: prompt, then hit ctrl-t to be given a list of full names and email addresses to choose from. This script can also be run from the shell to produce a list of matches.

A very useful command in Mutt is esc-C (alt or escape key with upper-case C). This is "decode copy". Decode-save, esc-s (lower case) is similar. If you have set Mutt to decode Word files with antiword, and/or html files with Lynx, and/or long lines with fold, you can save the decoded versions rather than the (quota killer) originals.

You might want to add application/octet-stream everywhere you have application/msword because this is how many people encode word documents (and add it to .mailcap too). However, octet-stream is used for other things too, so this depends on who sends you mail.

The Mutt web page has other examples of .muttrc files.

Getting color

Karl Morris makes the following suggestions for getting color using SecureCRT when you connect to a Solaris server (such as mail.sas):

Under the Options Menu, select Session Options.  Select
Emulation.  In the Terminal drop down menu, select ANSI, and
check the ANSI Color checkbox.  Thenk click ok.  Then, in your
terminal session (assuming that your session was already
started), at your command prompt type:

for bash shell:
$ TERM=ansi;export TERM

for csh/tcsh:
% setenv TERM ansi

Then at the command prompt, type:
reset

then reactivate Mutt and you should have color, if you've used the
color.muttrc file and have:
source "~/color.muttrc"
in your .muttrc file.

You can find color.muttrc on Google, but I'm not sure it is necessary.

Converting from Elm

Reasons to convert:
  1. Elm is buggy, and hasn't been developed or maintained in several years.
  2. mutt is very similar to elm, is actively being developed maintained, and has several additional features:
  3. elm users will need very few adjustments to using mutt

Converting aliases

One adjustment is converting your alises. To do this, first say cd .elm and then say (or cut and paste) one of the following:

elmalias -u -f "alias %a\t%n\t<%v>" | sed 's/,/>,</g' >> ~/.muttrc elmalias -u -f "alias %a\t%n\t<%v>" | sed 's/,/>,</g' > ~/.muttrc elmalias -u -f "alias %a\t%n\t<%v>" | sed 's/,/>,</g' >> ~/.mutt.aliases elmalias -u -f "alias %a\t%n\t<%v>" | sed 's/,/>,</g' > ~/.mutt.aliases The forms with ">" are if you do not already ahve a .muttrc or .mutt.aliases file. The forms with ">>" append to an existing file. Be very careful about ">"; if you have a file, that will wipe it out. The .muttrc vs. .mutt.aliases depends on where you keep your aliases (as discussed above).

Note 1: This has been tested and it works even with group aliases, but it may fail with some unusual configuration. Please ask Jon Baron for help if it doesn't work.

Note 2: Instead of using .muttrc, you might want to use .mutt.aliases, as explained above in the section on .muttrc.

Commands

Here is a list of command equivalents compiled by Vince Hurtubise: same: the key does the same thing in mutt use X: the key is not used for this purpose in mutt, but the key "X" is N/A: no equivalent in mutt Elm Key Meaning Mutt equivalent ---------- ------------------------------------------ --------------- <RETURN> Display current message same <SPACE> Display current message same | Pipe current message or tagged messages to same, but can a system command only pipe the current message ! Shell escape same $ Resynchronize folder same ? help screen(s) same + Display next index page use <RIGHT> - Display previous index page use <LEFT> = Set current message to first message same * Set current message to last message same <NUMBER><RETURN> Set current message to <NUMBER>, e.g, 10 same and then press <return> to go to message #10 / Search from and subjects for pattern same Note: / ~h scans all headers) // Search entire message texts for pattern / ~b > Save current message or tagged messages to a s folder Save current message or tagged messages to a use s to save folder the current message and ;s to save tagged messages < Scan current message for calendar entries N/A a Alias, change to 'alias' mode N/A a only creates aliases b Bounce (remail) current message same C Copy current message or tagged messages to a same folder c Change to another folder same d Delete current message same ^D Delete messages with a specified pattern use D e Edit current folder same f Forward current message same g Group (all recipients) reply to current same message h Headers displayed with message same; but h toggles on and off showing all headers J Advance to next message same j Advance to next undeleted message same K Decrement current message by one same k Advance to previous undeleted message same l Limit messages by specified criteria same ^L Redraw (refresh) screen same m Mail a message same M Read a message, using the MIME reader if use v appropriate n Display current message, then go to the next N/A undeleted message o Change ELM options edit ~/.muttrc p Print current message or tagged messages same q Quit, maybe prompting for deleting, storing, q is similar: and keeping messages q prompts for deleting, storing and keeping messages Q Quick quit - no prompting N/A ^Q Exit leaving folder untouched, ask permission use q if folder changed r Reply to current message same ^R Redraw (refresh) screen use ^L s Save current message or tagged messages to a s is similar: folder s saves the current message ;s saves tagged messages t Tag current message for further operations t is similar: t tags and goes to the next message T Tag current message and go to next message use t ^T Tag messages with a specified pattern use T u Undelete current message same ^U Undelete messages with a specified pattern use U x Exit leaving folder untouched, ask permission x is similar: if folder changed x leaves the folder untouched but does not prompt X Exit unconditionally, leave folder unchanged x <DOWN> Advance to next undeleted message same <LEFT> Display previous index page same <RIGHT> Display next index page same <UP> Advance to previous undeleted message same Jon Baron (with obvious help from Vince Hurtubise and Norman Matloff)