Re: [Exim] Exim & MySQL

Góra strony
Delete this message
Reply to this message
Autor: William Thompson
Data:  
Dla: Philip Hazel
CC: exim-users
Temat: Re: [Exim] Exim & MySQL
> > It would be nice to have the ability to simply put all data from a lookup
> > like that and check each line. I thought that's how it'd work, but when I
> > RTFM, I noticed it was only going to return true/false which in my case when
> > I was testing, it was always true (because of the sql condition).
> >
> > If something like that's possible, I'd like to wishlist it.
>
> Sorry, I'm not exactly clear what you are asking for here. I'm probably
> missing some vital point. At present you have two choices for the way
> you use lookups in a list:
>
> 1. Have the lookup return a list, which is then searched. The syntax is:
>
>     hosts = ${lookup mysql ..... }

>
> 2.  Use the lookup as a way of indexing into a list of permitted hosts/
>     domains/whatever. The syntax ix:

>
>     hosts = mysql;...

>
> You can even use both of these in the same item:
>
>     hosts = mysql;... : ${lookup mysql ....}

>
> Clearly, you are asking for a third facility, but I'm not sure what it
> is. Please point out to me what I am missing here!


If I do: hosts = ${lookup mysql ..... }
and the query returns multiple hosts, I'd have this after expansion:
hosts = 127.0.0.1\n
192.168.1.1\n
192.168.1.2

replacing \n with a NL.

Exim will check to see if host (say 127.0.0.1) is in the string
"127.0.0.1\n192.168.1.1\n192.168.1.2" which it isn't because it's not a
list.

I have this right now.
domainlist local_domains = localhost : \
        /etc/exim4/localdomains : \
        ${lookup mysql{select domain \
                        from eximconf.localdomains \
                        where enabled='yes' \
                      } \
                 {${sg{$value}{\N\ *\n\N}{ : }}} \
         }


If I change to:
domainlist local_domains = localhost : \
        /etc/exim4/localdomains : \
        ${lookup mysql{select domain \
                        from eximconf.localdomains \
                        where enabled='yes' \
                      } \
                 {$value} \
         }


it would expand to:
domainlist local_domains = localhost : \
    /etc/exim4/localdomains : \
    electro-mechanical.com\nfederalpacific.com\nfptonline.com\nlinepower.com\nmetalcastingsco.com\nthereserveatleonardfarms.com


Does this make anymore sense?