### router/450_stalag13-spamblock
#################################

.ifdef SPAMBLOCKING_BOGOFILTER
# spam checking
# first bogofilter
spamslay_router_bogofilter:
  debug_print = "R: bogofilter for $local_part@$domain_data received with protocol $received_protocol with X-Spam-Flag=$h_X-Spam-Flag and X-Bogosity=$h_X-Bogosity"
  # When to scan a message :
  #   -   it isn't already flagged as spam 
  #   -   it has not yet been spamslayed at all
  #   -   it isn't local ($received_protocol eq "" or local)
  condition = "${if and{ {!eqi{$h_X-Spam-Flag:}{yes}} {!eq{$received_protocol}{spamslayed-bogofilter}} {!eq{$received_protocol}{spamslayed-spamd}} {!eq{$received_protocol}{local}}  {!eq{$received_protocol}{}} }}"
  driver = accept 
  transport = spamslay_bogofilter
.endif

.ifdef SPAMBLOCKING_SPAMASSASSIN
# second spamd
# http://dman13.dyndns.org/~dman/config_docs/exim-spamassassin/node12.html
# (replaced by acl check)
spamslay_router_spamd:
  debug_print = "R: spamd for $local_part@$domain_data received with protocol $received_protocol with X-Spam-Flag=$h_X-Spam-Flag and X-Bogosity=$h_X-Bogosity" 
  # When to scan a message :
  #   -   it isn't already flagged as spam 
  #   -   it has not yet been spamslayed with SA
  #   -   ---COMMENTED--- it isn't already flagged as ham by bogofilter
  #   -   it isn't local ($received_protocol eq "" or local)
  condition = "${if and { {!eqi{$h_X-Spam-Flag:}{yes}} {!match{$h_X-Bogosity:}{^Spam}}  {!eq {$received_protocol}{spamslayed-spamd}} {!eq{$received_protocol}{local}} {!eq{$received_protocol}{}} }}"
  driver = accept
  transport = spamslay_spamd

# This route will send any mail that got here to the devnull alias, that
# should be configured in /etc/aliases to be a :blackhole:
# This route should get only mails that have spam score higher than 14.
# This will affect users mails!
spamslay_killit:
  condition = "${if ge{$h_X-Spam-Level:}{\*\*\*\*\*\*\*\*\*\*\*\*\*\*} {1}{0} }"
  driver = redirect
  data = spam
  file_transport = address_file
  pipe_transport = address_pipe
.endif