Adding a Header

It is sometimes useful to add a header to all messages. For example, you may want to add a header in order to track messages. This snippet adds an X-Seen-By header to all messages. It contains the following code:

pmx_add_header "X-Seen-By" "%%HOSTNAME%%";

The pmx_add_header action adds an X-Seen-By header. The value of the header is the hostname of the PureMessage machine (for example,

The %%HOSTNAME%% token is called a "template variable". For a list of supported template variables, see the pmx-policy man page.

Unlike the other default snippets in the Policy Repository, this snippet must be modified to suit its specific purpose. Occasionally, a site may require that certain messages be automatically sent to a specified address. For example, all messages containing the keyword "bug" might be sent to a bug-tracking system.

This example snippet adds a new recipient ( if (a) the Subject has "bug" in it, (b) a recipient is "", or (c) the header X-Bug-Id exists.

if anyof (header :matches "Subject" "*bug*", envelope "to"
            "", header :matches "X-Bug-Id" "*") { pmx_add_recipient
            ""; }

The anyof test is a "meta-test"; it returns true if any of the tests return true.

The header test returns true if the Subject matches "*bug*". The envelope test returns true if any of the message's "to" recipients match "". Neither of these tests is case sensitive.

The second header test returns true if the X-Bug-Id header matches anything at all. If the X-Bug-Id header exists, this will return true. If any of the tests return true, then pmx_add_recipient causes the message to be delivered to "", in addition to the original recipients.