I thought I understood "Alias domains" as that it's simply an alias for another domain! So when I set up a mailbox like "info@main.com", and add "alias.com" as a domain alias for "main.com" the address "info@alias.com" would also work... But no!

So, I've added these domains:

  • main.com
  • alias.com

I've created this mailbox:

  • info@main.com

Then I mapped these alias domains:

  • alias.com => main.com

And then when I send a mail to info@alias.com I receive this error:

Recipient address rejected: User unknown in virtual mailbox table (state 13).

I don't want to create an alias for every domain, as I have a few. I also don't want to use a wildcard (like info@*) because there are also other domains that aren't aliases of main.com

So... what are these exactly?

  • I expected the same and still don't understand why that's not the case. – Josh M. Jan 26 '15 at 21:12

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

| improve this answer | |
  • 3
    I can't seem to make sense of the docs - how do you have domain1.com alias any mailbox to <mailbox>@domain2.com? – Josh M. Jan 26 '15 at 21:16
  • 2
    @JoshM. You can use a hash table in virtual_alias_maps with an entry of the form @domain1.com @domain2.com. See my answer for details. – Sam Hanes Dec 29 '16 at 12:09

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.


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.


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.

| improve this answer | |
  • So, the PostfixAdmin interface have a bug, because the interface (edit.php?table=aliasdomain) fail to say to user that no alias in fact will occur when flagging it as enabled. – Peter Krauss Dec 27 '16 at 13:26
  • 2
    I wouldn't say it's a bug, exactly, since it does in fact configure a virtual alias domain. Rather, I suspect that PostfixAdmin expects you to know what Postfix virtual alias domains are, and that you also need to add actual aliases in order to make them do anything. It would probably be better if it told you that, though. – Sam Hanes Dec 29 '16 at 12:07

@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
| improve this answer | |
  • 1
    While not exactly incorrect (it'll do what you expect), using a regex table is less efficient than using a hash table with the @domain1.com @domain2.com syntax that I detailed in my answer. – Sam Hanes Dec 29 '16 at 12:04

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 mailbox@from.domain are all aliases.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.