[Exim] Spam filter with MySQL and .forward filter file

Top Page
Delete this message
Reply to this message
Author: Mike Kenyon
Date:  
To: exim-users
Subject: [Exim] Spam filter with MySQL and .forward filter file
I've decided in order to defeat the spam problem to redirect all mail
from people who aren't in my address book into a folder
called "Spam". This isn't particularly intelligent but seems to work.
I've created a cron job that distills my Mutt address book into a
simple list of addresses which are then searched in my .forward by
the following:

# Exim filter
if not error_message then
  if ${lookup{$sender_address}lsearch*@{$home/.addressbook}{OK}{SPAM}} is SPAM
  then
    save Mail/Spam
  endif
endif


Which works great.

*But* I also use SquirrelMail as well as Mutt (and I'm currently
evaluating Twiggi) and both store the contacts in a MySQL table (this
is optional with SquirrelMail but seemed like a good idea at the
time). What I want to is also have the filter search the relevant
table for addresses, something like:

if ${lookup mysql {select email from address_table where owner = 'mike' and
email = '$sender_address'}{OK}{SPAM}} is SPAM
then
save Mail/Spam
endif

(Note that the address table in SquirrelMail is called "address" and
not "address_table".)

This doesn't work, as Exim doesn't seem to recognise "mysql" as a
lookup type (at least in a filter) OR I've got the syntax completely
wrong.

I have digested the filter manual, the spec and searched this list
but to no avail (so far).



--
Mike Kenyon