Postfix virtual: parent domain matches subdomains - I don't want it [closed]
-
13-09-2019 - |
Question
I have my /etc/postfix/virtual file:
sub.domain.com DOMAIN
@sub.domain.com user2
domain.com DOMAIN
@domain.com user1
The mail for @sub.domain.com still goes to user1 and that's not what I want. Here's my /etc/postfix/my.cnf just in cases:
mydomain = domain.com
myhostname = mail.domain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
virtual_alias_maps = hash:/etc/postfix/virtual
myorigin = $mydomain
mydestination = $myhostname, $mydomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 1073741824
recipient_delimiter = +
inet_interfaces = all
parent_domain_matches_subdomains =
Note, that I set parent_domain_matches_subdomains to empty. But it still doesn't help. Any ideas?
Solution
The right hand side of your virtual_alias_maps table is an unqualified username.
Postfix appends $myorigin to unqualified usernames, making it effectively
@sub.example.com user2@example.com @example.com user1@example.com
Now user2@example.com is caught by the catchall for @example.com.
Hence, mail for user2@example.com goes to user1.
You could change your Postfix config to this:
mydomain = example.com myhostname = mail.example.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases virtual_alias_maps = hash:/etc/postfix/virtual myorigin = $mydomain mydestination = $myhostname, $mydomain, localhost relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 1073741824 recipient_delimiter = + inet_interfaces = all parent_domain_matches_subdomains = virtual_alias_domains = sub.example.com luser_relay = user2@example.com
/etc/postfix/virtual
@sub.example.com user1@example.com
Create two system accounts user1 and user2.