Re: [exim] Router condition

Góra strony
Delete this message
Reply to this message
Autor: Jakub Čermák
Data:  
Dla: exim-users
Temat: Re: [exim] Router condition
Hi,
I tried it, and it says
2009-08-21 14:18:37 1MeFj2-0002yY-9v failed to expand condition "${if and{{eqi{$h_X-Spam-Flag}}{${lookup mysql {SELECT home FROM passwd WHERE email='${quote_mysql:${local_part}@${domain}}'}}}}" for mysql_user_spam router: missing 2nd string in {} after "eqi" inside "and{...}" condition

So I tried adding {YES} or {"YES"} after the eqi{$h_X-Spam-Flag}, so it looked like "${if and{{eqi{$h_X-Spam-Flag}{YES}}{${lookup mysql {SELECT home FROM passwd WHERE email='${quote_mysql:${local_part}@${domain}}'}}}}" but the error is still the same.

And adding YES instead of {YES} yielded in 2009-08-21 14:29:31 1MeFj2-0002yd-BP failed to expand condition "${if and{{eqi{$h_X-Spam-Flag}YES}{${lookup mysql {SELECT home FROM passwd WHERE email='${quote_mysql:${local_part}@${domain}}'}}}}" for mysql_user_spam router: missing 2nd string in {} after "eqi" inside "and{...}" condition error

What I'm doing wrong?

S pozdravem / Best regards

Jakub Čermák


-----Original Message-----
From: Phil Pennock [mailto:exim-users@spodhuis.org]
Sent: Thursday, August 20, 2009 8:07 AM
To: Jakub Čermák
Cc: exim-users@???
Subject: 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