Example: Check Messages for Offensive Words

Rules can be configured to implement policies that reduce liability from inappropriate communications. The following rule checks messages originating from internal sources against a defined list of offensive words, and it quarantines any messages found to contain those words. (Note that this example assumes that you are using the default PureMessage Policy configuration.)

The Offensive Words list is pre-configured with several hundred words and phrases that are generally considered to be unacceptable in corporate communications. Before creating a rule that uses the Offensive Words list, review the contents of the list, adding words and phrases specific to your organization and removing words and phrases that are not applicable.

The following test uses the Message contains word or phrase test, which is part of the PureMessage Policy bundle. If you do not have a license for the Policy bundle, use the Message has offensive content test, which also uses the Offensive Words list, and which is included with the Anti-Spam license.

To create a "check messages for offensive words" rule using the PureMessage Manager:

  1. Click the Create link beside the Backups text on the sidebar of the Policy tab.

    A backup of the current policy is created; a backup entry with the current date and time is displayed in the Backups section of the sidebar.

  2. PureMessage includes a pre-configured list of offensive words and phrases. To view the contents of this list, click Offensive Words in the Lists section of the Policy tab sidebar.
  3. Click Policy Rules on the sidebar of the Policy tab to display the current policy.
  4. Click the Mail from internal hosts rule.
  5. Click the add rule link (beside Execute actions and rules). This creates a new rule at the bottom of the Internal Hosts section of the PureMessage Policy.
    1. Configure the Test:
      1. Change the (New Rule) text to Check for Offensive Words.
      2. From the Tests drop-down list, select Message contains word or phrase. Select Is a member of as the operator and Offensive Words from the available lists.
    2. Configure the Action:
      1. Click add action. This creates the action configuration template.
      2. In the new Execute actions and rules drop-down list, select Quarantine the message.
      3. In the text box to the right (Quarantine Reason), enter Offensive Word.
      4. In the second rules drop-down list, select Stop processing.
    3. Click Save.
    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.

  6. Test New Policy: Because the milter has not been restarted, it is still using the original policy. Therefore, the new policy can be tested without making it "live".
    1. Click Test Current Policy on the sidebar of the Policy tab.
    2. Enter adult site in the message source text box. (The default relay type is Internal, which is as desired.)
    3. Click Test. The test runs and the test results are displayed. Note that the Delivery Actions for the test message is quarantine: Offensive Word.
  7. 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.

Policy Script

To create a check messages for offensive words rule by editing the policy script:

if pmx_virus {
    # attr NAME=Allow unscannable messages to pass through
    if pmx_virus_cantscan {
    reject "One or more viruses were detected in the message.";
# attr NAME=Check for Offensive Words
elsif pmx_phrase :memberof ["offensive-words"] {
    pmx_quarantine "Offensive Word";

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