Virtual Domain Aliases
January 29, 2009 Multiple Domains
Virtual aliases can map to addresses that do not terminate on the local system while regular aliases can only map to addresses which terminate on the local system.
Virtual Alias Domains
You will need to add these lines to the main.cf file.
virtual_alias_domains = example.com
If you were going to add a number of domains you would want to create a map file. Create the file /etc/postfix/virtual_alias_domains and enter one domain on each line and include the creation date on the right. Postfix will ignore the creation date but remember map files must have two sides.
myexample.com 20070608
example.com 20070801
newexample.com 20070803
Now create the db out of this file with this command:
postmap hash:/etc/postfix/virtual_alias_domains
If you use a database file as illustrated above you will need the parameter changed to this:
virtual_alias_domains = hash:/etc/postfix/virtual_alias_domains
Warning!
If you set up a domain as virtual DO NOT put it in the mydestination parameter.
Now you need to create the recipient address map. Create a file called:
/etc/postfix/virtual_alias_maps
The file will then create the mappings of the virtual address on the left and the address, local or remote that you want it to go to on the right column. The names are separated by a TAB.
test@myexample.com test@example.com
mike@example.com mike@another_example.com
joe@newexample.com joe@last_example.com
Save the file.
Execute the command to create the db file.
postmap hash:/etc/postfix/virtual_alias_maps
Add this line in the main.cf.
virtual_alias_maps = hash:/etc/postfix/virtual_alias_maps
service postfix reload
Testing the Virtual Alias Settings
Enter a mail address that you have listed in your virtual_alias_maps file to test.
echo testing | /usr/sbin/sendmail test@myexample.com

