Re: [exim] Router condition

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Phil Pennock
Date:  
À: Jakub Čermák
CC: exim-users
Sujet: Re: [exim] Router condition
On 2009-08-20 at 01:33 +0200, Jakub Čermák wrote:
> I’ve this condition in my router:
> condition = ${lookup mysql {SELECT home FROM passwd WHERE email='${local_part}@${domain}'}}


Wait a moment ... I missed something here.

condition = "/home/dir/of/user"

This only works because on Routers, condition = XXX evaluates true for
all XXX other than "0", "no", "false" and empty strings. On ACLs, that
historical leniency does not exist. Yes, this is confusing.

When putting it inside an ${if and{{C1}{C2}}} condition check, you don't
have it so easy.

There's a chance that Exim 4.70 will include a bool{} expansion
condition, so that you could use
bool{${lookup mysql {SQL-STATEMENT} {yes}{no}}}
per: http://bugs.exim.org/show_bug.cgi?id=167
but it's not committed yet.

In the meantime, you need to use:
eq{${lookup mysql {SQL-STATEMENT} {yes}{no}}}{yes}
to get an expansion condition which is true/false.

(I also see that in my untested demonstration of expansion, I missed the
second part of the eqi{}{} test; an error of haste. Sorry.)


I think that this is what you need.

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


Alternatively, you can make it clearer that you're using the SQL lookup
to get yes/no out but using:

  condition = ${if and{\
        {eqi{$h_X-Spam-Flag:}{YES}}\
        {eq{${lookup mysql {SELECT "yes" FROM passwd \
           WHERE email='${quote_mysql:${local_part}@${domain}}
       AND home IS NOT NULL'}\
       }}{yes}}\
        }}


Regards,
-Phil