Introduction
With all the choices of graphical e-mail clients available to Linux users, the reader may wonder why I would spend time on a terminal based e-mail program. Like other debates on GUI vs. terminal base applications, the answer to this question is "it depends". It depend on what your needs are, what you're use to, and finally, what your preference is. Let me start with why I use Mutt and then why you might like it too.
Like most Linux users, I get quite a bit of e-mail from multiple mailing lists. I used Netscape Messenger for quit a while and, for the most part, was happy with it. However, reading mailing lists became a chore with Messenger because it handled threading poorly; with no way of changing its behavior. At the same time I needed a way of reading my mail remotely. If I used Messenger to retrieve my mail at work, I wouldn't be able to read it when I was at home and vis a versa. I was familiar with Pine and was going to use it when a friend suggested I try Mutt. Since it can be configured to use vi like key bindings, (I love vi), I decided to give it a try.
Mutt can be configured to do about anything with your mail. It handles MIME encoded mail quite well, has PGP support, and can be used as a POP3 mail client. The way it works with mailing lists and threaded mail alone is reason enough for any heavy e-mail user to consider it. You can configure it to use different signatures depending on who you're sending mail. And you can configure it to view mail in different mailboxes in different ways, including using color highlighting for different parts of an e-mail. If there is some function you want Mutt to have, it can be configured to have that function.
E-mail overview
Before we get going lets review how mail is sent and received on a
Linux system and the programs that are involved. Mail is handled by
three programs: the MTA (Mail Transfer Agent), the MDA (Mail Delivery
agent), and the MUA (Mail User Agent). The MTA is responsible for
sending mail (either local or remote) to the recipients' MTA. The MTA
hands off the mail to the MDA. The MDA then delivers the mail to the
default spoolfile; usually
/var/spool/mail/username
. The users MUA then reads
the mail in the spoolfile and either leaves it there or moves it to
another place for archiving.
Its slightly different for POP3 e-mail accounts. You still use the MTA to send mail, but to receive mail you use a POP3 client. It connects to the POP3 server, sends your username and password, retrieves your mail and delivers it either to your default mail spool file or to a folder the POP3 client is configured to use. Mutt can be used as a straight MUA that reads from the mail spool file of your choice or as a POP3 client MUA. I will go over how to configure Mutt for either case.
Installation
The first thing you need to do is install Mutt. Luckily, Mutt
comes as a standard application on most Linux distributions so chances
are you have it on your system already. To find out, open a terminal
window and type mutt -v
. If it's installed, you
should see something like this:
[steve@turin ~]$ mutt -v
Mutt 1.2.4i (2000-07-07)
Copyright (C) 1996-2000 Michael R. Elkins and others.
Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -vv'.
Mutt is free software, and you are welcome to redistribute it
under certain conditions; type `mutt -vv' for details.
System: Linux 2.4.0-test7 [using ncurses 4.2]
Compile options:
-DOMAIN
-DEBUG
-HOMESPOOL +USE_SETGID +USE_DOTLOCK +USE_FCNTL -USE_FLOCK
+USE_IMAP -USE_GSS -USE_SSL +USE_POP +HAVE_REGCOMP -USE_GNU_REGEX
+HAVE_COLOR +HAVE_PGP -BUFFY_SIZE -EXACT_ADDRESS +ENABLE_NLS +COMPRESSED
SENDMAIL="/usr/sbin/sendmail"
MAILPATH="/var/spool/mail"
SHAREDIR="/usr/share/mutt"
SYSCONFDIR="/etc"
ISPELL="/usr/bin/ispell"
To contact the developers, please mail to .
To report a bug, please use the muttbug utility.
This tells you the version you have (in my case 1.2.4i), the
library used for terminal screen control (ncurses 4.2), and then the
compile time options. Since my version of Mutt was from an RPM, the
output of mutt -v
has whatever compile options the
builder saw fit to use. I've compiled Mutt from a tarball and its no
more difficult than installing the RPM. If you have any experience
with compiling from source you will have no problems with Mutt. It
uses the standard ./configure;make;make
install
routine that you know and love. If you want to know
what all the compile options are just type ./configure
--help
and take a peek. However, the default options are
fine for most users.
When installing the RPM, you will need to have the
urlview
package installed first or you will get a
dependency error. If you compile from source, you don't need to have
urlview. However, you will not be able to view URLs in your e-mails
without it. You will also need either the ncurses or slang package
installed as well. These packages are used by Mutt for screen
control. According to the INSTALL file, slang may work better for
some people who don't have proper termcap entries. I have used both
without any problem. I won't dwell much on installing the package;
its very straight forward.
Configuration
The same can't be said for Mutts configuration file: .muttrc. It's this file that gives Mutt its flexibility and configurability; it's also this file that might give new users problems. The number of options that Mutt has available to it are truly astounding. Mutt allows the user to control about every function Mutt uses to send, receive, and read your mail. As is true with all powerful software, it takes time to understand the features and what they can do for you. However, once you start using Mutt, you begin to ask yourself, "I wonder if Mutt does...", the answer is almost always yes.
Lets start with the basics of the .muttrc file and along the way I
will comment on what I feel are good formatting practices so that you
can read (and edit) your .muttrc file later. The following is not an
exhaustive list of the options Mutt uses (that would take quite a few
more articles), just the ones that most users need to get started.
Most of the options are invoked using the "set" or "unset" commands
with either boolean or string values, e.g. "set folder =
~/Mail
". I put all the "set" commands in one section
and the "unset" in another. I make an exception for some options that
are related and work together.
The first options that need to be "set" are the default mail
folder, spool file, and e-mail file type:
# Mail Folder
set folder = ~/Mail # Directory that contains all mail files (mailboxes)
set spoolfile = +Inbox # Default spoolfile
set mbox = +Inbox # Where mail is appended to from spoolfile
set mbox_type = mbox # Type of mail files
set postponed = +Unsent # Where to save postponed mail
set copy = yes # Save copies of outgoing mail?
set record = +Sent # Where to save copies of outgoing mail
Notice the "+". It's an aliases that means "In the "folder" directory"
as set by the "set folder
" option. You can use either
"+" or "=". The reason you can use both + or = is that "set
spoolfile ==Inbox
" looks awkward.
We should clarify what "spoolfile" means here; its wherever your
MDA saves your mail. Most people have POP3 mail accounts which means
that you will need to use some program to retrieve your mail from that
POP3 server. Fetchmail is the most popular, but Mutt can also "pop"
your mail as well (more on that later). Fetchmail will "pop" or
retrieve your mail then send it to the MDA (generally Procmail). If
you configured Mutt for POP3, your mail will be retrieved by Mutt then
saved to the file specified by "set spoolfile
".
If you want the mail in your spoolfile moved to another folder
after reading then you should "set mbox
" to that
file. I don't need Mutt to move my Mail out of the default spool file
because I have Procmail filter my mail and bypass
/var/spool/mail/username and deliver it to other folders based on
address. Any mail that Procmail can't save to another mail folder goes
to ~/Mail/Inbox. Because of this I don't need "set
mbox
"; just "set spoolfile
".
"set mbox_type
" lets Mutt know what mailbox type
to create for new mailbox folders. Sendmail and Postfix use mbox;
Qmail uses Maildir. *Note: If you are converting from Netscape
Messenger to Mutt, use mbox. "set copy = yes
" is
the default value for this option but I like to explicitly set it for
reference. Even though Mutt saves a copy of outgoing mail it doesn't
yet know where to save it so, "set record
" tells
Mutt which file that is.
Now, the personal options:
# Personal options
set hostname = "your hostname"
set realname = "your real name"
set signature = ~/.signature
These three values are self explanatory. Set them to values
appropriate for you. For "set hostname
", I set
this for the domain name of my POP3 email service. This way the domain
name in the "From" header field that the recipient sees is from my
e-mail service.
Lets define where our address book (aliases in Mutt speak) is located:
# Aliases (address book)
set alias_file = ~/.mutt-aliases
source ~/.mutt-aliases
set reverse_alias # Show real name instead of e-mail address in index
set sort_alias = alias # Sort aliases by alias name not email address
The only tricky part here is the second line. You have to "source"
the file that contains your email aliases otherwise Mutt won't "see"
them. I have my aliases sorted by real name as some of the e-mail
addresses are not very intuitive. Check "man
muttrc
" for other sort options.
This section is imperative:
# Prune the headers!
ignore * # Ignore all header info
unignore subject
unignore to
unignore from:
unignore date
unignore CC
hdr_order Date: From: To: CC: Subject:
Have you ever looked at all of the header info on an email? Unless
you like this sort of info its fairly useless. What most people want
to see is who the mail is from, the date sent, and the subject. The
first value ignores everything; the rest unignores only the header
info that's important to you. The "hdr_order
"
allows you to specify the order you see the header info when you read
mail. It's one of those cool features that you wouldn't think are
important until you use it.
Tell Mutt what folders to look in for new mail:
# Mailboxes
mailboxes =Inbox
mailboxes =Mailing-Lists/Kickstart-list
mailboxes =Mailing-Lists/LinuxWorld
mailboxes =Mailing-Lists/PPA-Devel
mailboxes =Mailing-Lists/PPA-Users
mailboxes =Mailing-Lists/RPM-list
The "mailboxes
" variable will tell Mutt what
mailboxes can receive mail and where Mutt should check for new
messages. You can cycle through these mailboxes by pressing the space
bar after changing folders. This allows you to keep an eye on certain
mailboxes for new mail. *Note: Mutt will not put mail in these
folders; you will need something like Procmail to do that.
If you want to use Mutt as a POP3 mail client...:
set pop_host =[your.pop3.hostname]
set pop_user =[your pop3 username]
set pop_pass =[your pop3 password]
set pop_delete =yes # Save mail on server or not
If you don't want to use a POP3 mail retriever like Fetchmail, you can configure Mutt as a POP3 mail client and have it retrieve your mail. The options are straight forward. The last one will depend on whether or not you want to save your mail on the POP3 server. Since most POP3 servers have a limit on how much mail they will hold for you, I suggest you have Mutt delete mail after its retrieved it. It doesn't take long for that limit to be reached.
With these options set in your .muttrc file you can use Mutt.
There are many, many more options and the curious reader should
consult "man 5 muttrc
" for the rest. Now that we
have the .muttrc file created you will have to create your alias file.
A simple "touch [nameofaliasfile]
" is all that is
needed.
In my next article I will go over the functions of Mutt and how to
navigate your way around your mail. Again, if you want to know more,
the man pages for muttrc and mutt are quite helpful. I also recommend
the Mutt manual. On RedHat systems it's installed in
"/usr/doc/mutt-1.2.x
". This document has all the
muttrc options and plenty of instruction on how to use Mutt.