2.4. Configuring Postfix as a destination for multiple domains
You can configure Postfix as a mail server that can receive emails for multiple domains. In this configuration, Postfix acts as the final destination for emails sent to addresses within the specified domains. You can configure the following:
- Set up multiple email addresses that point to the same email destination
- Route incoming email for multiple domains to the same Postfix server
Prerequisites
- You have the root access.
- You have configured a Postfix server.
Procedure
In the
/etc/postfix/virtualvirtual alias file, specify the email addresses for each domain. Add each email address on a new line:<info@example.com> <user22@example.net> <sales@example.com> <user11@example.org>In this example, Postfix redirects all emails sent to info@example.com to user22@example.net and email sent to sales@example.com to user11@example.org.
Create a hash file for the virtual alias map:
# postmap /etc/postfix/virtualThis command creates the
/etc/postfix/virtual.dbfile. Note that you must always re-run this command after you update the/etc/postfix/virtualfile.In the Postfix
/etc/postfix/main.cfconfiguration file, add thevirtual_alias_mapsparameter and point it to the hash file:virtual_alias_maps = hash:/etc/postfix/virtualReload the
postfixservice to apply the changes:# systemctl reload postfix
Verification
- Test the configuration by sending an email to one of the virtual email addresses.
Troubleshooting
-
In case of errors, check the
/var/log/maillogfile.