home | pop3spam | mutt | brainfuck | exprt | vpn | pgp key | deutsch | qwerty | no disclaimer
mutt ]
Introduction
  mutt is a text based email client which has been programmed by Michael Elkins. It has nearly all the abilities one can expect from a mail user agent.

Here are just a few ones:

  • mutt is fast and doesn't require much memory
  • it can be configured very extensively
  • keybindings are individually adjustable
  • macros facilitate input of command sequences
  • mail-threading provides clearly structured mail history
  • each object can be assigned any desired color

In the following I'll describe the most important options to adapt mutt to each individual user's preferences for an easy and efficient use.

Overview
 base configuration
color configuration
keybinding configuration
convert pine's addressbook to mutt's aliases format
cut off signature automatically
easy and beautified reply
newsgroups and mailing lists
links
Base configuration 
  First we'll configure the most important settings in the local config file ~/.muttrc to use mutt in a rational way.

  • You can download the configuration below in text format
# Let's determine your full name and email address:
set from="Forename Surname <your@emailaddress.domain>"

# In case that your hostname won't be detected correctly you can explicitly set it here:
set hostname="yourhostname.domain"

# To avoid problems with German special characters use the character sets ISO-8859-1 or ISO-8859-15:
set charset="ISO-8859-1"

# Here you can determine your favorite editor for writing messages:
set editor="/usr/bin/vim"

# Skip the bothering prompt for recipient and subject when replying and start immediately with writing your message:
set fast_reply="yes"

# Always quote when replying:
set include="yes"

# Mail that belongs together should be displayed in a thread-tree:
set sort="thread"

# Here you can determine your personal attribution line. This string always precedes quoted text. (Take a look at all possible tokens):
set attribution="* %n <%a> wrote:\n"

# Set format of %d. You can use this in your attribution line. (See strftime(3) man page for more infos):
set date_format="%A, %d.%m.%y at %H:%M"

# The quoting character can be set individually, too:
set indent_string="> "

# Scrolling line by line in index mode is really a cool thing, isn't it:
set menu_scroll="yes"

# Also very useful in pager mode (even the number of scrolling lines can be set):
set pager_context="1"

# Mutt can split the screen into halves, so you can watch index + pager simultaneously:
set pager_index_lines="5"

# Don't jump to next message when at bottom of current message:
set pager_stop="yes"

# Here you can define the location for copies of all outgoing mail:
set record="~/outbox"

# Which MTA (Mail Transport Agent) shall be used for delivering mail:
set sendmail="/usr/sbin/sendmail -oem -oi"   # sendmail
set sendmail="/var/qmail/bin/sendmail -oem -oi"   # qmail

# Location of your .signature file:
set signature="~/.signature"

# Unless your signature file already contains sigdashes "-- " (without quotation marks) you should enable this option:
set sig_dashes="yes"

# Determine the location of your spool file. All incoming mail is stored there:
set spoolfile="/var/spool/mail/yourloginname"   # sendmail
set spoolfile="~/Mailbox"   # qmail

# All aliases are stored in this file (more about aliases):
set alias_file="~/.aliases"

# To initialize the aliases file at startup you have to explicitly define it here:
source ~/.aliases

# In the first step we are going to weed all headers:
ignore *

# In the second step we remove the desired headers from the ignore-list:
unignore date: from: to: subject: cc: user-agent: x-mailer:

# Finally we specify the order for displaying headers:
hdr_order date: from: to: subject: cc: user-agent: x-mailer:

Color configuration 
  If you did everything correctly mutt should already be quite usable. However, there are a couple of things which are worth taking a closer look at. First we will unshackle mutt from its monotony existence and make it somewhat more colorful.

The syntax for color assignment is as follows:

color object foreground background [pattern]

  • If you want to know more about this see colors
# First we will set the default color of foreground and background:
color normal white default

# Sets the default color of all header entries:
color hdrdefault brightblack default

# Assuming that you would like to highlight some headers:
color header brightblue default "^from:"
color header brightblue default "^subject:"
color header brightred default "^user-agent:"
color header brightred default "^x-mailer:"

# Errors will be printed in red color:
color error red default

# Sets colors for different quoting levels:
color quoted green default
color quoted1 yellow default
color quoted2 brightblue default

# Color of highlighted bar or arrow which marks the focused message:
color indicator default blue

# Here you can determine the color of thread-trees:
color tree green default

# Assigns color of headline and footline from which you get various information:
color status black red

# Highlights signature in color:
color signature brightblack default

