Example: Run Per-Recipient Tests

About this task

Create a rule that causes PureMessage to perform different actions, depending on the recipient of the message. When such a rule is applied, PureMessage splits a message addressed to multiple recipients into copies and operates on the copies independently. This makes it possible to specify different actions for the individual recipients of messages addressed to multiple recipients.

Per-recipient rules are created using Envelope from and Envelope to tests. In this example, you will create a rule that adds a banner to messages addressed to the customer service representatives of company "XYZ".

To Run Per-Recipient Tests using the PureMessage Manager:

Follow these steps

  1. Click Create beside Backups on the Policy tab sidebar. A backup of the current policy is created, and the current date and time are displayed in the Backups section of the sidebar.
  2. Click Policy Rules on the Policy tab sidebar to display the current policy.
  3. Click the Mail from external hosts rule.
  4. Click add rule (beside Execute actions and rules. This creates a new rule.
    1. Configure the Test:
      1. Change the (New Rule) text to Add banner for selected recipients only.
      2. From the Tests drop-down list, select Envelope to.
      3. From the second drop-down list, select Is.
      4. In the adjacent text box, enter:
        "kurt@service.xyz.com", "kris@service.xyz.com", "dave@service.xyz.com"
    2. Configure the Action:
      1. In the Execute actions and rules drop-down list, select Add banner.
      2. Click the Arguments button to the right of the drop-down list.
      3. Select the Append banner to message body check box.
      4. Select Verbatim from the Data_type drop-down list.
      5. In the File or string text box, enter: ATTENTION
      6. Click OK.
      7. Click Save.
    3. Change the Rule Order:
      1. Click Cut. A message is displayed at the top of the page indicating that the "Add banner for selected recipients only" rule has been cut.
      2. Click the rule Clean mail containing viruses.
      3. Click Paste. The "Add banner for selected recipients only" rule is displayed in its new position beneath the "Clean mail containing viruses" rule.


    4. Click the Commit link to update the live policy script. PureMessage displays a message advising that the milter is running with a stale configuration. Do not restart the milter.
  5. Test New Policy: The milter uses the original policy until the service is restarted. However, the new policy can be tested without making it "live".
    1. Click Test Current Policy on the Policy tab sidebar. The Test Current Policy page is displayed.
    2. From the Select Relay Type drop-down list, select External.
    3. In the Envelope From text box, enter:
      customer@example.com
    4. In the Envelope To text box, enter:
      kurt@service.xyz.com, jane@sales.xyz.com
    5. Accept the sample text that is displayed by default in the message source text box.
    6. Click Test. The test runs and the results are displayed. Note that the Delivery Action for each of the two resulting messages is "keep".
    7. Click the number of the first message in the Resulting Message column. Notice that the banner text (ATTENTION) appears beneath the message body text.
    8. In the Message Preview window, click the Quarantine Info tab. Notice that the Envelope From and Envelope To details are displayed in the Quarantine Info table.
    9. Click the number of the second message in the Resulting Message column to view details of the message for which a banner was not added.
  6. If satisfied with the new policy, click Restart now to restart the milter and make the new policy live. To restore the original policy, click the backup link, and select OK.

What to do next

Policy Script

To run per-recipient tests by manually editing the policy script:

# attr NAME=Mail from external hosts
else {
    pmx_add_header "X-PMX-Version" "%%PMX_VERSION%%";
    pmx_mark "Size" "%%MESSAGE_SIZE%%";
    # attr NAME=Clean mail containing viruses
    if pmx_virus {
        pmx_file "Virus";
        pmx_virus_clean "cantclean.tmpl";
        pmx_replace_header "Subject" "[PMX:VIRUS] %%SUBJECT%%";
        pmx_replace_header "X-PerlMx-Virus-Detected" "%%VIRUS_IDS%%";
    }
    # attr NAME=Add banner for selected recipients only
    if envelope :comparator "i;ascii-casemap" :all :is ["to"] ["kurt@service.xyz.com",
                                                               "kris@service.xyz.com",
                                                               "dave@service.xyz.com"]
    {
        pmx_add_banner :body :data "ATTENTION";
        keep;
    }
}

See the Policy Script Tutorial for more information about modifying the policy script from the command line.