Re: [Exim] Help with condition required

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Greg Ward
Ημερομηνία:  
Προς: exim-users
Αντικείμενο: Re: [Exim] Help with condition required
On 01 February 2002, Paul Walsh said:
> This set me thinking and the solution I'm trying to come up with uses a
> modified condition in the director which should only succeed if the received
> protocol isn't spam_checked AND the local part can be looked up in a file:
>
> spam_to_check:
> driver = smartuser
> transport = spam_scan
> condition = ${if and { {!eq {$received_protocol} {spam_checked} }\
> { eq {${lookup {$local_part} lsearch {/usr/exim/tables/SA_users} {1}}} {1}
> }\
>
> I'm obviously going wrong somwhere because I get the following error:


Ugh, don't you just hate trying to debug those hairy expansions? Oh,
for temporary variables!

Anyways, I recently went through a similar exercise. The director I
crafted to decide if someone's mail gets piped through SpamAssassin is a
little more complicated, because my /etc/exim/spamcheck_users
(equivalent to your /usr/exim/tables/SA_users) also acts like an alias
file: if someone is listed there, pipe their mail through SA, and then
deliver it to the address in the file. Here it is:

# Filter through SpamAssassin, but only if the local_part is mentioned
# in /etc/exim/spamcheck_users (an alias-like file).
spamcheck_user:
driver = smartuser
transport = spamcheck

  # Translated, this reads:
  #   if !(defined X-Spam-Flag) and
  #      !($received_protocol eq "spamcheck") then
  #      run this director
  condition = "${if and { {!def:h_X-Spam-Flag:} \
                          {!eq {$received_protocol}{spamcheck}} } {1}{0}}"
  local_parts = lsearch;/etc/exim/spamcheck_users


  new_address = ${lookup{$local_part} lsearch \
                        {/etc/exim/spamcheck_users} {$value}}


In the painful hours it took me to perfect this, I leaned about a very
valuable tool: "exim -be". Run that, and then build up your expansion
string a little bit at at time. Sooner or later, you'll find the
problem.

Hope that helps --

        Greg
--
Greg Ward - software developer                gward@???
MEMS Exchange                            http://www.mems-exchange.org