Postfix can handle e-mails from multiple domains by mapping users from one domain to the other. A good example, is a machine with multiple domain names where the actual users are the same. This short tutorial explains how to configure postfix to handle e-mail from multiple domains by using the virtual domains feature of postfix.
You can create a file name, for example, domains
, in which you list all the additional domains that postfix should handle mail for:
somexample.com somexample.net somexample.org
and save it to, say, /etc/postfix/domains
. After that, run postmap
on the file:
postmap /etc/postfix/domains
When this is done, you can add the domain file to postfix's configuration by editing main.cf
and appending the path to the file to the mydestination
directory:
mydestination = $myhostname, /etc/postfix/domains
To map users from one domain to the other, create another file, called, say, addressmap
and save it to, say, /etc/postfix/addressmap
. This file should have a specific format, for example:
somexample.com DOMAIN joe@somexample.com jane jade@somexample.com jitty somexample.net DOMAIN @somexample.net office somexample.org DOMAIN @somexample.org office
which does the following:
joe
for the domain somexample.com
to the local user jane
jade
for the domain somexample.com
to the local user jitty
somexample.net
to the local user office
somexample.org
to the local user office
Note that these mappings respect the aliases which are usually placed at /etc/aliases
.
Once the addressmap
file is written, you can run postmap
on the file:
postmap /etc/postfix/addressmap
Finally, a reference to the file can be added to /etc/postfix/main.cf
in the virtual_maps
configuration key:
virtual_maps = hash:/etc/postfix/virtual/addressmap