On 2009-09-01 at 12:29 +0200, Pascal Bourdais wrote:
> exim -bem /tmp/test.eml '${if
>    and {
>       { ${lookup ldap 
> {ldap:///ou=cer5372,dc=infagri,dc=laval?mail?sub?([email protected])}{true}{false}
>  } }
>       { ! def:h_X-From71:}
>    }
> {true}{false}
> }'
> Return-path taken from "Return-path:" header line
> Failed: condition name expected, but found "${lookup ldap {l" inside 
> "and{...}" condition

Okay, this at least has the right number of braces.

${lookup ...} returns a string.  A string is not a condition value.
Confusingly, the "condition = XYZ" rule interprets a string to make a
boolean condition value, but ${if XYZ} does not.  XYZ here, or inside
the branches of and{{cond1}{cond2}} must be something that "is" a true
false value.

If you wrap something which returns strings "true"/"false" in an eq{}{}
test for comparing to the string "true", you'll get a boolean value.

This is one of the most confusing points of Exim and keeps tripping
people up.  I missed it in the first skim over your mail because I
focused on the obvious syntax error of too many braces.

${if and{\
  {eq{${lookup ldap {LDAP_QUERY}{true}{false}}}{true}}\
  {!def:h_X-From71:}\
  }}

where LDAP_QUERY is:
  ldap:///ou=cer5372,dc=infagri,dc=laval?mail?sub?([email protected])

-Phil

-- 
## List details at http://lists.exim.org/mailman/listinfo/exim-users 
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

Reply via email to