Home > Solaris, Spam Fighting, exim > Spam filtering with EXIM/SpamAssassin and Procmail

Spam filtering with EXIM/SpamAssassin and Procmail

July 26th, 2006

For others who may be intersted. (Note this is what I did on a Solaris 10 machine) I also already had EXIM configured with SpamAssassin to put [SPAM] in the subject if the message was “spam”. This also assumes that the IMAP mailbox directory is the mail directory in the users home directory.

Here is what you need to do:

1. Install procmail, (I get it from blastwave, as I did exim,spamassassin, and clamav):

su – root
cd /opt/csw/bin
./pkg-get -i procmail

2. Configure exim to handle procmail pipes.
a. make a backup copy of /opt/csw/etc/exim/exim.conf
b. In the “routers” sections of the exim.conf, right above the localuser: line add the following:

procmail:
 debug_print = "R: procmail for $local_part@$domain"
 driver = accept
 domains = +local_domains
 check_local_user
 transport = procmail_pipe
 require_files = ${local_part}: \\
               ${if exists{/etc/procmailrc}\\
                 { /etc/procmailrc}{${home}/.procmailrc}}:\\
               +/opt/csw/bin/procmail
 no_verify
 no_expn

exactly how I have it above

c. In the transports section right below the 2 lines that say:

remote_smtp:
driver = smtp

add in this :

procmail_pipe:
 debug_print = "T: procmail_pipe for $local_part@$domain"
 driver = pipe
 path = "/opt/csw/bin:/bin:/usr/bin"
 command = "/opt/csw/bin/procmail"
 return_path_add
 delivery_date_add
 envelope_to_add

e. Now restart exim:

/etc/init.d/cswexim stop; /etc/init.d/cswexim start

3. Setup a .procmailrc in the users home directory and make sure it is owned by the user, this is what I had in my test user’s .procmailrc file:

VERBOSE=no
MAILDIR=/home/testuser/mail

#:0: #Delete spam messages
#* ^Subject: \[SPAM]
#/dev/null
:0: #Delete spam messages
* ^Subject: \[SPAM]
Spam

the first set will just delete the messages if they contain [SPAM] in the subject, and they are commented out. The second set will put the messages in the Spam folder. You can replace the Spam with Junk if you want. Make sure the mail directory exists in the home directory and it owned by the user. The Junk/Spam folder will automatically be created if it does not exist the first time a spam message comes in..

Should be it.

Solaris, Spam Fighting, exim , ,

Comments are closed.