Adding a Recipient

Occasionally, a site may require certain messages to be automatically sent to a known address. For example, all messages containing the keyword “bug” might be sent to an bug tracking system. This policy adds a new recipient to a message ( when the “Subject” header has the string “bug” in it, the recipient is “”, or the header “X-Bug-Id” exists.

# attr NAME=add a recipient
# Adds a "" recipient to the envelope.
if anyof (header :matches "Subject" "*bug*",
         envelope "to" "",
         header :matches "X-Bug-Id" "*") {
    pmx_add_recipient "";


  • The first command is an if anyof statement comprised of three compound tests. The header test returns “true” if the “Subject” header matches the string “bug”. The envelope test returns “true” if anyof the message’s recipient “To” headers match the string “”. The second header test returns “true” if the “X-Bug-Id” header matches itself. If any of these three tests return “true”:
    • The pmx_add_recipient command delivers the message to The message is also delivered to all original envelope recipients.

Where does this filter go?

The “add a recipient” filter should be placed before the filter in “Policy Script 1: Scan and Deliver Internal Messages” and directly after the pmx_test_mark action. Positioning the “add a recipient” filter at this point ensures that:

  • The “add a recipient” filter always executes. (A stop command from another filter will not prevent it from executing.)
  • Subsequent spam and virus filters will always execute. (The “add recipient” filter does not contain a stop command that would otherwise end the policy script before spam and virus filters execute.)