Re: [Exim] One mysql query

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Maykel Moya
Datum:  
To: Nico Erfurth
CC: exim-users
Betreff: Re: [Exim] One mysql query
> for ACLs you could do:
>
> set acl_m0 = ${lookup mysql {select f1,f2,f3 from table where f4='x'}}
>
> and ${extract {f1}{$acl_m0}} will return the data of the first field.
> In routers you can use address_data to do the same thing.


Nico, after read (again) the doc, I have another doubt. At the end there
is a portion of my current config (which a took from vexim).

In the router, the mysql lookup yields only one field, so the lookup
passes it back as is.

As you can see, all queries are almost the same. But if I do a query
which yields more than one column don't know what exim will do.

I can see from the config that data is expecting a dirname, no more, no
less..., but a multi-column query gives a 'field1=value1 field2=value2
etc...' in 'data'.

Ideally I should solve it with something like this:

virtual_domains:
driver = redirect
set query_result = ${lookup mysql{select <tons_of_columns>...}
data = ${extract {dir}{$query_result}}
...

virtual_delivery:
driver = appendfile
directory = ${extract {dir}{$query_result}}
user = ${extract {user}{$query_result}}
...

But... set isn't allowed in a router. Any hint?

Regards,
mike


The router
----------
virtual_domains:
  driver = redirect
  allow_fail
  data = ${lookup mysql{select smtp from users,domains \
                where localpart = '${quote_mysql:$local_part}' \
  ...


The transport
-------------
virtual_delivery:
  driver = appendfile
  envelope_to_add
  return_path_add
  mode = 0600
  maildir_format = true
  create_directory = true
  directory = ${lookup mysql{select smtp from users,domains \
                where localpart = '${quote_mysql:$local_part}' \
                ...
  user = ${lookup mysql{select users.uid  from users,domains \
                where localpart = '${quote_mysql:$local_part}' \
                ...
  group = ${lookup mysql{select users.gid from users,domains \
                where localpart = '${quote_mysql:$local_part}' \
                ...
  quota = ${lookup mysql{select users.quota from users,domains \
                where localpart = '${quote_mysql:$local_part}' \
                ...