Re: [exim] Is there any way to get exim to display the exapn…

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: Ritchie P. Fraser
Data:  
Para: exim-users@exim.org
Temas antigos: Re: [exim] Is there any way to get exim to display the exapnded list returned from a pgsql lookup?
Asunto: Re: [exim] Is there any way to get exim to display the exapnded list returned from a pgsql lookup? {Scanned}
Hi Phil,

I don't think you were at all rude. In fact, you were consise and provided just the answer I was looking for, and I thank you :-)

I had in the mean time been playing with....
    condition     = ${lookup pgsql{SELECT name FROM maildomains WHERE name='$domain' AND status='t';}{yes}{no}}
...which, if a single match is returned from the database evaluates to true/yes and if no rows returned is evaluated to false/no.


I have since also tried out your suggestion of using match_domain

          condition     = ${if match_domain{$domain}{+our_sql_maildomains} {yes}{no}}


but get the following
$ exim -bh 192.168.0.115
...helo and mail from...
rcpt to: joeblow@???
...
>>> ourcompany.com in ": ourcompany.co.uk
>>> ourcompany.biz
>>> ourcompany.ltd.biz
>>> ourcompany.co
>>> ourcompany.com
>>> ourcompany.info
>>> ourcompany.ltd.info
>>> ourcompany.ltd.net
>>> ourcompany.org
>>> ourcompany.ltd.org
>>> ourcompany.ltd.co.uk
>>> ourcompany.me.uk
>>> ourcompany.ltd.me.uk
>>> ourcompany.org.uk
>>> ourcompany.ltd.org.uk"? no (end of list)
>>> ourcompany.com in "+our_sql_maildomains"? no (end of list)
>>> check condition = ${if match_domain{$domain}{+our_sql_maildomains} {yes}{no}}
>>>                 = no
>>> accept: condition test failed in ACL "acl_check_rcpt"


So the expansion of +our_sql_maildomains IS calling postgresql AND executing the query AND returning a list of the company domain names AND doing the comparison which is all brilliant, but for whatever reason didn't match the domain :-(

Not sure if my sql query needs a tweek to return the domain list formatted differently or add crlf on end of needle or something else.... I'm not too worried about this though as I have a working exim config with the "${lookup pgsql{SELECT...}}"

Kind Regards

Ritchie


-----Original Message-----
From: Phil Pennock [mailto:exim-users@spodhuis.org]
Sent: 11 February 2014 17:07
To: Ritchie P. Fraser; exim-users@???
Subject: Re: [exim] Is there any way to get exim to display the exapnded list returned from a pgsql lookup? {Scanned}

On 2014-02-11 at 08:52 -0800, Phil Pennock wrote:
> On 2014-02-11 at 12:16 +0000, Ritchie P. Fraser wrote:
> > Have I done something REALLY stupid like missed curly braces in the condition = statement?
> >
> >                 I have tried the following:
> >                 condition     = ${if inlist{$sender_address_domain}{+our_sql_maildomains}{false}{true}}
> >                 condition     = ${if !inlist{$sender_address_domain}{+our_sql_maildomains}{true}{false}}
> >                 condition     = ${if !inlist{$sender_address_domain}{+our_sql_maildomains}}
> >                 !condition     = ${if inlist{$sender_address_domain}{+our_sql_maildomains}{true}{false}}
> >                 !condition     = ${if inlist{$sender_address_domain}{+our_sql_maildomains}}

>
> inlist{FOO}{BAR} treats BAR as a list of simple strings; it doesn't
> take domainlists. You want match_domain instead.
>
> condition = ${if
> !match_domain{$sender_address_domain}{+our_sql_maildomains}}


Well that was rude of me, no matter how much of a hurry I was/am in.

No, that was not a stupid mistake -- this is a confusing area, with multiple related functions; inlist/inlisti were added to provide safer alternatives where the second parameter needs to be expanded but only a simple list was wanted (which is normal, when expanding a variable to provide the target list).

We could almost certainly use better documentation here; I'm far too close to the problem domain and tend to miss when the docs I write have subtleties that are not immediately obvious to someone not also familiar with the issues.

So this *is* a bug, it's a documentation bug, and suggestions for improved text, cross-referencing, etc are very welcome.

Regards,
-Phil

--
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.