Jerry Jerry - 4 months ago 9x
Linux Question

Postfix: which option for multiple domains and multiple users?

Our server will have three domains:,, and
For each, the info@... and webmaster@... should be working (but can be shared / forwarded to one). For the .org and .nl domains those will be the only users. For the .net domain there will be a few dozen users. The .net domain will be the main address for website and email.

The users will have no SSH access, no mysql access, no ftp access, only mailboxes.

Postfix and Dovecot are running now. Dovecot currently looks at unix account for mailboxes but that can change.

On this page I read about the different options for Postfix:
but it's not clear enough to me which is best for us, what the pros and cons are.

I lack the knowledge to make a good choice on which is the best option for us.
* the .net domain is the main address for website and email
* info@ and webmaster@ for .net/.org/.nl should have a mailbox, but it's OK if that's just one mailbox for info@ and one for webmaster@ and the others are forwarded to those and
* users only have, I don't care if and work or not

Any suggestions?



Before I go and describe how you can do this I must warn you - it is fairly easy to have your postfix server misconfigured which can result making it working as open-relay. Make sure you test it on sites like this:

Also I would recommend "The book of postfix" by Ralf Hildebrandt and Patric Koetter.

Now - to the answer.

Postfix offers functionality called "virtual mailbox". Not to go deep into details - you can list all your domains with virtual_mailbox_domains configuration option within your; this option works together with virtual_mailbox_maps, virtual_alias_maps and virtual_alias_domains. See example piece of configuration from my below:

myhostname =
virtual_mailbox_domains =,
virtual_uid_maps = static:2000
virtual_gid_maps = static:2000
virtual_mailbox_base = /home/postfix/virtual_mailboxes/
virtual_mailbox_maps = hash:/etc/postfix/virtual_mailboxes/virtual_mailbox_recipients
virtual_alias_maps = hash:/etc/postfix/virtual_mailboxes/virtual_mailbox_aliases
virtual_alias_domains = hash:/etc/postfix/virtual_alias_domains

myhostname is required by postfix and this should be your primary domain.

Example /etc/postfix/virtual_mailboxes/virtual_mailbox_recipients account1/ account2/ account3/

/home/postfix/virtual_mailboxes/{account1,account2,account3} directories must exist.

You can then add some aliases within /etc/postfix/virtual_mailboxes/virtual_mailbox_aliases,,

You point your virtual mailboxes in your dovecot configuration like this:

mail_location = maildir:/home/postfix_vuser/virtual_mailboxes/%n

(from dovecot documentation %n - user part in user@domain, same as %u if there's no domain)