# Displays new messages in another color:
color index red default ~N

Keybinding configuration 
  At this point we'll set some keybindings. Mutt can be configured almost limitless to suit all individual tastes. I have bound the elementary navigation functions (mail selection, mail navigation, etc.) in vim style. If you don't use vim (or a vi clone) at all or maybe you do but you're one of those guys who use the cursor keys for navigation you will probably find it a bit unhandy. Just use your preferred keybindings. That's what mutt's about!

Syntax of keybindings:

bind menu key function

# Bindings for index mode. This is where all mail will be listed. Entries are self explanatory, I think:
bind index j next-entry
bind index k previous-entry
bind index l display-message
bind index v collapse-thread

# Pager mode will be entered when selecting a message:
bind pager l next-line
bind pager h previous-line
bind pager t display-toggle-weed

# Some other examples:
bind browser l select-entry
bind attach l view-attach
bind compose f edit-from

Convert pine's addressbook to mutt's aliases format 
  If you were using pine so far and want to switch to mutt now but you want to keep your addressbook, you will quickly notice that this is not quite so easy. The reason is that mutt uses a different format to store its entries. Here is a comparison of both formats:

pine:
nickname fullname address fcc comment
nickname fullname (address1,address2) fcc comment
nickname fullname address
  • Note that the actual pine format is a little more complex since it might differ depending on the length of the tokens, which tokens are actually used, and the number of characters the comment consists of.
mutt:
alias nickname address (fullname) # comment (1) 
alias nickname (fullname) address # comment (2) 
alias nickname address1,address2 # comment (3) 
alias nickname (fullname) address1,address2 # comment (4) 
  • The section about aliases in the mutt manual suggests format 1 for a single address and format 3 for multiple addresses. The latter one, however, doesn't take care of a fullname. If one appends a fullname after the addresses mutt assigns it only to the last address so that it looks somewhat awkward in aliases overview. Hence pine2mutt uses formats 2 and 4, respectively, which will be displayed correctly (mutt uses almost the same format if you create an alias from within mutt).

The following perl script converts pine's addressbook into the proper mutt format. The script expects two parameters. The first one specifies the location (path + filename) of the pine addressbook (usually: ~/.addressbook). The second parameter specifies the location of the new mutt aliases file.

For example:

$ pine2mutt .addressbook .aliases

In case that something doesn't work as expected please mail me at w3@michnet.de.

#!/usr/bin/perl
#
# pine2mutt-0.2: convert pine's addressbook to mutt's aliases format
#
# Michael Velten <michael@michnet.de>

die "Usage: $0 pinefile muttfile\n" if (($P,$M) = @ARGV) != 2;
open(P) || die "$P: $!";
open(M, ">$M") || die "$M: $!";
($_ = join "\0", <P>) ="~" s/\n\0\s([\s:])\s/$1eq':'&&' '/ge;
for (split "\0") {
    next if m|^#DELETED-\d{2}/\d{2}/\d{2}#|;
    s/^([^\t]*)\t([^\t]*)\t\(?(.*?)\)?(?:\t[^\t]*\t(.*))?$/
      "alias $1 ".($2&&"\($2\) ").$3.($4&&" # $4")/e;
    print M;
}
close(M);
close(P);
I'd like to thank Mark Stosberg for his suggestions and patched version of my old pine2mutt script. With that suggestions in mind I implemented the above current version which hopefully handles all cases correctly.

Hans Fredrik Nordhaug sent me an adapted version which converts entries in ISO-8859-1 appropriately. For example, =?iso-8859-1?Q?Morten_M="F8ller"?= will be converted to Morten Møller.

Cut off signature automatically 
  Beyond all the capabilities of mutt there's one thing one might miss, though. There is no possibility to cut off the signature automatically when repyling, for instance. I've written a little perl script that does exactly this for you. Just copy the following script to your home directory (or anywhere else - adjust path!) and modify the editor option in your ~/.muttrc as follows.

set editor=$HOME/killsig %s; /usr/bin/vim %s

Of course, you can use any other editor as well.

The script also recognizes the pseudo signature delimiter "--" (note the lacking trailing space) produced by Outlook Express. If you are using a different quoting character instead of ">" or "> " you'll have to adjust the code accordingly.

#!/usr/bin/perl
#
# killsig: delete signature (also "oe-sigs") when quoting emails.
#          known patterns: ">-- " , "> -- ", ">--", "> --".
#
# Michael Velten <michael@michnet.de>

