Virtual Alias Domain in Postfix

A reader Remo Mattei commented on my article about a Virtual Alias Domain issue. He got the Postfix 550 “Recipient address rejected: User unknown in virtual mailbox table;” error in maillog.

Since I don’t need this feature in my current setup, so it got ignored when I built and tested my mail system few months ago. After reading some documents online I managed get this work.

So what is Virtual Alias Domain?

Here is the defination from the official Postfix site:

Besides virtual aliases, the virtual alias table can also be used to
implement virtual alias domains. With a virtual alias domain, all
recipient addresses are aliased to addresses in other domains.

Virtual alias domains are not to be confused with the virtual mailbox
domains that are implemented with the Postfix virtual(8) mail delivery
agent. With virtual mailbox domains, each recipient address can have
its own mailbox.

With a virtual alias domain, the virtual domain has its own user name
space. Local (i.e. non-virtual) usernames are not visible in a virtual
alias domain. In particular, local aliases(5) and local mailing lists
are not visible as localname@virtual-alias.domain.

Confused? A little bit. Let’s use an example to explain it:

Let’s say I am hosting emails for both domain and All users will have both .com and .net email addresses. And we want all the emails send to .net to deliver to corrsponding .com address.

With the Virtual Alias Domain feature in Postfix, I can simply do:

  1. Create domain and;
  2. Setup virtual alias domain with the target domain set to;
  3. Add Mailbox for users (e.g. and,etc.)

Now all the email send to will be delivered to mailbox. So does for Bob.

Postfix Configuration

If you followed my previous post on setup Postfix and PostfixAdmin, then you can continue here. If you use different setup, then you need alter the configuration accordingly.

Here I’ll show you how my configuration to:

  1. Enable Postfix to use Virtual Alias Domain feature;
  2. Create MySQL connectors to connect to PostFixAdmin database.


In the Part 2 I have the following settings in /etc/postfix/

relay_domains = proxy:mysql:/etc/postfix/
virtual_alias_maps = proxy:mysql:/etc/postfix/,regexp:/etc/postfix/virtual_regexp
virtual_mailbox_domains = proxy:mysql:/etc/postfix/
virtual_mailbox_maps = proxy:mysql:/etc/postfix/
virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $smtpd_sender_login_maps $sender_bcc_maps $recipient_bcc_maps $smtp_generic_maps $lmtp_generic_maps $alias_maps $virtual_mailbox_limit_maps

Now use the following lines to replace the following three lines respectively:

virtual_mailbox_domains = proxy:mysql:/etc/postfix/
virtual_alias_maps =
virtual_mailbox_maps =

MySQL connection configuration

Now we need Postfix to make connections to MySQL databse (Created by PostfixAdmin) and to qurey the database.
So let’s create 3 new configration files:

  1. /etc/postfix/

    hosts = localhost
    user = postfix
    password = PApassword
    dbname = postfix
    query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('%u', '@', alias_domain.target_domain) AND = 1 AND'1'
  2. /etc/postfix/

    user = postfix
    password = PApassword
    hosts = localhost
    dbname = postfix
    query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('@', alias_domain.target_domain) AND = 1 AND'1'
  3. /etc/postfix/

    user = postfix
    password = PApassword
    hosts = localhost
    dbname = postfix
    query = SELECT maildir FROM mailbox,alias_domain WHERE alias_domain.alias_domain = '%d' and mailbox.username = CONCAT('%u', '@', alias_domain.target_domain) AND = 1 AND'1'

Do not forget to set the correct permission on these new files:

chgrp postfix /etc/postfix/mysql-virtual_alias_domain*
chmod 640 /etc/postfix/mysql-virtual_alias_domain_*

Restart Postfix (or MailScanner), check maillog and make sure no errors.

PostfixAdmin Setup

Go to PostfixAdmin and login as administrator. Add two new domain and

Then go toVirtual List then Add Alias Domain. Select as the Alias Domain. Set the Target Domain to

Now add an user mailbox for domain For example


Send an email to see the virtual alias domain feature in action. The email send to should arrive to the inbox of