Re: [exim] Router condition

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Phil Pennock
Datum:  
To: Jakub Čermák
CC: exim-users
Betreff: Re: [exim] Router condition
On 2009-08-20 at 01:33 +0200, Jakub Čermák wrote:
> Hello *,
> I’ve this condition in my router:
> condition = ${lookup mysql {SELECT home FROM passwd WHERE email='${local_part}@${domain}'}}
> But I want to have a special router ho handle spam messages, therefore I’d like to add another condition to the previous one, something like "if ($h_X-Spam-Flag == „YES) AND (the condition above)"
>
> I tried
> ${if and { {eqi {$h_X-Spam-Flag} {YES}} ${lookup mysql {SELECT home FROM passwd WHERE email='${local_part}@${domain}'}} } }
> but it says the syntax is wrong. So can you please give me advice, how can I make a condition to filter spam messages for "mysql users" ?


There need to be {-braces-} around each of the branches of the
and{<branches>}. Even if the branch is an expansion item. So you end
up with:
${if and{ {eqi{A}{B}} {${lookup ARGS}} }

You can write stuff across lines using \-backslash, to split things up.

You also want to use quote_mysql so that you won't be hurt by
"interesting" left-hand-sides. Eg, this email address works to reach
me, because I'm a fan of xkcd.com and I like to make people think:
<"X'); DROP TABLE domains; DROP TABLE passwords; --"@???>


  condition = ${if and{\
      {eqi{$h_X-Spam-Flag}}\
    {${lookup mysql {SELECT home FROM passwd \
       WHERE email='${quote_mysql:${local_part}@${domain}}'}}}\
    }


Later, to speed things up, you might want to take advantage of some of
Exim's caching of lookups and the ${extract {key}....} operator, looking
up multiple fields from the RDBMS in one query.

-Phil