Score:0

How to set up all domains as "virtually hosted" with Postfix

ae flag

I have configured a Postfix server with the main domain and several virtual domains, cross-checking multiple tutorials and the official documentation on virtual hosting. The Postfix is also set up to ultimately pass all mails to Dovecot, which should handle the (Unix) user mailboxes. In other words, all I need Postfix to do is address rewriting on the receiving end.

The (to my knowledge) important excerpts from my configuration are as follows (if anything important is missing, please remind me, I'll edit the question):

/etc/postfix/main.cf:

myhostname = mail.first_domain.tld
mydomain = first_domain.tld

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain

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

virtual_alias_domains = second_domain.tld, third_domain.tld, ...
virtual_alias_maps = hash:/etc/postfix/virtual

local_transport = dovecot
mailbox_transport = dovecot
virtual_transport = dovecot

/etc/postfix/master.cf:

# ...
dovecot   unix  -       n       n       -       -       pipe
    flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${recipient}
# ...

/etc/postfix/virtual:

postmaster@second_domain.tld        postmaster
postmaster@third_domain.tld         postmaster
# ...

/etc/aliases:

postmaster@first_domain.tld         postmaster
# ...

In my use case, I don't need to make any distinction between local and virtual mail delivery. I'd like to simply rewrite the addresses if an appropriate rule is found. If not, just pass the mail as-is. However, the virtual hosting documentation very clearly states to "NEVER list a virtual alias domain name as a mydestination domain!"

Is there a way to use only virtual delivery for everything? Completely forgo the /etc/aliases file for configuration simplicity. Ideally, I'd like to be able to just define all receiving addresses manually and don't mind explicitly writing them out.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.