$Id: README.exim,v 1.1 2004/10/24 21:25:35 jonz Exp $

EXIM INTEGRATION

Please follow the instructions in the README for building DSPAM. Once DSPAM
has been built, the following instructions may be used to integrate it with
exim.
 
To integrate DSPAM with exim, you'll need to create a new director in the exim
configuration.  First, add the following code to the directors :

spamscan:
  no_verify
  condition = "${if and { {!eq {$received_protocol}{spam-scanned}} } {1}{0}}"
  driver = localuser
  transport = spamcheck
  require_files = ${local_part}:\
    +/path/to/dspam-home:\
    +/path/to/dspam/binary

Then add the following code to the transports:

spamcheck:
  driver = pipe
  command = /usr/local/bin/dspam --deliver=innocent --user $local_part -bm %u
  user = mail
  group = mail
  return_path_add = false
  log_output = true
  return_fail_output = true

Finally, you will need to configure your delivery agent into dspam. This may 
end up calling exim again, if you are using maildir format for example.  An 
example of calling back to exim for delivery might look like:

   ./configure --with-delivery-agent="/usr/sbin/exim -oMr spam-scanned"

RUNNING WITHOUT PRIVILEGED EXIM USERS

Alternatively, one could also write a line to the header and check for 
that instead of looking at the protocol:

   condition = "${if and {\
                         {!def:h_X-DSPAM-Check:}\
                 }{1}{0}}"
   headers_add = "X-DSPAM-Check: by $primary_hostname on $tod_full"

The problem with setting $received_protocol in the transport is that only
priviledged Exim users are allowed to do so. With this setup, DSPAM could
run with /usr/sbin/exim specified as the delivery agent in dspam.conf.

DIRECTORY SETTINGS

When changing the user/group it is highly advisable to set "home_directory"
and "current_directory" accordingly:

home_directory = "/path/to/dspam/dspam-home" # or "/tmp"
current_directory = "/path/to/dspam/dspam-home" # or "/tmp

Otherwise, the transport might try to run DSPAM in something like /home/bob
under certain circumstances. This will most likely fail if DSPAM runs as
"mail".

PASS-THROUGH

For a pass-through setup where DSPAM feeds all processed messages back to
Exim it is also a good idea to set "prefix" and "suffix" to an empty
string:
  prefix = ""
  suffix = ""

ALIASES

There is no need to create aliases for every user on the system in order to
handle spam reports and false positives. They can be handled by directors
and transports, using the following directors:

   dspam_addspam:
     prefix = spam-
     driver = localuser
     transport = addspam

   dspam_falsepositive:
     prefix = falsepos-
     driver = localuser
     transport = falsepositive

For every $user on the system, these directors will handle messages
addressed to "spam-$user@localhost" and "falsepos-$user@localhost", strip
the prefix from the address, and pass the message to the respective
transport. This requires two additional transports:

addspam:
  driver = pipe
  command = "/path/to/dspam --user $local_part --class=spam --source=error"
  return_path_add = false
  return_fail_output = true
  log_output = true
  home_directory = "/path/to/dspam/dspam-home" # or "/tmp"
  current_directory = "/path/to/dspam/dspam-home" # or "/tmp"
  user = mail
  group = mail
  prefix = ""
  suffix = ""
falsepositive:
  driver = pipe
  command = "/path/to/dspam --user $local_part --class=innocent --source=error --deliver=innocent"
  return_path_add = false
  return_fail_output = true
  log_output = true
  home_directory = "/path/to/dspam-home" # or "/tmp"
  current_directory = "/path/to/dspam-home" # or "/tmp"
  user = mail
  group = mail
  prefix = ""
  suffix = ""

This way, all users are handled transparently. No fiddling with aliases is
required as you add or remove users.


