Setting your Postfix self-hosted mail server up for multiple domains

Use a single server to host email for multiple domains wqithout having to create a UNIX system account for every email.

  • With virtual alias domains, each hosted address is aliased to a local UNIX system account or to a remote address.
  • NEVER list a virtual alias domain name as a mydestination domain!
  • Execute the command postmap /etc/postfix/virtual after changing the virtual file, and execute the command postfix reload after changing the file.
  • Note: virtual aliases can resolve to a local address or to a remote address, or both. They don't have to resolve to UNIX system accounts on your machine.
# /etc/postfix/
virtual_alias_domains = ...other hosted domains...
virtual_alias_maps = hash:/etc/postfix/virtual
# /etc/postfix/virtual postmaster       joe      jane
# Uncomment entry below to implement a catch-all address
#         jim
...virtual aliases for more domains...

Mail accounts without system user accounts

Maildir style delivery where a mailbox pathname is used instead of a UNIX system account is used can be used to create virtual mailboxes. That way you don't have to create a system account for every user that you want to give email accesss to.

Maildir style delivery is turned on by terminating the mailbox pathname with /.

# Virtual Mailbox related config
# /etc/postfix/
virtual_mailbox_domains = ...more domains...
virtual_mailbox_base = /var/mail/vhosts
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_minimum_uid = 100
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_alias_maps = hash:/etc/postfix/virtual
# /etc/postfix/vmailbox:
# Comment out the entry below to implement a catch-all.
...virtual mailboxes for more domains...
# /etc/postfix/virtual: postmaster


Please note that this site and the posts on it are, and will always be, a work in progress. If i waited for perfection, i’d never get anything done.