This page describes how I set up my system to handle my e-mail. In particular it deals with processing the mail after it has been retrieved from a POP server by fetchmail. I use Exim4 as local MTA. Exim4 sends all incoming mail to Spamassassin. If Spamassassin considers the mail spam, Exim4 will put it in ~/Maildir/Spam/ instead of the usual ~/Maildir/. Finally, I run dovecot as an IMAP server, so that I can access my mail from any computer running an e-mail client that understands IMAP.
So in a nut shell: e-mail
To have all this running, you will need (at least) the following packages (package names refer to Debian sid)
/etc/exim4/conf.d/transport/30_exim4-config_mail_spoolto make exim use the maildir format. The changed file looks like this on my system
mail_spool: debug_print = "T: appendfile for $local_part@$domain" driver = appendfile #file = /var/mail/$local_part delivery_date_add envelope_to_add return_path_add group = mail mode = 0660 directory = ${home}/Maildir maildir_format message_prefix = ""
/etc/exim4/email-addresses
so that messages you sent from a local account to an
outside e-mail address will have the right return address.
/etc/exim4/conf.d/transport/30_exim4-config_spamcheckwith the following contents
spamcheck: debug_print = "T: spamassassin_pipe for $local_part@$domain" driver = pipe command = /usr/sbin/exim4 -oMr spam-scanned -bS use_bsmtp transport_filter = /usr/bin/spamc home_directory = "/tmp" current_directory = "/tmp" user = Debian-exim group = Debian-exim return_fail_output message_prefix = message_suffix =Update 16 December 2003
/etc/exim4/conf.d/router/850_exim4-config_spamcheck_routerwith the following contents
spamcheck_router: no_verify check_local_user # When to scan a message : # - it isn't already flagged as spam # - it isn't already scanned condition = "${if and { {!def:h_X-Spam-Flag:} {!eq {$received_protocol}{spam-scanned}}} {1}{0}}" driver = accept transport = spamcheck
The Debian spamassassin package contains a program
spamd
which can run as a daemon. However
this is disabled by default and you should edit
/etc/default/spamassassin
to
enable it. I also
removed the "-c" from the OPTIONS
in the file, because
Spamassassin will not run under the user account and
as such is not going to use the user preferences.
Update 8 March 2004
Janos Dobos from Hungary mailed me the following comment:
if you set up the spamcheck transport with this modification:
--- transport_filter = /usr/bin/spamc
+++ transport_filter = /usr/bin/spamc -u ${local_part}
then spamc will run under the user account of the local part
of the emailaddress. In most cases the local part is the name
of the actual localuser thus spamc can use the user preferences.
(Actually spamc runs as Debian-exim/Debian-exim but spamd runs
as root so can drop into group/user and access the neccessary files.)
I am not using this myself, but if you do not have root access
or do not want to change the Debian defaults, you might want
to try this.
/etc/exim4/conf.d/router/600_exim4-config_userforward
.
You should uncomment the line saying "allow_filter".
.forward
in your home directory. If the
first line of this file reads # Exim filter
then
Exim4 will treat it as a filter. Here is my filter
# Exim filter if $h_X-Spam-Status: CONTAINS "Yes" or "${if def:h_X-Spam-Flag {def}{undef}}" is "def" then save $home/Maildir/.INBOX.Spam/ finish endifThis filter will put all messages that Spamassassin considers spam in a maildir folder named Spam.
The information on this page is mostly an update of the information provided by Derrick Hudson on http://dman.ddts.net/~dman/config_docs/exim4_spamassassin.html. Unfortunately, this site seems to be unreachable.
If you want you can also simply refuse to accept spam messages sent to you (since my e-mail is accepted by a POP server that I do not have administrator rights for, this is not useful for me). If you would like to take this approach, please check Marc Merlins site on sa-exim.
Updated 9 October 2003:
The output Spamassassin adds to e-mail changed and would cause the original Exim filter
to put all mail in the Spam folder. Changed the check to be case sensitive. Thanks to
Damir for pointing that out.
Updated 16 December 2003:
The Debian developer maintaining exim4 has changed the user and group for
the exim4 program from mail to Debian-exim which caused the
spamcheck transport filter to fail.
Martijn Anthonissen, 8 March 2004 |