Re: [Exim] Combining conditions . . .

Top Page
Delete this message
Reply to this message
Author: Konrad Michels
Date:  
To: Nico Erfurth
CC: Exim-Users (E-mail)
Subject: Re: [Exim] Combining conditions . . .
Much obliged Nico! I'll work this through tomorrow: my brain is already
fried enough for today! Many thanks!

On Thu, 2004-06-03 at 16:03, Nico Erfurth wrote:
> Konrad Michels wrote:
> > Hi again folks
> > I've managed to sort out my routers for the mysql queries to give a 550
> > error: if anyone's interested I'll post it - just let me know.
> >
> > What I'm attempting to do now, well, what I've actually done already is
> > setup an autoreply transport being called by a router to do vacation
> > replies. It all works quite neatly, but I've one thing that I've not
> > quite managed yet, all due, I suspect, to to many {{{{{}}}}}{{{}{}{{}'s
> > and me not being able to see the logic for the {}'s!
> >
> > In my router that calls the autoreply transport, I've got a condition
> > statement which checks the database to check whether or not the router
> > must be run:
> >
> > condition = ${if eq{} {${lookup mysql{SELECT autoresponder \
> >                FROM smtp WHERE autoresponder='yes' \
> >                AND username='$local_part@$domain' \
> >                }}}{no}{yes}}

>
> *cough**cleaningglasses*
> If your autoresponder is an enum that only can return yes/no you can
> easily use
> ${lookup mysql{select autoresponder from smtp where \
>    username='${quote_mysql:$local_part}@$domain'}}

>
> > So, quite simply, if there's a "yes" in table "smtp" and field
> > "autoresponder", it will run the router, which it does.
> >
> > What I've got from a previous exim installation's vacation router though
> > is the following condition:
> >
> > condition = "${if or {{match {$h_precedence:} {(?i)junk|bulk|list}} \
> >                 {eq {$sender_address} {}}} {no} {yes}}"

> >
> > which is also fairly straightforward in making sure we don't respond to
> > certain types of mail.
> >
> > What I've been struggling with is combining the two conditions in the
> > router. Don't know if I'm on the right track here, but I would sure
> > appreciate some assistance in getting the two conditions combined.
> >
> > Many thanks for your time and patience!
>
> It helps to seperate the single conditions into seperate lines. Also,
> you don't need to use and/or every time.
>
> I would suggest something like:
>
> ${if or {\
>            { match {$h_precedence:} {(?i)junk|bulk|list} } \
>            { eq {$sender_address} {} } \
>          } {no} \
>            {${lookup mysql{select autoresponder from smtp where \
>               username='${quote_mysql:$local_part}@$domain'}}}\
>   }

>
> First with a have or-condition, with two sub-conditions (match and eq),
> these are evaluated, when ONE of them is true, no is returned. When none
> of them is true, the lookup is started, that will return yes or no,
> depending on the current autoresponder setting.
>
> (untested, but should work)
>
> Usually exim -d+expand -be is your friend for testing.
>
> Nico