Quarantining Spam Messages

Use the following "quarantine spam" filter to decrease the number of spam messages directed to a recipient's mailbox. The "quarantine spam" filter is a modification to the default policy script filter found in "Policy Script 6: Calculate Spam Probability, Modify and Deliver". Unlike the default policy script filter, the "quarantine spam" filter quarantines messages when the spam probability is over 80%. (The default policy filter only "files" spam messages when the spam probability is over 50%. See the pmx_file command in the pmx-policy manpage.

# attr NAME=quarantine spam
# Quarantines spam if probability over 80%.
# Else, delivers message if probability over 50%.
# Prefixes "Subject" header with "[SPAM:]".
# Adds an "X-PMX-Spam" header.
if pmx_spam_prob :over 80 {
    pmx_quarantine "Spam";
    stop;
}
elsif pmx_spam_prob :over 50 {
    pmx_replace_header "Subject" "[SPAM:%%GAUGE%%] %%SUBJECT%%";
    pmx_add_header "X-PMX-Spam" "Probability=%%PROB%%";
}

Description:

  • If the pmx_spam_prob test finds the message has a spam probability of 80% or more:
    • The pmx_quarantine action copies the message to the PureMessage quarantine with the reason "Spam". This string should be a single word. If multiple words are used the spaces between the words are silently changed to underscores. For example, the string "message is spam" becomes "message_is_spam". Quarantined messages can be viewed, released and digested using the PureMessage Manager and the quarantine tools.
    • The stop command then ends message processing.
  • If the pmx_spam_prob test finds the message has a spam probability of 50% or more:
    • The pmx_replace_header action prefixes the "Subject" of the message with a string similar to: " [SPAM:###] ", where each additional "#" character denotes 10% above the argument to pmx_spam_prob (at least one '#' is always appended, indicating that the message contains 0-50% spam).
    • The pmx_add_header action then adds an "X-PMX-Spam" header to indicate the message's complete spam probability.

Where does this filter go?

The "quarantine spam" filter replaces the filter found in "Policy Script 6: Calculate Spam Probability, Modify and Deliver". Replacing this default policy filter with the "quarantine spam" filter ensures that:

  • The "quarantine spam" filter executes when messages from external hosts have spam probabilities of either over 80% or over 50%.
  • Messages with a spam probability of 80% or more are quarantined.
  • Messages are delivered, with additional headers, to envelope recipients if the spam probability is between 50% and 79%.