Postfix has two important domains:

The relevant configuration in main.cf looks like this:

 virtual_mailbox_domains = /etc/postfix/virtual_mailbox_domains
virtual_alias_domains = /etc/postfix/virtual_alias_domains

What's the content in them? We can give an example as follows.

 # cat virtual_mailbox_domains
sample1.com
sample2.com
 # cat virtual_alias_domains
sample3.com
sample4.com

Here sample1.com and sample2.com have the real mailbox. While sample3.com and sample4.com are alias domains who have none mailbox.

After creating the two files, don't forget to reload postfix.

 # service postfix reload

And then, we need to create the real users who have the mailboxes. The real users are located in dovecot's userdb.

 # cat /etc/dovecot/dovecot-users 
[email protected]:{plain}strong_pass_here
[email protected]:{plain}strong_pass_here

How to create the real users for dovecot? please check my before note below.

Install postfix dovecot squirrelmail letsencrypt on ubuntu

For now, wen can setup the alias users for alias domains. The messages sent to alias users will be forwarded to the real users.

Add this line into main.cf:

 virtual_alias_maps = hash:/etc/postfix/virtual_alias_maps

The content in this file looks like this:

 # cat virtual_alias_maps
@sample3.com [email protected]
@sample4.com [email protected]

Here I just specified two catchall forwardings:

Surely you can also specify the specific users here, such as [email protected].

Run postmap to create the database for hash map, and reload postfix.

 # postmap virtual_alias_maps
# service postfix reload

All done. You can test it by sending a message to [email protected] which will be forwarded to [email protected]. And messages sent to [email protected] will be forwarded to [email protected].

Return to home | Generated on 11/06/22