I have configured a Postfix mail server for two domains: domain1.com and domain2.com.

In my configuration domain1 has both virtual users with Maildirs and aliases to forward mail to local users (eg. root, webmaster) and some small mailing lists. It also has some virtual mappings to non-local domains.

Domain2 on the other hand has only virtual alias mappings, mainly to corresponding 'users' at domain1 (eg. mails to root@domain2.com should be forwarded to root@domain1.com).

My problem is that currently Postfix accepts mail even for those users that don't exist in the system. Mail to existing users and /etc/aliases works fine. Postfix documentation states that the same domain should never be specified in both mydestination and virtual_mailbox_maps, but If I specify mydestination as blank then postfix validates recipients against virtual_mailbox_maps but rejects mail for local aliases of domain1.com.


myhostname = domain1.com
mydomain = domain1.com
mydestinations = $myhostname, localhost.$mydomain, localhost

virtual_mailbox_domains = domain1.com
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_mailbox_base = /home/vmail/domains

virtual_alias_domains = domain2.com
virtual_alias_maps = hash:/etc/postfix/virtual

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

virtual_transport = dovecot


domain1.com right-hand-content-does-not-matter
firstname.lastname user1
[more aliases..]

domain2.com right-hand-content-does-not-matter
@domain2.com @domain1.com


user1@domain1.com user1/Maildir
user2@domain1.com user2/Maildir


root: :include:/etc/postfix/aliases/root
webmaster: :include:/etc/postfix/aliases/webmaster

Is this approach correct or is there some other way to configure Postfix with Dovecot (virtual) Maildirs and Postfix aliases?


Yes, you can't have domain in both mydestination and virtual_mailbox_maps. To overcome this you need set mydestination in main.cf

mydestination = localhost.$mydomain, localhost

and in /etc/postfix/virtual

root@domain1.com   root@localhost
webmaster@domain1.com  webmaster@localhost

with this setup, email to root@domain1.com will be redirected root@localhost. Because localhost listed in mydestination then postfix will apply alias in /etc/aliases

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.