How to Filter Messages Based on Their Body Text

This article describes how you can filter messages based on their body text and optionally replace the words.

Solution

In this article we shall provide the steps in creating a rule, at the server level (filters all messages), which searches for a text string in the body of the message and takes an action if a match is found.

In order to create such a rule please take the following actions:
1. Via the Webadmin interface navigate to Security&Filtering -> Incoming Message Rules -> click on "Add Message Rule"
2. Type a name for this rule
3. In the Conditions area select "Body" - "Contains" - and type the text string to match
4. In the Actions area select the action you wish to be taken when the message matches the condition previously defined.

5. Optional you can replace some specific words  found in the subject or body, using "bodyreplacewords"' command. For this you will have to manually edit the wasieve-server.sieve file located under the "<Axigen working directory>/filters" folder:
  a) on the first line add "bodyreplacewords" as required. The line should look similar to the one bellow:
require ["fileinto", "envelope", "copy", "forward", "vacation", "tagsubject", "body", "bodyreplacewords"];
  b) find the section corresponding to the previously defined rule. It should begin with a line describing it:
##Filter id=x name="name of the rule previously created" enabled=1
You should quickly identify the section corresponding to the Actions commands. Add the following line before any action command:
bodyreplacewords ["word1","word2" ] "replacing word"
When one of those two words are encountered in the subject and body of the message they will be replaced with "replacing word" (without the quotes).
OS: LinuxWindowsFreeBSDNetBSDOpenBSDSolaris