Re: [exim] expansion variables in routers?

Página Principal
Apagar esta mensagem
Responder a esta mensagem
Autor: David S. Madole
Data:  
Para: exim-users
Assunto: Re: [exim] expansion variables in routers?
From: "matthew dunham" <matthewdunham@???>
>
> what would be preferable, from an efficiency/flexibility standpoint,
> would be to do a single sql query that sets a number of expansion
> variables at once. ideally then each router could do tests on these
> expansion variables rather than using its own sql query. is this
> possible? and if so, could someone illustrate a brief example?


The simplest way to do this is to set $address_data with an SQL queries
that retrieves everything you need at once within one router. This sets
$address_data to a string of the format "col1=val1 col2=val2 col3=val3"
etc, with the actual column names and values. You can then use the
${extract operator to access individual elements. The $address_variable,
once set, sticks with the delivery address across multiple routers.

I actually have a router in my configuration that does nothing but
populate $address_data, because $address_data is expanded last and I need
it in preconditions for following routers. My configuration is structured
something like this:

lookup:
  driver = redirect
  data = ""            # basically a no-op router
  address_data = \
    ${lookup mysql{select 1 as a, 2 as b, 3 as c, 4 as d} \
     {$value}fail}


router1:
  driver = redirect
  condition = ${extract{a}{$address_data}} # returns 1
  data = ${extract{b}{$address_data}}      # returns 2


router2:
  driver = appendfile
  file = ${extract{c}{$address_data}}      # returns 3


And so on. See the documentation on $address_data and ${extract for
detailed information.

David