On Tue, Mar 23, 2021 at 10:16:31AM +1000, Simon Wilson wrote: > I run multiple local domains, and for the first time need to have the > same username in two of them go to different local accounts. > > I.e. my son has a local (LDAP) account "dom". Mail sent to > dom@his-personal-domain reaches that mailbox fine. He now has a > business domain, and I have setup a LDAP account dom.w, so > dom.w@his-business-domain works fine. What I want to be able to do is > rewrite dom@his-business-domain when it is received so it delivers to > dom.w@his-business-domain. > > From what I read at http://www.postfix.org/aliases.5.html I don't > think I can do this with aliases directly, as the "name" component of > the alias line is a local address with no domain part. What I need to > have happen (written in alias-style format) is this: > > dom@his-personal-domain: dom # this works fine already > dom.w@his-business-domain: dom.w # this works fine already > dom@his-business-domain: dom.w # this is the bit I want to add > > How do I achieve this with rewriting or aliasing, i.e. without having > to move to virtual domains?
You don't have to move to "virtual domains". The virtual(5) aliases table applies to all recipient addresses, regardless of "address class". In fact you should avoid local aliases(5) for address to address rewriting, and do all such rewriting in virtual(5) instead, using the aliases(5) file only for "|command", "/some/file" or ":include:" aliases. That said, I recommend making *all* you real domains be virtual alias domains, and using only "localhost.localdomain" or similar as the only domain in mydestination, with all addresses intended for local delivery rewritten into that domain as appropriate. In some cases I go further and add access(5) rules that block direct remote addressing of that domain, so that all inbound mail has to come through one of the virtual alias domains. So you can certainly migrate to virtual alias domains, which is a better model. -- Viktor.