Re: [exim] router condition, problem with "and"

Pàgina inicial
Delete this message
Reply to this message
Autor: Jonas Forsberg
Data:  
A: exim-users
Assumpte: Re: [exim] router condition, problem with "and"
On Thu, 19 Aug 2010 10:12:29 +0200, Marcin Mirosław <marcin@???>
wrote:
> W dniu 19.08.2010 09:06, Jonas Forsberg pisze:
>>
>>
>> Hello.
>> I am fairly new to exim4, so please be patient with me.
>>
>> I'm
>> trying to get a condition for a router to work as I expect, but I
>> clearly have issues understanding the syntax.
>>
>> The condition consists of
>> two parts:
>>
>> 1st a check in the Subject field after a string, that I have
>> got to work.
>>
>> condition = ${lookup mysql{
>> SELECT email FROM users
>>
>> WHERE email='${quote_mysql:$local_part}@${quote_mysql:$domain}'}
>>
>> {true}{false}}
>>
>> 2nd a check in a MySQL table, which I have been
>> working.
>>
>> condition = ${if match
>> {$h_subject:}{N^KalleKalas$N}{yes}{no}}
>>
>> but to combine those two into a
>> "and rule" makes my head spin. What ever I do exim4 logs that it can not
>> expand the condition.
>
> Hello!
> If you want to join this two condition with logical "and", it would be
> looks in this way:
>
> condition = ${if and{
> {lookup mysql{SELECT 1 FROM users WHERE
> email='${quote_mysql:$local_part}@${quote_mysql:$domain}'}}
> {if match {$h_subject:}{N^KalleKalas$N}{yes}{no}}}
> }
>
> I can't test it, i'm not sure about sql query (mayby it shoud be write
> in such way: {eq {1}{SELECT 1 FROM users WHERE
> email='${quote_mysql:$local_part}@${quote_mysql:$domain}'}
> )
>
> Regards,
> Marcin
>
> --
> xmpp (jabber): marcin [at] mejor.pl


Thanks for trying to help out.

Let me try to break down things a bit.

This works as I said before:


condition = ${if match {$h_subject:}{\N^kallekalas$\N}{yes}{no}}

if I replace that with a very stupid rule
condition = ${if and{ \
                     {eq \
                        {1} \
                        {1} \
                     } \
                     {eq \
                        {1} \
                        {1} \
                     } \
                   } \
                   {yes}{no} \
             }



it works like a charm. Changing one of the 1 to a 0 will not trigger
the condition.
I've broken down the "and" into several lines just to make it more
visible for me...

When I try to replace the first eq condition with my subject match like
this
condition = ${if and{ \
                     {match \
                        {$h_subject:} \
                        {\N^kallekalas$\N} \
                        {yes}{no} \
                     } \
                     {eq \
                        {1} \
                        {1} \
                     } \
                   } \
                   {yes}{no} \
             }


and it looks ok to me, but I get this in the mainlog
* 1Om1IO-0005ro-Bs failed to expand condition "${if and{ {match
{$h_subject:} {\N^kallekalas$\N} {yes}{no} } {eq {1} {1} } } {yes}{no}
}" for vmail_init router: missing } at end of condition inside "and"
group

I just can't understand why....

Cheers
Jonas