Postfix: what exactly are alias domains?

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


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.


@Josh M.

I have no idea whether this is the right way and/or good practice but I'm using something like this:

virtual_alias_maps = regexp:/etc/postfix/domain_rewriting pgsql:/etc/postfix/pgsql/     virtual_alias_maps.cf

$ cat /etc/postfix/domain_rewriting 
/^(.*)@domain1.com$/     ${1}@domain2.com

This is my short version of @sam-hanes ' answer (that worked for me)

In your virtual_alias_maps add :

@from.domain <tab> @to.domain

In the command line do :

 postmap /path/to/yourvirtualalismapsfile

In your main.cf file add :

virtual_alias_domains : from.domain

virtual_alias_domains tells postfix that all mailbox addresses that are in the form of [email protected] are all aliases.