Compound Tests, allof and anyof

Some tests in the PureMessage policy script are used as logical operators. These tests are called compound tests as they take other tests as arguments. Use the allof or anyof commands to build a compound test. The allof command functions as logical AND. (All compound tests in the allof list must be “true” for the corresponding actions in a block to execute.) The anyof command functions as a logical OR. (Only one of the compound tests in the anyof list needs to be “true” for the actions in the block to execute).

In the policy script, the allof and anyof commands take a test and a list as arguments. To build a compound test, group individual tests and associated arguments in parentheses before the beginning of a block statement. Each compound test in the list must be separated with a single comma “,” to delimit the end of each test.

Generic Example:
if anyof (test :match_type "list", test :match_type "list") {

In this example, the anyof command takes two tests. Each test takes a match-type with a list argument. The compound test is enclosed in parentheses. Each test is separated with a comma character.

Policy Script Example:
if anyof (host :memberof "whitelisted-hosts",
          sender :memberof "whitelisted-senders") {

This policy filter evaluates both the host and sender for membership on a PureMessage “whitelist”. If either the host or sender are found on a “whitelist”, the message is delivered to all envelope recipients. The script then halts with the stop command.