This is G o o g l e's cache of http://tellus.dyndns.org/?topic=mutthowto.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
To link to or bookmark this page, use the following url: http://www.google.com/search?q=cache:6GiQ6eZctC0J:tellus.dyndns.org/%3Ftopic%3Dmutthowto+fetchmail+procmail+spamassassin+maildir&hl=en&ie=UTF-8


Google is not affiliated with the authors of this page nor responsible for its content.
These search terms have been highlighted: fetchmail procmail spamassassin maildir 

tellus - mother earth

tellus

Sun Nov 2 04:42:59 CET 2003
tellus

bibliotheca
mutt howto

pinacotheca
m+m+m
candle light
einstein portrait
peacock portrait
vorchdorf
fireworks 2002/03
winter 2002/03
spring 2003
linz - donaulaende

max

pgp key
mutt-fetchmail-procmail-spamassassin-qmail-gnupg howto

mutt-fetchmail-procmail-spamassassin-qmail-gnupg howto

Copyleft (C) 2002 Markus Stöger,
markus_stoeger@gmx.at, http://tellus.dyndns.org.

Table of contents
Introduction
Who is who and how this is supposed to work
Configuring fetchmail
Configuring procmail
Configuring spamassassin
Configuring qmail
Configuring mutt
  I, The basics
  II, Useful key bindings and functions of mutt
  III, GnuPG - digital signatures and encrypted email
  IV, How to cope with dissociative identity disorder
  V, Random email signatures
Credits/Thanks
Changelog

Introduction

This howto explains how to get an email system based upon the famous mutt email program (MUA - mail user agent) up and running on your Linux/UNIX system as fast as possible. It is by no means meant to replace any other manuals. It only provides example configuration files for each used program and short explanations. - Refer to the original, long version of the manuals to get more detailed information about each setting/feature.

The latest version of this howto is available at http://tellus.dyndns.org. If you find errors or if you have suggestions please send email to markus_stoeger@gmx.at.

Who is who and how this is supposed to work

The email system we'll build is quite different to the usual email programs known from Microsoft Windows(R)(TM)($$$). The main difference is that it does not consist of a single program that retrieves, sends, filters and edits email. Instead it is built modularly, i.e. it consists of several programs, each doing what it can do best. Due to this modularity it is easy to replace any of the used programs with another one that you feel more comfortable with, that's more secure, smaller, faster or whatever. Freedom of choice.
Below is a list of required programs with an explanation of what each of them is used for and where to get them.

fetchmail
homepage:
http://tuxedo.org/~esr/fetchmail/
man fetchmail

fetchmail is, as the name suggests, used to fetch (or retrieve) incoming email from your mail server(s). It can be configured to poll your mail servers every few minutes and, should you be in the lucky situation to receive new email, download it to your local system for further processing.

procmail
homepage: http://www.procmail.org/
man procmail
man procmailrc

Email downloaded by fetchmail is passed right on to procmail, our email delivering and filtering program. It can be used to inspect the header fields and body content, evaluate them and then sort the emails into different mailboxes. This is an optional but very useful component in our email system. It could be left off if you have no need to filter any of your email, though it certainly is nice to be able to keep your business email separate from your girlfriends letters, or to forward spam straight to /dev/null.

spamassassin
homepage: http://spamassassin.taint.org/
man spamassassin

spamassassin is a perl script used to identify spam (UCE - unsolicited commercial email). It is invoked by procmail, which will handle the email differently depending on its 'spam status'. Like procmail this is optional also, though I really recommend its use. You'll finally be able to use your real email address in newsgroups, yet never find spam in your main mailbox again.

qmail
homepage: http://www.qmail.org/
man qmail

qmail, my personal mail server (MTA - mail transfer agent) of choice because it is very easy to configure, simple, small and secure. It can be used to both send and receive email. All we'll use it for is to send email though. It will be invoked by mutt as soon as you 'click the Send button' and then make sure that the email gets delivered to its final destination. If you don't like qmail you can replace it with sendmail (and others?) without mutt noticing anything.

