Postfix: what exactly are alias domains?

Solution 1:

Adding alias.com to virtual_alias_domains is the correct first step, but that just tells Postfix that you want to use that domain for aliases. It doesn't say what the aliases should be. For that, you need to use a virtual alias map.

First, add something like this to main.cf:

virtual_alias_domains = alias.com
virtual_alias_maps = hash:/etc/postfix/virtual

Adding virtual_alias_maps gets you a file (/etc/postfix/virtual) that's used as a virtual alias map. But what do you put in that file? According to the virtual(5) manpage:

The input format for the postmap(1) command is as follows:

  pattern address, address, ...

When pattern matches a mail address, replace it by the corresponding address.

and

With lookups from indexed files such as DB or DBM, or from networked tables such as NIS, LDAP or SQL, each user@domain query produces a sequence of query patterns as described below. Each query pattern is sent to each specified lookup table before trying the next query pattern, until a match is found.

...

@domain address, address, ...

Redirect mail for other users in domain to address.

and

The lookup result is subject to address rewriting: When the result has the form @otherdomain, the result becomes the same user in otherdomain. This works only for the first address in a multi-address lookup result.

Therefore, putting this in /etc/postfix/virtual will achieve the full-domain alias that you want:

# map any <user>@alias.com to the matching <user>@main.com
@alias.com     @main.com

Then, since that file is a hash table, you need to run postmap (explanation, manpage):

postmap /etc/postfix/virtual

You can find more information about virtual domains in the Postfix Virtual Domain HOWTO and about aliases in the Postfix Address Rewriting HOWTO.

Solution 2:

The explanation is in the documentation: http://www.postfix.org/VIRTUAL_README.html#virtual_alias

You want "alias mailboxes" aka virtual_mailbox_alias and virtual_mailbox_maps but talk about "alias domains": http://www.postfix.org/ADDRESS_CLASS_README.html#virtual_alias_class

Tags:

Postfix