Re: [Exim] substituting $local_part after mysql query

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Peter Lockhart
Fecha:  
A: Philip Hazel
Cc: exim-users
Asunto: Re: [Exim] substituting $local_part after mysql query
Philip,

Thanks very much for the help so far.

sample entries:
    +---------------------+---------+-----------+
    | userid              | aliasid | domain    |
    +---------------------+---------+-----------+
1-> | notlocal            | bob     | abc.co.za |
2-> | peter@??? | peter2  | abc.co.za | 
    +---------------------+---------+-----------+


This now works fine, except that it wont deliver to non-existant local
users.
-> unknown local-part "notlocal" in domain "localhost"
should the address expand to a non-local user, seen in entry 1 above.

Delivery to valid local users or an address expanding to a remote
address is fine though (as expected).

So basically, for my needs, including 'transport = local_delivery' in
the director is fine so long as the expanded mysql query does not
contain an "@" (entry 2 above), in which case further expansion must
happen. This will mean all query-results without an "@" will be
delivered to /var/mail/${local_part} whether they exist as valid system
users or not.

This is what I want, just append mail to /var/mail/${local_part} should
it exist in the mysql table, else expand the address again, and
optionally send to a router (should the query result in
user@???)

The only solution I can think of is to have two almost identical
directors, the first with a test condition which says "execute this if
the mysql query result contains an '@'". The second director would be
the same except for containting the line "transport = local_delivery".
(this does feel a little awkward though, relying on regexps for a
transport result, still ... :)

Trouble is, whats the correct syntax ? :)

mysql_system_aliases:
condition = ${if match {$value}{@}{yes}}
driver = aliasfile
search_type = mysql
query = "select userid from domain_table where aliasid='$local_part'
and domain='$domain'"

The condition statement never matches:
-> calling mysql_system_aliases director
-> mysql_system_aliases director skipped: condition failure
Substituting $value with $local_part, $key, $query or escaping the "@"
dont make a difference. (As a side note , is the entire director
evaluated before the condition is tested ?)

What is the correct format to have this condition work ?
Also , any better ways to do this ? (I'd prefer not to add a boolend
field to the table such as "is_local")

Regards
Peter Lockhart

Philip Hazel wrote:
>
> On Mon, 17 Apr 2000, Peter Lockhart wrote:
>
> > I am setting up a mysql-driven exim to deliver mail to non-system users.
> >
> > My director:
> >
> > mysql_system_aliases:
> >   driver = aliasfile
> >   search_type = mysql
> >   query = "select userid from domain_table where aliasid='$local_part'
> > and domain='$domain'"
> >   transport = local_delivery
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^
> This is your problem. Aliasfile operates *entirely differently* if you
> give it a transport. Take that away, and it will do normal aliasing,
> that is, turn one address into another, which is independently
> processed.

>
> --
> Philip Hazel            University of Cambridge Computing Service,
> ph10@???      Cambridge, England. Phone: +44 1223 334714.

>
> --
> ## List details at http://www.exim.org/mailman/listinfo/exim-users Exim details at http://www.exim.org/ ##