Using exim4 with exiscan-acl (spamassassin, SPF, ...) - why and how

exim4 MySQL HOWTO
UPDATES:
20040813: SPF updated.
20040808: started building this page - first item: SPF.

exiscan is a sourcecode-patch for the exim MTA, which modifies the exim-own ACL system. Exim uses its ACL-system to decide, wether to accept or decline an email - or even just add header-lines or write an entry on the exim logfile. More to this in the exim documentation, Chapter 38
This means, with this patch applied, you are able to run the following checks on emails and reject or add a specfic header then:

Why?

There are some good reasons to reject a mail that you don't want to deal with as soon as possible. If you use spamassassin, you can reject mails with a pretty high score before they touch your system - and MAYBE this is even a way to unsubscribe from these spam-mailers, if they only get bounces...
Or you can use SPF (that was one of the reasons for me trying exiscan-ACL) to tag incoming mails and score them with spamassassin later on. There are some pretty, nice and nasty things you can do with exiscan-acl - just have a look at http://duncanthrax.net/exiscan-acl/.

HOW - Step 1 - compiling and installing (very short way...)

SPF

We have already compiled exiscan with SPF-support - so we should have a look at it.
There are some good examples how you could include SPF-ACLs on the exiscan-Homepage, but I like the idea of adding only a SPF-header to all mails which can be parsed by spamassassin. So can modify the spamassassin-score by the SPF result - nice, isn't it?
To do this, I've included the lines
  warn    message       = $spf_received
          spf           = pass : fail : softfail : none : neutral : err_perm : err_temp
          domains	= +local_domains
in acl_check_rcpt just after
  require verify        = sender
  accept authenticated  = *
Probably, you've to move the accept authenticated = * some lines up. This skips adding a tag for all mails relayed via SMTP-Auth (thanks, Tom Kistner!)
With domains = +local_domains only incoming mails will be tagged - relayed mails (without SMTP-authentcation) should get a tag at the recipient MTA - not here. We need this for our relay_from_hosts, cause they don't have to use SMTP-auth.

Every incoming mail should get SPF-tagged, now. This doesn't hurt in any way.
In /etc/spamassassin/local.cf (debian place for SA-config) I added the following SA rules:

  header SPF_CHECK_PASS Received-SPF =~ /^pass/
  describe SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain
  score SPF_CHECK_PASS -1.5

  header SPF_CHECK_FAIL Received-SPF =~ /^fail/
  describe SPF_CHECK_FAIL SPF reports sender host as NOT permitted to send mails from
  score SPF_CHECK_FAIL 0.5
That's one way of dealing with SPF.
There are still some points I don't like (but I've no better solution, so...):

spamassassin - coming soon