1.14  Message filtering

1.14.1  List of filtering rules
1.14.2  Creating or changing a rule
1.14.3  Cellular phone notification

When a message is delivered to a local user of Kerio Connect, it is stored in the INBOX folder. In Kerio WebMail, each user can define a set of actions to be performed on all new incoming messages, as well as their conditions. These actions are called filters and are specified through filtering rules. Filtering does not mean merely refusing email messages or sorting them to folders, but it includes other actions such as notifications to cellular telephones, automatic replies, forwarding the message to a different email address, etc.

1.14.1  List of filtering rules

Define filtering rules in the Mail filters section. To open this section, click the Settings button in the toolbar.

Settings Menu

Figure 1.101. Settings Menu


A list of defined filtering rules is displayed. Each message is checked against this list of rules (from top to bottom). If the message complies with any of the rules, a corresponding action defined for this rule is performed. If the message complies with more than one rule, all previously defined corresponding actions are performed (unless provided otherwise).

Instead in the Filters dialog box, the Spam and Out of office rules can be set in Settings → Settings → Spam (see chapter 1.13.1  User Settings). In the list, the rules can be viewed, not edited.

Rule list

Figure 1.102. Rule list


A check box next to each rule determines if the rule is active or not. The rule can be disabled temporarily without the need to delete it and create again.

Use the list buttons to perform the following:

New

This option creates a new rule.

Modify

Use this option to change (edit) the selected rule.

Delete

This option removes the selected rule.

Edit script

This option is used for editing the script (the filter source code). Filtering rules are created in the Sieve standard language. This means that the dialog window displayed after clicking on the New or Edit button is a graphic interface for the rules. The graphic dialog window enables setting of all conditions and functions offered by Kerio Connect. Therefore, it is recommend that only users who are familiar with the Sieve language and do not wish to use the graphic interface use the Edit function.

Move up, Move down

Move the rules up or down. All rules are processed from top to bottom and should be sorted from the most specific to the most general ones. A rule can also stop processing of other rules (i.e. no more rules are processed, even though the message would comply with some of them). In such cases, consider carefully where the rule should be inserted.

Note

The Spam rule is special and cannot be moved by the Up and Down buttons. The highest priority is set for the rule.

Save and close

This button saves all changes to the rule. This must be done every time you make changes to the rules (including their activation or deactivation using the checkbox) or all changes will be lost. If changes have not been saved, a warning message will be displayed under the rules list (Your changes are not saved).

After the rules are set, save the action with the Save and close button.

1.14.2  Creating or changing a rule

Click the New or Modify buttons to open a dialog window where you can define a rule. This window is divided into four parts:

  1. Condition (that the message must meet)

  2. Action (that will be performed)

  3. Rule description (a text description that allows modification of some details)

  4. Name of the rule (a name that will be displayed in the rule list)

Conditions

The rule will be used if the selected conditions are met. The logical relationships and (i.e. all conditions must be met) / or (at least one of the conditions must be met) can be used in conditions. Selected conditions are displayed in the third section of the dialog window where you can specify the requested values and change the type of logical conjunction.

Example: Create the following condition: If the sender's address is admin@ourcompany.com or the message subject contains the word Warning.

Rule Description

Figure 1.103. Rule Description


  1. Select the Where the From address is condition.

  2. In the third section, click the Contains link — this will open another dialog window where you can specify the address. Enter admin@ourcompany.com.

  3. Select the Where the subject contains the words condition.

  4. Upon clicking, the and conjunction will be changed to or

  5. Click on the contains link to specify Warning (the entry is not case-sensitive).

When specifying required content for a certain entry, several different strings can be defined — the condition will only be met if the entry contains at least one of them (or relation).

The condition for the occurrence of a certain string in a given entry can be more general. Click the Options... button to specify its occurrence in the entry:

is

The entry must exactly match with the specification.

is not

The entry must not match with the specification.

contains

The entry must contain the (sub)string.

does not contain

The entry must not contain the specified (sub)string.

matches

The entry must match the expression (the expression can contain the ? and * wildcards that can represent one or more characters).

