Bitrix Site Manager

New rule (rule editor)

This form is used to create or edit rules for new mail messages. To create a new rule, you need to fill in the form fields and click the Save button.

Rule parameters

"Parameters" tab

Field Description
ID The ID of the rule under which the rule was saved.

The code is displayed while editing the existing rule.
Modified The date and time when the rule was last changed.

It is displayed while editing the existing rule.
Mail box The mailbox to which this rule is to be applied. You can create a new mailbox by clicking the Create link.
Act. If checked, the rule is active and can be applied to messages. If not checked, the rule does not apply.

See also the Apply to events field.
Name The name of the rule. 
Description The description of the rule. You can enter any description here.
Sorting The rule sorting value; used when displaying rules in lists.
Apply to events Types of events with which this rule should be applied:
  • When receiving a message - with this checkbox selected, the rule will be applied to every message when receiving messages from the mailbox for which the rule is created. If the checkbox is not selected, the rule will not be applied to the incoming messages;
  • When processing rule manually - if the checkbox is selected, the rule can be applied only manually. 

"Conditions" tab

Field Description
Groups of condition fields These groups of fields are used to create conditions which define whether the rule can be applied to messages or not; in other words, these fields define the preliminary filtering conditions for messages before the rule is applied. 

For more information about groups of fields, see the notes below.
Spam probability Indicates that the rule will be applied only to messages whose SPAM index satisfies this condition. 

For example, if this condition is set to "more than 90%", the rule will be applied only to the messages with the spam index is more than 90%.
Message size Indicates that the rule is to be applied only to the messages whose size satisfies this condition.
PHP condition Optional PHP script. The script is executed by the system and should return true or false.

For more information about groups of fields, see the notes below.
Settings (adding a message to technical support)
This group of settings is displayed only for rules created using the "adding message to techsupport" template
Identify registered user by e-mail If this condition is set to yes..., upon receiving a new message, the rule will try to find a registered user with the specified address in the database and assign the message to this user.

Otherwise, messages in the technical support module will be created as anonymous.
Add a new message to existing ticket This condition defines addresses messages from which can be added to an open ticket of the technical support module. 

If you select the as hidden... checkbox, only members of the technical support service will have access to the message.
Subject templates... Regular expressions applied to incoming messages. This field is intended for developers; it is not recommended to change this value.
Link a new trouble ticket to the site Specifies the site to which the newly created ticket is to be added.
Add a new ticket to a category Specifies the ticket category to which the new ticket will be linked.
New ticket emergency Allows to set the default emergency of the new ticket.

"Actions" tab

Field Description
Set read status Marks all messages processed with this rule as read.
Mark as spam Marks all messages processed with this rule as spam.
PHP script action Optional PHP script which is executed when the rule is applied to the message.
Delete message Deletes the messages to which the rule is applied.
Do not process with other rules After applying this rule to a certain message, other rules will not be applied to it, even if this message meets the appropriate rule conditions.

Notes

Groups of condition fields

The first dropdown list of the group contains text message properties used as an information source for the filter (operand).

The second dropdown list contains comparative operators that define the type of the compare operation applied to the text of the property selected in the first list at filtering. You can select the Regular expression item as a functional operator. The syntax of the regular expressions corresponds to the PCRE specification. The syntax description can be found here: http://php.net/manual/en/reference.pcre.pattern.syntax.php.

The input text field is intended for a sample text which is compared to the property text of the first list.

Example

To apply a rule to all incoming messages with the word Order in the Subject field, set the following field values:

PHP script condition

In most cases the features available are sufficient for setting the message selection conditions. However, if standard rules do not allow to implement the required message selection conditions, you can create the user-defined selection conditions. The script for these conditions should be written in the PHP programming language. When running the condition script, the validity of the message fields array $arMessageFields is guaranteed.

The conditional PHP-script should return true if the condition is implemented and can be applied to a message; otherwise, false is returned..

Example
if ($arMessageFields["FIELD_PRIORITY"] > 3 || 
    strpos($arMessageFields["FIELD_FROM"], "@bitrix") > 0)
   return true;
return false;