Q0405 - Exim/exim GitHub Wiki
On a host that accepts mail for several domains, do I have to use fully qualified addresses in /etc/aliases or do I have to set up an alias file for each domain?
You can do it either way. The default aliasing router contains this line:
data = ${lookup{$local_part}lsearch{/etc/aliases}}
which is what does the actual lookup. To make it look up the complete address instead of just the local part, use
data = ${lookup{$local_part@$domain}lsearch{/etc/aliases}}
If you want to use a separate file for each domain, use
data = ${lookup{$local_part}lsearch{/etc/aliases/$domain}}
domain_aliases:
debug_print = "domain_aliases for $local_part@$domain"
driver = redirect
allow_defer = yes
allow_fail = yes
data = ${lookup{$local_part}lsearch*{${lookup{$domain}partial-lsearch{DOMAINDIR/map}\
{DOMAINDIR/$value}} }}
domains = partial-lsearch;DOMAINDIR/map
retry_use_local_part = yes
This router has a directory DOMAINDIR (you can use that as a macro or replace the three occurrences of the macro in the router). DOMAINDIR/map maps a domain to a file name (domain: filename), while DOMAINDIR/filename is the actual alias file. That way, you can map multiple domains to the same alias file.
DOMAINDIR/map
example.com: example1
example.org: example2
example.net: example2
example.biz: example3
DOMAINDIR/example1
user1: bill
DOMAINDIR/example2
user2: alison
DOMAINDIR/example3
*: bill
that way, `[email protected]`_ gets delivered to bill, while `[email protected]`_ and `[email protected]`_ both get delivered to alison, with all other combinations being handed down to the next router.
In the last example any messages sent to example.biz (like `[email protected]`_) will be delivered to bill. Note: This catches ALL messages sent to example.biz. It might and probably will also increase the amount of incoming spam
**-------------------------
-------------------------**
FAQ_ / `Routing for local delivery`_ **/ Q0405
-------------------------**
CategoryFrequentlyAskedQuestions_