Enable virtual domains for postfix

Enable virtual domains for postfix

Virtual domains can be used to route e-mails from multiple domains to the correct mailboxes. In order to make it work, some changes need to be made.

First we need to edit the main.cf (on my Ubuntu server in /etc/postfix/) and add the following lines:

virtual_alias_domains = yourdomain.org

virtual_alias_maps = hash:/etc/postfix/virtual

The first line contains all the domains which have to be checked, any domain not listed will be rejected (see postfix manual about virtual_alias_domains)

The second line specifies the file which contains the aliases (see postfix manual about virtual_alias_maps).

Create a file called “virtual” in the postfix folder and add lines such as:

The first line is an example where all the mail for [email protected] will be delivered to the local mailbox bas. The second line just forwards the mail to [email protected] The third line is the catch-all rule which catches all unmatched e-mail and forwards it to the local mailbox bas.

Now just one more thing: we need to generate the virtual.db file. In order to do this execute:

 # postmap /etc/postfix/virtual

Reload the new postfix config with:

 # /etc/init.d/postfix reload

Done!

Leave a Reply

Your email address will not be published. Required fields are marked *