[Vmail-discuss] domain aliasing with local delivery

Jakob Hirsch jh@xxxxxxxx
Sat, 27 Oct 2001 16:58:12 +0200


----- Original Message ----- From: "Paul Warren" <pdw@ex-parrot.com>

> > But it's only a workaround, that only works if the real domain is
> > listed in the domain-table before the alias domain.
> The alias domain should not be listed in the domain-table at all - only
> in the alias table.

That means, if I have a domain dom1, that should be aliased to another domain dom2, dom1 will be in
domain_alias table, but not in domain table? Then it's (at least partially :-) my fault, since I'm
using my own php-scripts for administration that put dom1 in both tables.

Another point: I wasn't aware of the fact that dom2 has to be local. Maybe I'll try to implement a
more generic form of aliasing that allows to use any domain as dom1 (with exim rewrite or
something).

> The problem (AIUI) was that a query for e.g. mydomain.com was producing:
>
> path    mbox_name   domain.domain_name  alias.alias
> foo     bar         mydomain.com        myalias.com
> foo     bar         mydomain.com
> foo     bar         mydomain.com        myotheralias.com

Sure? This query here only gives lines 1 and 3.
I think your "limit 1" is for a different problem I didn't come across yet: Having multiple domains
aliased to the same "real" domain. Funny that it (partially) fixed also my problem. :)
My problem was: The query for the path in virtual_localdelivery gave two different results, one for
dom1 and one for dom2, since both are in domain table with a path of "/var/spool/mail/<domain>".
I finally fixed this now with your "limit 1" and an additional WHERE:
SELECT path FROM domain LEFT JOIN domain_alias ON domain_alias.domain_name = domain.domain_name \
WHERE ( domain.domain_name = '$domain' \
AND ( domain_alias.alias != '$domain' OR domain_alias.alias IS NULL  )) \
OR domain_alias.alias = '$domain' LIMIT 1

> The contents of path and mbox_name are always there, and always correct,
> they just sometimes appear more than once.  The limit 1 means that only
> one will be returned.  Have I missed something?

Yes. :)
Sorry for not clearly stating that I use my own admin-scripts.

> also mentioned that the user query needs a limit 1:
> but I suspect you've already got that...

Not really, didn't even look for it, since I have the user hardcoded in exim.conf. I don't use
quotas and that's the only thing it's needed for, if I understand correctly.