mutt
homepage: http://www.mutt.org/
man mutt
man muttrc

mutt, the heart of this system, is basically nothing more then a file/email browser with a text editor. It allows you to browse through the emails that have been placed into a mailbox, move them around, actually write new emails (wow!) and all the usual stuff (and much more) known from other email programs. I'll start with a basic configuration and add certain useful features in later chapters.

Configuring fetchmail

fetchmail's configuration file is located at ~/.fetchmailrc. Make sure it's chmod 600ed because it contains account information for all email accounts.

set daemon 1
set syslog

defaults proto pop3, timeout 30, fetchall, forcecr, mda "/usr/local/bin/procmail"

poll pop.server1.com interval 1 user "max" pass "abcdef"
poll pop.server2.com interval 20 user "max" pass "secret"
poll pop.server3.com interval 20 user "max" pass "ghijkl"

The first few lines contain global settings. Most importantly the 'mda' setting. It tells fetchmail to forward the emails to procmail. The last three lines list the email servers. There can be as many of these entries as you need. Adjust the account information and try:

fetchmail --nosyslog --nodetach --check

This makes fetchmail check your email accounts (without downloading anything). Make sure there are no errors.

Later when procmail is configured you can run fetchmail in the background by typing 'fetchmail' without any parameters. Status messages will be sent through syslog.

Configuring procmail

procmail's configuration file is located at ~/.procmailrc.

PATH=/bin:/usr/bin:/usr/local/bin
MAILDIR=$HOME/mail
DEFAULT=inbox/
LOGFILE=$MAILDIR/logfile

:0
* ^From:.*@mycompany.com
business/

This simple procmail configuration consists of only one filter rule. Any email 'From:' *@mycompany.com is saved in the 'business' mailbox, while all the rest is saved in the default 'inbox' mailbox. The mailboxes are located in subdirectories of $HOME/mail/ and a logfile listing each processed email is written to $HOME/mail/logfile. Note that the slash at the end of mailbox names tells procmail to store email in 'Maildir' format (instead of mbox format).

