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



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}}

A convenient cut-and-paste solution

  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 example1 example2 example2 example3

user1: bill

user2: alison

*: bill

that way, ``_ gets delivered to bill, while ``_ and ``_ both get delivered to alison, with all other combinations being handed down to the next router.

In the last example any messages sent to (like ``_) will be delivered to bill. Note: This catches ALL messages sent to It might and probably will also increase the amount of incoming spam




FAQ_ / `Routing for local delivery`_ **/ Q0405



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.