Table of Contents

Mail Server#MTA (mail transfer agent)

Postfix Virtual Domain Configuration Examples


Postfix Commands and Configuration Examples




Method 1. mydestination

/etc/postfix/main.cf
mydestination = example.com, test.com
# systemctl reload postfix     <- CentOS7, 8



example.com and test.com are the same

ex.
user01@example.com = user01@test.com


Method 2. virtual alias

/etc/postfix/main.cf
virtual_alias_domains = test.com
virtual_alias_maps = hash:/etc/postfix/virtual
# systemctl reload postfix     <- CentOS7, 8
/etc/postfix/virtual
test.com        anything
user1@test.com  user1
user2@test.com  user2
# useradd user1
# useradd user2
# postmap /etc/postfix/virtual


Method 3. virtual mailbox

/etc/postfix/main.cf
virtual_mailbox_domains = test1.com  test2.com
virtual_mailbox_maps = hash:/etc/postfix/virtual-mailbox
virtual_uid_maps = static:2000
virtual_gid_maps = static:2000
virtual_mailbox_base = /var/spool/virtual
# groupadd -g 2000 vmail
# groupadd -u 2000 -g vmail vmail

# mkdir /var/spool/virtual
# chown -R 2000,2000 /var/spool/virtual
# systemctl reload postfix     <- CentOS7, 8
/etc/postfix/virtual-mailbox
user1@test1.com          test1.com/user1/Maildir/
user2@test1.com          test1.com/user2/Maildir/
user10@test2.com         test2.com/user10/Maildir/
user11@test2.com         test2.com/user11/Maildir/
# postmap /etc/postfix/virtual-mailbox