You could now test fetchmail. Better start with a test email account that contains a few emails from yourself.. just in case something goes wrong and causes lost email. After the emails are downloaded you should find a few files in $HOME/mail/inbox/new/*, each containing one email.

Configuring spamassassin

The defaults for spamassassin work quite well. Take a look at the man page if you want/need to change anything.

To make procmail invoke spamassassin you can add the following two rules to your .procmailrc. Add them at the top, before any other filter rules.

:0fw
| /usr/bin/spamassassin -L

:0
* ^X-Spam-Status: Yes
spam/

The first rule tells procmail to pipe the email through spamassassin. spamassassin adds the header field 'X-Spam-Status: Yes/No' to the email, which gets evaluated by the second rule. If it is possible spam the email will be sent to the spam/ mailbox.

Configuring qmail

qmail's configuration files are in /var/qmail/control/. We need 'locals' and 'me'. The 'smtproutes' configuration is optional. If you use it then qmail will forward email to your isp's smtp server instead of delivering it directly. This normally causes email to get sent faster, especially on dial-up connections that aren't online all the time.
qmail provides a sendmail wrapper that is required by mutt to send email. Just link /var/qmail/bin/sendmail to /usr/sbin/sendmail.

rm /var/qmail/control/*
echo "no-locals" > /var/qmail/control/locals
echo "your.hostname.com" > /var/qmail/control/me
echo ":smtp.yourisp.com" > /var/qmail/control/smtproutes
ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail

To start qmail add the following to /var/qmail/rc and run '/var/qmail/rc &' from your boot scripts:

exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start ./Mailbox splogger qmail

Time to test qmail, send yourself an email with:

echo "To: you@server.com" | /var/qmail/bin/qmail-inject

Configuring mutt, I, The basics

mutt's configuration is at ~/.muttrc.

set folder = ~/mail
set mbox_type = Maildir
set spoolfile = +inbox
set mbox = +inbox
set postponed = +unsent
set record = +sent
mailboxes +inbox +business +spam
unset check_new

my_hdr from: Joe <joe@your.hostname.com>

set sort = threads
set sort_aux = last-date-received

set charset = "iso-8859-15"
set send_charset = "iso-8859-1:iso-8859-15"
set index_format = '%4C %Z %{%d %b %Y} %-30.30L %s'
set tilde = yes
set fast_reply = yes
set markers = no
set smart_wrap = yes
set copy = yes

ignore *
unignore subject
unignore to
unignore from
unignore date
unignore CC
unignore X-Mailer
unignore User-Agent

hdr_order From Date Subject To CC X-Mailer User-Agent

color hdrdefault brightwhite default
color indicator red green
color status brightwhite blue
color quoted3 yellow default
color quoted2 blue default
color quoted1 green default
color quoted red default

The first section configures your mailboxes. It tells mutt which mailbox format to use (Maildir, as with procmail), where to look for new email (mailboxes +inbox +...), where to store sent email and so on. The '+' in front of mailbox names gets substituted with the 'folder' variable, ~/mail. The next line sets your From: line in outgoing emails. The rest is just for the look & feel of mutt.

You have a fully functional mutt now! Launch it with 'mutt' and type '?' for help. The next chapter lists some often used key bindings and functions of mutt to make your life as new mutt user easier.

Configuring mutt, II, Useful key bindings and functions of mutt

Some of my most often used keys:

q ... quit mutt.
m ... write a new email.
r ... reply to an email.
g ... group reply. reply to all recipients.
f ... forward an email.
b ... remail a message to another user.
s ... save email to a file/mailbox.
d ... mark an email as deleted.
u ... undelete an email.
c ... change to another folder/mailbox.
t ... tag an email.
T ... tag all emails matching a pattern (man muttrc -> PATTERNS).
; ... execute a function on all tagged emails. e.g. ';d' to delete all tagged emails.
/ ... search for the next email matching a pattern.

Type '?' to get a list of all available key bindings.

Configuring mutt, III, GnuPG - digital signatures and encrypted email

set pgp_autosign = no
set pgp_autoencrypt = no
set pgp_ignore_subkeys = yes
set pgp_entry_format = "%4n %t%f %4l/0x%k %-4a %2c %u"
set pgp_good_sign = "^gpg: Good signature from"
set pgp_long_ids = yes
set pgp_replyencrypt = no
set pgp_replysign = no
set pgp_replysignencrypted = no
set pgp_retainable_sigs = no
set pgp_show_unusable = yes
set pgp_sign_as = ""
set pgp_strict_enc = yes
set pgp_timeout = 1800
set pgp_verify_sig = yes
set pgp_sort_keys = address
set pgp_create_traditional = no
set pgp_decode_command = "/usr/local/bin/gpg %?p?--passphrase-fd 0? --no-verbose --quiet --batch --output - %f"
set pgp_getkeys_command = ""
set pgp_verify_command = "/usr/local/bin/gpg --no-verbose --quiet --batch --output - --verify %s %f"
set pgp_decrypt_command = "/usr/local/bin/gpg --passphrase-fd 0 --no-verbose --quiet --batch --output - %f"
set pgp_clearsign_command = "/usr/local/bin/gpg --no-verbose --batch --quiet --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
set pgp_sign_command = "/usr/local/bin/gpg --no-verbose --batch --quiet --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f"
set pgp_encrypt_sign_command = "pgpewrap /usr/local/bin/gpg --passphrase-fd 0 --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f"
set pgp_encrypt_only_command = "pgpewrap /usr/local/bin/gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f"
set pgp_import_command = "/usr/local/bin/gpg --no-verbose --import -v %f"
set pgp_export_command = "/usr/local/bin/gpg --no-verbose --export --armor %r"
set pgp_verify_key_command = "/usr/local/bin/gpg --verbose --batch --fingerprint --check-sigs %r"
set pgp_list_secring_command = "/usr/local/bin/gpg --no-verbose --batch --quiet --with-colons --list-secret-keys %r"
set pgp_list_pubring_command = "/usr/local/bin/gpg --no-verbose --batch --quiet --with-colons --list-keys %r"

Configuring mutt, IV, How to cope with dissociative identity disorder

Sometimes it's useful to have more then one email personality, like one for business email, one for mailinglists and one for private use. There are several ways to realise this with mutt, below I explain four.. choose whichever best fits your needs.

Method #1 - set the personality depending on the mailbox/folder you are in.

folder-hook . my_hdr from: Joe <your@default-address.com>
folder-hook business my_hdr from: Joe Smith <you@yourcompany.com>
folder-hook mailinglists my_hdr from: Joe <you@somewhere.com>

With this the default email address is 'your@default-address.com'. When you start writing a new email while in the 'business' mailbox the address will be set to 'you@yourcompany.com', yet another email address will be set when you are in the 'mailinglists' mailbox.

Method #2 - set the personality depending on the recipient.

send-hook . my_hdr from: Joe <your@default-address.com>
send-hook @securityfocus\.com my_hdr from: Joe <you@somewhere.com>

This sets a default address of 'your@default-address.com'. When sending email to a mailinglist at securityfocus.com it will be changed to 'you@somewhere.com'.

Method #3 - set the personality depending on whom the email was sent to.

set from = 'Joe <you@default-address.com>'
set alternates = (you@default-address\.com)|(you@server2\.com)|(you@server3\.com)|(you@server4\.com)
set reverse_name = yes
set reverse_realname = yes

The first line sets a default address. The second line tells mutt (with a regular expression) at which email addresses you can receive email. And the last two lines enable mutt's reverse_(real)name features. They cause mutt to take the address in the To: field and put it into the From: field when replying to an email. This way when someone sends you email at you@server3.com and you reply mutt automatically sets your From: field to you@server3.com.

Method #4 - bind each personality to a certain key.

my_hdr from: you@default-address.com
macro generic <f1> ":my_hdr from: you@default-address.com\n" "Set From: to you@default-address.com"
macro generic <f2> ":my_hdr from: you@server2.com\n" "Set From: to you@server2.com"
macro generic <f3> ":my_hdr from: you@server3.com\n" "Set From: to you@server3.com"
macro generic <f4> ":my_hdr from: you@server4.com\n" "Set From: to you@server4.com"

... binds the keys F1-F4 to different email addresses.

Configuring mutt, V, Random email signatures

Some hate them, others need them.. email signatures. If you want the same signature for every email you can simply add this to your .muttrc:

set signature = ~/.signature

... and write your signature into the file ~/.signature.

If you want a different/random signature for every email you can use the 'fortune' program, available at http://ftp13.freebsd.org/CPAN/authors/Greg_Ward/. It uses a fortune-cookie database (a text file) and spits out a random cookie every time it's run. After compiling/installing it add this to your .muttrc:

set signature = 'fortune ~/.signatures|'

... and write your signatures, separated by the percent sign, into the file ~/.signatures:

Put your hand on a hot stove for a minute, and it seems like an hour. Sit
with a pretty girl for an hour, and it seems like a minute. That's
relativity. --Albert Einstein
%
Imagination is more important than knowledge. --Albert Einstein
%
I don't know with what weapons World War III will be fought, but World
War IV will be fought with sticks and stones. --Albert Einstein

Credits/Thanks

Peter Vratny for bugging me to write this.
Carl Patterson for proof reading.
The authors of the mentioned software, it's documentation and FAQs.
Bach, Beethoven, Mozart and Linkin Park for good background music.

Changelog

2002-12-07
second try...

2002-09-05
toasted power supply with dead harddisk for breakfast. later that day a lesson about backups.

2002-09-04
thunderstorm

2002-09-01
first try