Posted by ybiC on Mon 10 Apr 2006 at 09:45
I'm configuring a Debian Sarge/Exim4 host to act as an email gateway between the internet and a private LAN email server. The intent is to forward incoming email messages for some users not only to the internal email host, but also back out to their home email addresses.
The Exim FAQ Q0427 shows a technique that looks promising - mulitple aliases files. But in which Exim configuration file should the given block be placed? Fwiw, I'm using the default of "multiple config files" for Exim4.
Or is there a better approach?
cheers,
ybiC
How can I have an address looked up in two different alias files, and delivered to all the addresses that are found?
Answer
Use a router like this:
multi_aliases:
driver = redirect
data = ${lookup{$local_part}lsearch{/etc/aliases1}\
{$value${lookup{$local_part}lsearch{/etc/aliases2}{,$value
\
*
{${lookup{$local_part}lsearch{/etc/aliases2}{$value}fail}}}\
}}}
If the first lookup succeeds, the result is its data, followed by the data from the second lookup, if any, separated by a comma. If the first lookup fails, the result is the data from the third lookup (which also looks in the second file), but if this also fails, the entire expansion is forced to fail, thereby causing the router to decline.
Another approach is to use two routers, with the first re-generating the original local part when it succeeds. This won't get processed by the same router again. For example:
multi_aliases1:
driver = redirect
data = ${lookup{$local_part}lsearch{/etc/aliases1}{$value,$local_part}}
multi_aliases2:
data = ${lookup{$local_part}lsearch{/etc/aliases2}}
This scales more easily to three or more alias files.
This article can be found online at the Debian Administration website at the following bookmarkable URL:
This article is copyright 2006 ybiC - please ask for permission to republish or translate.