About

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.

Creating the Domains File

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

Mapping Users

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:

  • it maps joe for the domain somexample.com to the local user jane
  • it maps jade for the domain somexample.com to the local user jitty
  • it maps all e-mails for the domain somexample.net to the local user office
  • it maps all e-mails for the domain 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

networking/postfix/multiple_domains.txt ยท Last modified: 2022/04/19 08:27 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.