Nigel Metheringham edited this page Nov 29, 2012 · 2 revisions





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:

  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:

  driver = redirect
  data = ${lookup{$local_part}lsearch{/etc/aliases1}{$value,$local_part}}

  data = ${lookup{$local_part}lsearch{/etc/aliases2}}

This scales more easily to three or more alias files.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.