Examples:

  • ?atch — matches batch, match, patch, catch, latch, hatch, ratch, natch and watch.

  • *each — matches each, beach, preach, peach, reach, leach, teach, bleach and other words.

  • [bmp]atch — matches batch, match and patch, but notcatch, latch, hatch, ratch, natch or watch.

    Note

    If you need to find a string which includes square brackets, use ? or* wildcard in the matches entry instead of them

does not match

The entry must not match the expression.

The default value is contains.

The following conditions are possible:

Where the recipient's address (To or Cc line) is

The specified string must be included in the To or Cc line.

Where the sender's address (From) is

The specified string must be included in the From entry.

Where the To address is

The specified string must be included in the To address.

Where the Cc address is

The specified string must be included in the Cc address.

Where the Sender address is

The specified string must be included in the Sender address. This item can be usually found in automatically generated messages (email conferences etc.) where it replaces the To field.

Where the subject contains words

The specified string must be included in the Subject entry.

Kerio Connect spam filter can be set so that the Subject entry will include results of antispam tests (the value is represented by asterisks). Using this feature spam may be filtered easily. Simply insert the number of asterisks that will specify the rule. Messages that match this rule will accept this specification.

Where the message has an attachment

At least one attachment must be appended to the message.

Where the message size is more than

The message size exceeds the specified value. To specify the size you can select from the following units: bytes (B), kilobytes (KB) and megabytes (MB).

Where the message was detected as a spam

Spam are undesirable messages sent to users. You can use the Kerio Connect antispam filter to protect your users from such messages. This filter uses special header items which include message evaluation and information about applied antispam testing.

For all messages

This rule is valid for all incoming messages.

Action to be performed

In the second section of the dialog window, you can choose one or more actions that will be performed if the condition in section 1 is met:

Move the message to a specified folder

Move the message to the selected folder (you can choose a folder from a list).

Forward the message to an address

Forward to a specified address. In this case no other actions are performed.

Reject message (return to sender)

The message will not be stored in a local mailbox and the user will never be informed about it.

Keep in INBOX

This action must be combined with another (i.e. with Move, Forward, Reject, etc.). It cannot be combined with the Discard the message action.

Discard the message

The message will not be stored in any local folder. This action cannot be combined with the Keep in INBOX action.

Send notification

Sends notification (i.e. a short text message) to a specified address, typically to a cellular phone. For a cellular phone you must enter the whole email address, not just the telephone number (e.g. . For details, see the following sections).

The following macros can be used in the message text:

  • $from$ — the notification contains the message sender (the address in the From field).

  • $from-name$ — the notification will show the name of the message sender.

  • $subject$ — the notification will show the message subject.

  • $text$ — the notification will show the message text. Only the first 128 characters will be displayed. To change the count of characters, the macro can be written as follows:

    $text[50]$

    The number in parentheses represents the maximum number of characters displayed in the text box.

Send autoreply

The automatic reply with a specified text. The automatic reply will be sent to each sender's address only once a week (so that the automatic reply does not create a loop in case there is an automatic reply set at the other end).

Stop processing more rules

If the message complies with this rule, no more rules will be processed. This function allows users to create more complex rule sequences for different condition types. Always be careful about the order of the conditions (the rules are processed from top to bottom).

Note

Notifications and autoreplies are protected from loops. This means that the system does not send a notification in reply to received notification or automatic replies. The detection of notification or automatic replies is performed using special items in the message header. Only notifications and automatic replies generated by Kerio Connect are detected.

Rule description

In the third section of the dialog box, the user can review a summary of the created rule. Optional values are formatted as links and can be changed repeatedly. The conditions and actions can be easily removed or added by activation or deactivation.

Name of the rule

Give the created rule a unique name (may be multiple words) that best describes the rule. Naming the rules Rule 1, Rule 2, etc. is not very helpful.

1.14.3  Cellular phone notification

When setting up the notification , a format of the message can be specified. In the notification text, special character sequences can be used which will be replaced by the corresponding parts of the original message.

$subject$

Subject of the message

$from$

Sender address (From field)

$env-from$

SMTP envelope From address

$text$

First 128 characters of the text (message body)

$text[N]$

First N characters of a message body (N is an integer). The part of the message that will be sent to a cellular phone is determined by the SMS gateway (usually up to one SMS message).

The notification text can have the following form:

Message from $from$, subject: $subject$. Message body: $text$