open(MAIL, "+<$ARGV[0]") || die "$0: Can't open $ARGV[0]: $!";
while (<MAIL>) {
	unless (/^> ?-- ?$/) {
		push(@purged, $_);
	}
	else {
		while (<MAIL>) {
			push(@purged, $_) unless /^>.+/;
		}
	}
}
truncate(MAIL, 0);
seek(MAIL,0,0);
print MAIL @purged;
close(MAIL);
Easy and beautified reply 
  It's a rather tedious task to format a message manually when replying to it. For example, you might want to delete the usual greetings and attribution lines. You may also want to remove lines beyond a certain indentation level or insert some space after each paragraph where you're usually going to write your own lines.

That's the reason I started to write a small script which tries to do all this work automatically. It started like a small hack (well, it still is); hence it's far from being perfect and there are circumstances which still require manual user intervention but altogether it definitely helped me to ease the pain when formatting replies.

Here's an example. Suppose the message looks like this:

On Fri, May 28, 2010 at 00:00:00PM +0200, Michael Velten wrote:
> * Foo Bar <foo@bar.com> wrote:
> > How is it going?
> Fine, you?

I'm doing all right.

> > What are you doing on Monday? What are you doing on Tuesday? What
> > are you doing on Wednesday?
> Monday: ill. Tuesday: sick. Wednesday: both.

That sounds great!

Regards, Foo
After you hit the reply button it would usually look like this:
* Foo Bar <foo@bar.com> wrote:
> On Fri, May 28, 2010 at 00:00:00PM +0200, Michael Velten wrote:
> > * Foo Bar <foo@bar.com> wrote:
> > > How is it going?
> > Fine, you?
> 
> I'm doing all right.
>  
> > > What are you doing on Monday? What are you doing on Tuesday? What
> > > are you doing on Wednesday?
> > Monday: ill. Tuesday: sick. Wednesday: both.
> 
> That sounds great!
> 
> Regards, Foo

Here's the automatically formatted message:
* Foo Bar <foo@bar.com> wrote:
>> Fine, you?
> I'm doing all right.



>> Monday: ill. Tuesday: sick. Wednesday: both.
> That sounds great!
Here's a summary of the differences between both quoted versions:
  • removed attribution line On Fri, May 28, 2010 [...] generated by Foo's mail user agent (MUA)
  • removed attribution line * Foo Bar <foo@bar.com> wrote: previously generated by our MUA and quoted by Foo's MUA
  • deleted line > > > How is it going? because it's been quoted 3 times
  • replaced > > Fine, you? with >> Fine, you?
  • removed empty quoted lines before and after > I'm doing all right.
  • inserted 3 empty lines after I'm doing all right. for replying
  • deleted line > > > What are you doing on Monday? [...] and > > > are you doing on Wednesday? because of the 3rd indentation level
  • replaced > > Monday: ill. [...] with >> Monday: ill. [...]
  • removed empty quoted lines before and after > That sounds great!
  • removed Regards, Foo

In order to invoke the script you could use a line like the following in your ~/.muttrc:

set editor="$HOME/purgemail %s; /usr/bin/vim %s"

Feel free to adapt the script to your needs!

Newsgroups and mailing lists 
  If you got a problem with mutt and can't solve it yourself, there are several places where you can get help. The first step should always be to consult the mutt faq where you can find answers to the Frequently Asked Questions.

If you didn't find an answer there you should consider the internet next (see also links below) and use one of the countless search engines available. I prefer google. Furthermore, you can also use a newsgroup search engine like google groups. Try to put your question into short expressive headwords and search for them in older postings.

If this attempt also fails you can describe your problem accurately in one of the existing newsgroups and chances are that you'll get more or less useful information in a relatively short time. But be warned, usenet people smell it if you didn't do your homework well and didn't try the above suggestions and can then be kind of rude sometimes. If you don't have any experience with usenet so far, first read the *newusers* groups. You should heed things mentioned there in any case.

The existing mailing lists may be helpful, too. At the mutt homepage you can find more information about newsgroups and mailing lists regarding mutt. There's also an IRC channel mentioned there. But don't expect too much. IRC might give you a quick answer but on usenet quality is usually better. Exceptions prove the rule.

Links 
  Here are some links that might be worth a look. If you discover any deadlink please give me a short notice. If you know any other interesting websites and you think that I should include them here you are welcome to inform me about. Simply write an email to w3@michnet.de.
 
Michael Velten <w3@michnet.de>Last change: Wed Dec 8 11:28:22 2010