At 08:33 PM 2/2/2021, you wrote:

Quoting Viktor Dukhovni <postfix-us...@dukhovni.org>:

On Tue, Feb 02, 2021 at 06:12:01PM -0800, david wrote:

At 06:07 PM 2/2/2021, Viktor Dukhovni wrote:
>On Tue, Feb 02, 2021 at 06:46:32PM -0700, Bob Proulx wrote:
>
> > >
> > > a...@d1.tld    d1_a
> > > b...@d1.tld    d1_b
> > > @d1.tld     owner_d1
> > > @d2.tld     owner_d2
> >
> > I don't see anything wrong as such with the above.  Seems like it
> > should work.  And for me I have a very similar arrangement here.  So I
> > modified it so that I could test the above case here.  It worked for
> > me here.
>
>Look more closely.  The table as written cannot meet the OP's goals.
>So, no, it does not look like it should work.  It is expected to rewrite
>all the recipients to owner_d1, as reported by the OP.

Why would the line
   @d1.tld owner_d1
apply to ALL recipients?  I want it to apply to recipients at d1.tld,
not d2.dld.  What am I missing?

This is an easy question, that I was hoping someone else would field for
a change.

    1. Rewriting via virtual(5) is recursive, with recursion stopping
       either when there's no result, or a key maps to itself.
    2. Unqualified RHS values are qualified by appending @$myorigin

Each of these independently makes your table not sufficient for your
needs, in combination it is doubly unsuitable.  The correct syntax is:

    @d1.tld         owner...@d1.tld
    a...@d1.tld        d...@d1.tld
    b...@d1.tld        d...@d1.tld
    owner...@d1.tld owner...@d1.tld

    @d2.tld         owner...@d2.tld
    owner...@d2.tld owner...@d2.tld

When using wildcard mappings, always add explicit identity mappings for
RHS values that should not be further expanded.  Always append explicit
domains to RHS values in virtual(5), unless you specifically mean for
them to expand to localport@$myorigin with the suffix defined externally
in main.cf.

Finally, in some cases consider setting "append_mydomain = yes", if you
want to use "localpart@hostname" in tables, without having to specify
an explicit ".$mydomain" suffix after the hostname.  Note that this
is "$mydomain" not "$myorigin" as above.

Good luck.  Lots of folks on this list know the answer to this question,
I guess most of them have not paid attention to this thread (yet).

--
    Viktor.

If they're all local accounts, and local domain is d1.tld, should that
last line be?:
    owner...@d2.tld owner...@d1.tld


Regards

--
Mike.


I rebuilt my lists based upon the above suggestions, including Mike's last-line adjustment. I then tried to send mail to 'garb...@d2.tld', and it showed up in the mail for 'owner_d1', not the desired result. Of course, I'm not using those names; I've used fake names to protect the innocent. So I stared again, and I "think" I got it right. At least mail seemed to end up correctly, and an extra file showed up in /var/mail. So, to summarize, here's what seems to work:

main.cf is:

1) mydomain             = d1.tld
2) mydestination                = localhost.$mydomain localhost $mydomain
3) virtual_alias_domains        = d2.tld
4) virtual_alias_maps           = hash:/etc/postfix/virtualusers

Line 1 - This is the primary domain name of the server. It is **NOT** listed in line 3.
lin3 2 - We can receive mail for d1.tld
line 3 - We can also receive mail for d2.tld, and any other domains you want to list here. line 4 - The magic sauce. The file /etc/postfix/virtualuser becomes a database (postmap), and contains:

--------------------------
@d1.tld         owner...@d1.tld
owner...@d1.tld owner...@d1.tld

a...@d1.tld        d...@d1.tld
d...@d1.tld     d...@d1.tld

b...@d1.tld        d...@d1.tld
d...@d1.tld     d...@d1.tld

@d2.tld         owner...@d1.tld
owner...@d1.tld owner...@d1.tld

-----------------------------

This is different than noted above, and appears to work. Furthermore, it can be generated mechanically given the email address and the name of the local account that receives the data. Note the right-hand-side always uses the $mydomain. Maybe some of the 'map to itself' entries are not needed, but I couldn't figure out when they'd be needed and when not. The key piece of information that made it work was Victor's note about the recursive nature of the mapping.

--------------------

And to Victor and Mike, a pat-on-the-back and a "thank you". I can say that as verbose as the Postfix documentation is, this solution was far from obvious, and none of the tutorials I found even alluded to the recursive property. I guess that's what mail-lists are for.

It will take a few days to make sure this works before I modify my MX records to point to this server as the primary mail system. I hope I don't have to come back with an "ooops, it doesn't work".

David





Reply via email to