Re: [exim] Hints needed to run forwarded messages through a …

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: David S. Madole
Data:  
Para: 'exim-users@exim.org'
Asunto: Re: [exim] Hints needed to run forwarded messages through a pipe
> From Marc Sherman on Wednesday, June 27, 2007 11:20 AM
> David S. Madole wrote:
> >
> > I do an extensive amount of message processing based on database
> > content, and one thing that works well for me is to have a dummy
> > router early in the chain that does the database lookup and
> populates
> > $address_data with everything that will be needed later, with the
> > individual fields accessible through ${extract ...}. It can
> save a lot
> > of ad-hoc database lookups scattered all over the configuration.
> >
> > Mine looks like this:
> >
> > lookup:
> >
> > driver = redirect
> > data = ""
> > address_data = ${lookup mysql { select userid, domain,
> mailto, ....
> } {$value} }
>
> Does address_data still get set even if the router declines
> because of the blank data?


Yes. That is the exact form that I use. From the docs:

"The string is expanded just before the router is run, that is, after all the precondition tests have succeeded... When the expansion succeeds, the value is retained with the address, and can be accessed using the variable $address_data in the current router, subsequent routers, and the eventual transport."

Note that you could in most cases just do this in the first router that actually does something, I just found it easier organizationally to put it in it's own dummy router, partly because I use redirect_router later on to point to the router after when the lookup should not be performed again after a redirect.

Note that too, you can easily update the value of single items in the list later on by prepending the new key/value paur to $address_data since extract works left to right and returns the first match.

address_data = mailto=newmailtovalue $address_data

Even if $address_data already contained a mailto key/value, the new one will be returned by subsequent ${extract}s. It is of course easy to add completely new key/values too through the same construct. I regard $address_data as an array.

David