david wrote:
> To accomplish this, I set values in /etc/postfix/main.cf:
>
> mydomain      = d1.tld
> mydestination = localhost.$mydomain localhost $mydomain
> virtual_alias_domains = d2.tld
> virtual_alias_maps = hash:/etc/postfix/virtualusers
>
> The file /etc/aliases contains:
> root: owner_d1
>
> and the file /etc/postfix/virtualusers contains:
>
> a...@d1.tld      d1_a
> b...@d1.tld      d1_b
> @d1.tld       owner_d1
> @d2.tld       owner_d2

Viktor Dukhovni wrote:
> Bob Proulx wrote:
> > 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.

Hmm...  Yet I did dummy up the same test case and try it and it
"Worked For Me".  Which leads me extra confused when you say it won't
be sufficient.  Since it was sufficient for me. (shrug)

One thing I do see now is that since only d2.tld is declared in
virtual_alias_domains then why would @d1.tld in the virtual table have
any effect at all?  My experience has been that only domains declared
as being in virtual_alias_domains can be mapped through the virtual
table.  No?  Therefore three of those lines would seem to have no
effect.

> a...@d1.tld      d1_a
> b...@d1.tld      d1_b
> @d1.tld       owner_d1

And actually my test case as I look now was only on the next part.

> @d2.tld       owner_d2

The domain declared as a virtual.  Seems like since there is only one
entry for d2.tld and it is an "@d2.tld" entry that it would apply to
the entire domain and all mail there would map to owner_d2.  And since
there is no domain it would map to owner_d2@$myorigin as you note below.

> david wrote:
> > 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.  

I could tell that because you answered part of it but not more. :-)
Therefore I gave it my best shot!  And the parts I answered I tried to
answer as factually as possible.

However I don't see the problem you say I should be seeing even now
when looking at it again and closely.

>     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

Why is adding @d1.tld on the RHS is required if myorigin is equal to
d1.tld already?  Since that is already added by default.  Isn't the
above the same with or without @d1.tld on the RHS?

But does d1.tld get mapped through virtual if it is not declared to be
virtual?  I didn't notice that before or I would have commented about
that point in my previous message.

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

Since the default would have been equivalent to adding @d1.tld then if
one wants them to be in the @d2.tld then yes of course @d2.tld would
need to be added.  But I presume that the OP wanted them in d1.tld
domain.  However perhaps not.

I actually don't know what myorigin is set to but the OP said that
mydomain was set to d1.tld and therefore I presume that either d1.tld
or a host.d1.tld is what would get added to the RHS and probably the
result is the same then in either of those cases.  They would be for me.

> 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.

In my case I usually want them to be expanded to $myorigin and/or
$mydomain here.  And I presume that the OP was expecting the same
there.

In my case myorigin and mydomain are only different in a way that
makes no difference to me here.  myorigin = havoc.proulx.com on my
mail relay but mydomain = proulx.com there.  Which for me will end up
being no difference in the result as far as I can see.  However...

> > mydestination = localhost.$mydomain localhost $mydomain

Looking now I do not see $myhostname in that list.  I would suggest
that to be added.

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

> 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.

Perhaps append_dot_mydomain=yes was the intended setting to mention here?

> 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).

It is true that trying to explain something is how I find out what I
don't know.  And so I find trying to answer questions is one of the
best ways to learn the limits of my knowledge. :-)

It's taken me a while to type this in.  I am going to send it
regardless that other responses have flowed around it while I was
typing this.

Bob

Reply via email to