I host a handful of domains on a single box (Linux, Ubuntu 13.x) and am attempting to use Postfix 2.10.2-1 to route mail to them. (I used sendmail for the past 10 years, so this is new to me.) All my MX
records are set up accordingly, so external mail is reaching the box just fine.
I followed the various online tutorials and have the following relevant lines in my configs:
main.cf
-------
myhostname = foo.a.com
myorigin = /etc/mailname # this just has 'a.com' inside it
mydestination = a.com localhost.localdomain localhost
virtual_alias_domains = b.com c.org
virtual_alias_maps = hash:/etc/postfix/virtual
At the moment I just want all mail addressed to postmaster at any of the domains to go to the postmaster account, and all mail addressed to anyone else at any of the domains to go to the associated account.
virtual
-------
[email protected] postmaster
@a.com userA
[email protected] postmaster
@b.com userB
[email protected] postmaster
@c.org userC
Unfortunately, all mail addressed to anyone at any of these domains is being routed to userA. Until I enabled verbose logging, I thought that the virtual domains were not being respected. After enabling verbose logging, however, I see this happening for every incoming mail:
mail.log
--------
...
postfix/cleanup: maps_find: virtual_alias_maps: hash:/etc/postfix/virtual(0.lock|fold_fix): @b.com = userB
postfix/cleanup: mail_addr_find: [email protected] -> userB
postfix/cleanup: send attr request = rewrite
postfix/cleanup: send attr rule = local
postfix/cleanup: send attr address = userB
But then trivial-rewrite runs again (for about the 80th time processing this particular piece of mail) and decides that userB is not the true final Unix account recipient, but that it instead represents a mail address at myorigin (or perhaps it's picking the first element in mydestination ... that would make more sense).
postfix/trivial-rewrite: master_notify: status 0
postfix/trivial-rewrite: rewrite socket: wanted attribute: request
postfix/trivial-rewrite: input attribute name: request
...
postfix/trivial-rewrite: 'local' 'userB' -> '[email protected]' # <-- d'oh!
postfix/trivial-rewrite: send attr flags = 0
postfix/trivial-rewrite: send attr address = [email protected]
postfix/trivial-rewrite: master_notify: status 1
Then postfix/cleanup
takes over
postfix/cleanup: maps_find: virtual_alias_maps: hash:/etc/postfix/virtual(0.lock|fold_fix): @a.com = userA
postfix/cleanup: mail_addr_find: [email protected] -> userA
postfix/cleanup: send attr request = rewrite
postfix/cleanup: send attr rule = local
postfix/cleanup: send attr address = userA
and concludes that userA is the true intended Unix account recipient.
I know almost nothing about Postfix, but it seems from the logs that it only decides on the final recipient address after running it through rewrite twice and getting the same result twice in a row. How do I prevent it from interpreting the local account userB as a mail address userB@mydestination[0]? I want it to stop as soon as it finds the local userB and just deliver it to him.
Am I not allowed to list @mydestination[0] within /etc/postfix/virtual? While that could perhaps solve my current problem (because these users are real Unix users on the box, so the mail would get to the right place), Postfix would still wind up thinking that [email protected] is the final recipient. That seems wrong to me. It should just know that userB is a Unix account and stop there.