Q0427 - Exim/exim GitHub Wiki
Q0427
How can I have an address looked up in two different alias files, and delivered to all the addresses that are found?
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.