[exim] reusing a complicated query

Top Page
Delete this message
Reply to this message
Author: Ferenc Wagner
Date:  
To: exim-users
Subject: [exim] reusing a complicated query
Hi,

In a smarthost config currently I run two redirect routers, the first
doing an LDAP query, and if that gives no results, the second doing a
MySQL query and also providing a default. Both of these queries work on
$local_part (this setup is to handle local emails generated on servers
having central user databases):

redirector_ldap:
hide data = ${lookup ldap {[...](uid=${quote_ldap:$local_part})}}

redirector_mysql:
  data = ${lookup mysql{[...]'${quote_mysql:$local_part}')} \
                       {${tr{$value}{\n}{,}}}{default@???}}


where the [...]s are rather long strings.

Now, to handle the possible bounces, I have to set errors_to similarly,
unless $return_path is already set to a nonlocal domain (as neither the
smarthost, nor the clients handle incoming mail). This means I'll have
to join the two queries, as there's no decline mechanism for errors_to.
Once I've done that, I'd also merge the two routers, so that there's
only one errors_to to fill out with the ugly beast resulted from joining
the queries. But then I'm still left with two occurences of the ugly
beast: one acting on $local_part in data, and another acting on
$return_path for errors_to. How could I avoid this? I'd need a
parametrized macro, but that's not available, as far as I can see. Of
course I could use three macros (INIT $local_part MIDDLE $local_part
TAIL), but that's still rather ugly. Any better ideas?
--
Thanks,
Feri.