So what is meant by a virtual domain? A virtual domain is when a server hosts multiple domain names which all point to the same IP address. Virtual domains are relatively easy to set up in Postfix.
In this post I will speak of Virtual alias domains which simply expands the number of domains Postfix delivers mail to. This solution assumes the user has a user account on the system.
Firstly, modify the postfix configuration file to allow virtual domains:
sudo nano /etc/postfix/main.cf
and add the following lines:
virtual_alias_domains = mydomain.com, ...
virtual_alias_maps = hash:/etc/postfix/virtual
where mydomain.com is your virtual domain followed by any additional virtual domains separated with a ‘,’ and the path supplied for virtual_alias_maps (this will be created in the following step). Do not list virtual_domains under my_destination.
Next, create a file named virtual in the postfix directory:
sudo nano /etc/postfix/virtual
In this file you can map recipients to the virtual domains, eg you can create info@… e-mail addresses and map them to user accounts.
For example:
# mydomain.com
postmaster@mydomain.com postmaster
info@mydomain.com eliza
Always after creating or modifying a database mapping file run the postmap command:
postmap /etc/postfix/virtual
and reload the configuration file after modifying it:
postfix reload
At this point, virtual domains should be up and running!
For further information on configuring virtual domains, refer to the Postfix documentation on Postfix Virtual Domain Hosting Howto. Later, I will extend onto virtual mailbox domains where a virtual mailbox can be created for users without *nix accounts.