|
|
Setting Up Delivery Rules
You can use delivery rules to direct incoming and outgoing mail to particular mailboxes based on the contents of the To, From, Sender, Subject, Header or Body fields of the message. Delivery rules can be applied at three levels:
- Mail host (Inbound and Outbound rules)
- List-server mailing list (Inbound rules)
- Individual users (Inbound rules)
Inbound delivery rules can be used in conjunction with the Info Manager to screen for a particular phrase, and then (if the phrase is found) send an automatic response and forward the mail to someone for follow-up.
Some circumstances in which delivery rules are useful are:
- An inbound delivery rule for a host. A school administrator can set up a delivery rule that scans all mail for offensive language and delivers such messages to a special user account that can be reviewed by a faculty member.
- An outbound delivery rule for a host. A school administrator can set up an outbound delivery rule that will scan for offensive language or content in mail messages that are being sent out through IMail Server by local users.
- An inbound delivery rule for a list-server mailing list. A system administrator can set up a delivery rule for a list-server mailing list to scan the body of all messages addressed to the list for language that indicates that the mail came from a spammer or bulk mailer, and ignore any such messages. For example, the rule can search for one of these text strings:
- to be removed from any future mailings
- please respond with the word "remove" in the subject line
- advertise with bulk email
- bulk friendly
- An inbound delivery rule for an individual user. You could set up a rule for a sporting goods salesman to have all messages with baseball, softball, bat, base, homerun, or cap in the Subject automatically placed in his mailbox named baseball.
- An inbound delivery rule combined with the Info Manager. You could set up a delivery rule to forward all mail containing the phrase "send info" to a particular mailbox named Requests in a user account named Sales. Then, you could set up the Info Manager to send out a generic response and also forward the mail to your company's Sales Manager. (For more information about the Info Manager, see "Using the Info Manager".)
- An Inbound Delivery Rule to Bounce Spam Messages. If you want to send all spam messages back to the sender, you need to set up delivery rule that searches for messages with a spam X-Header (X-IMAIL-SPAM:) in the header and then select Bounce. For more information, see "Using Delivery Rules to Filter Spam".
Rules Processing
IMail Server stores delivery rules in text files named rules.ima (inbound rules) and orules.ima (outbound rules). Since inbound rules can be created by mail hosts, users and list-server mailing lists, there can be multiple rules.ima files on your IMail Server system. If an inbound delivery rule applies for a mail host, the rules.ima file is located in the mail host's directory. If an inbound delivery rule applies for a user, the rules.ima file is located in the user's directory. If an inbound delivery rule applies for a mailing list, the rules.ima file is located in the list's directory. For information on the order in which rules files are processed, see "Processing Order".
Since only mail hosts can create outbound rules, the orules.ima file is located in the mail host's directory. You may have multiple orules.ima files on your IMail Server system, one for each host.
IMail Server reads the rules.ima and the orules.ima files during the delivery process. The rule files for the host are evaluated first, and then the rules for users and lists. Any rules.ima or orules.ima file can be copied to other directories. For example, if you create inbound delivery rules for one host, you can copy the rules.ima file to the directories of other hosts to apply the same rules to them.
Delivery rules created by the system administrator for an individual user affect only mail sent to the user's Main mailbox. Users can use IMail Web Messaging to create their own delivery rules by selecting Change Processing Rules from Personal Account Options in Web Messaging. Rules created by a system administrator for a domain will take precedence over rules for a particular user, as described in "Processing Order".
Creating an Inbound Delivery Rule
Inbound delivery rules, are used to sort incoming mail messages for mail hosts, users, and mailing lists. The following procedure describes the creation of an inbound delivery rule for a host. Note that this procedure is the same for mail hosts, users and lists.
- In the left panel, do one of the following:
- To create a delivery rule for a mail host, select the host.
- To create a delivery rule for a user, expand a host and the Users folder, and then select a user.
- To create a delivery rule for a list-server mailing list, expand a host and the Lists folder, and then select a list.
- In the right panel, click the Inbound Rules tab, and click Add. The Rules dialog box appears as shown below.
![]()
- From the Select Rule list box, select the rule that you want to create (From, To, Subject, Sender, Body Text, Header Text).
- Select contains to have the delivery rule look for messages that contain the search text. Select does not contain to look for messages that do not contain the search text
- To enter search text, either enter the text in the Search Text box as described below, or specify an external file that contains the search text you want to use.
Enter the search text by doing one or more of the following:
- Enter the literal text that you want to search for. For example, if you want to find the word jazz, enter: jazz.
- Enter search expressions and quantifiers as shown in Text Patterns.
- Use the popup menu to insert a generic form of a search expression and then edit the inserted expression.
- Paste a portion of a mail message that meets your search criteria. For example, you could copy and paste text such as "XMSMailPriority(High)" from the header of a message; this would search for High priority messages.
- Select External File, if you have placed the search text in an external file. The list box displays the existing external files.
- Select Match Case to search for text that matches the case of the search text. To ignore case, clear Match Case.
- Click Add Condition. The condition that you just created is added to the rule and appears under Final Rule. If this is the only condition you want the rule to have, click OK and you will return to the Inbound Rules tab (shown below). If you want to add multiple conditions, read "Adding Multiple Conditions to Rules".
![]()
- A placeholder is placed in the Active Rules list just under the selected slot (if any). The rule is temporarily named New Rule. The default mailbox is Main.
- You cannot name delivery rules, because they are identified in the Active Rules list only by their sequence in the list. To identify a delivery rule, highlight one of the rules (e.g., rule1, rule2) and read its contents in the search text box.
- From the Active Rules text box on the Inbound Rules tab, select the rule you just created. The rule's syntax appears in the lower textbox. Now specify what will be done with messages meeting the rule criteria by choosing one of the following actions:
- Send the message to a mailbox. Select Move to mailbox, and in the Addresses box, enter the name of the mailbox to which messages meeting the rule criteria will be sent. If you enter a mailbox that does not exist, one will be created for the user. A POP3 user will see this mailbox only if he logs on to this mailbox using the format userid-mailbox. By default, if nothing is entered in the textbox, messages meeting the rule criteria will be sent to the user's Main mailbox.
- Send the message to an address. Select Forward. Then, in the Addresses text box, enter the email address to which messages meeting the rule criteria will be sent. You must enter the full email address, such as Fred@domain1.com.
- Delete the Message. Select Delete to delete the message.
When the screen is refreshed, the delivery rule, previously identified as New Rule, will appear in the format Rule# to identify its sequence in the Active Rules list. Any existing delivery rules are renamed to reflect the new sequence.
Creating an Outbound Delivery Rule for a Host
Outbound delivery rules, are used to sort outgoing mail messages that are initiated by local users. Outbound delivery rules can only be created and applied at the host level. The following procedure describes the creation of an outbound delivery rule.
- In the left panel, select the host. In the right panel, select the Outbound Rules tab, and click Add. The Rules dialog box appears.
![]()
- From the Select Rule list box, select the area of the message that you want to search (From, To, Subject, Sender, Body Text, Header Text).
- Select contains to have the delivery rule look for messages that contain the search text. Select does not contain to look for messages that do not contain the search text.
- To enter search text, either enter the text into the Search Text box as described below, or specify an external file that contains the search text you want to use.
Enter the search text by doing one or more of the following:
- Enter the literal text that you want to search for. For example, if you want to find the word jazz, enter: jazz.
- Enter search expressions and quantifiers as shown in Text Patterns.
- Use the popup menu to insert a generic form of a search expression and then edit the inserted expression.
- Paste a portion of a mail message that meets your search criteria.
- For example, you could copy and paste text such as "XMSMailPriority(High)" from the header of a message; this would search for high priority messages.
- Select External File, if you have placed the search text in an external file. The list box displays the existing external files.
- Select Match Case to search for text that matches the case of the search text. To ignore case, clear Match Case.
- Click Add Condition. The condition that you just created is added to the rule and appears under Final Rule. If this is the only condition you want the rule to have, click OK and you will return to the Outbound Rules tab (shown below). If you want to add multiple conditions, read "Adding Multiple Conditions to Rules".
![]()
- A placeholder is placed in the Active Rules list just under the selected slot (if any). The rule is temporarily named New Rule.
- You cannot name delivery rules, because they are identified in the Active Rules list only by their sequence in the list. To identify a delivery rule, highlight one of the rules (e.g., rule1, rule2) and read its contents in the search text box.
- In the Active Rules text box on the Outbound Rules tab, select the rule you created. In the lower section of the Outbound Rules tab, select the action you want to occur when a message is caught by the rule. You can choose only one of the following actions:
- Send. Processes the message as normal by sending it to the addressee.
- Send with Copy to. Processes the message as normal by sending it to the addressee, and sends a copy to the address entered in the Addresses text box.
- Delete. Deletes the message.
- Redirect to. Does not send the message to the addressee. Instead, the message is sent to the address that is entered in the Address text box.
- Bounce. Bounces the message back to the sender, without delivering it.
Note: If you choose either Send with Copy to or Redirect to, you must also enter an address in the Address text box. - Click Apply to save your changes.
Adding Multiple Conditions to Rules
Sometimes, a rule with only one condition is adequate to fulfill your requirements. However, there are times when you may want to create more complex rules, in these cases, you may want to use multiple conditions. Multiple conditions can be created for both inbound and outbound rules. By using multiple conditions, you can combine multiple rules into one.
If you want all emails from your supervisor containing text about "project updates" to be sent to a specific mailbox in your account, you would set a rule with two conditions: 1) the message must be from your supervisor; and 2) the message must contain the words "project updates" in the subject or message body of the email.
To add a rule with multiple conditions:
- Follow the steps for creating an inbound rule as described earlier in this chapter. Then, while on the rules dialog, create the first condition for the rule and click Add Condition.
- Click either Insert AND or Insert OR. Click Insert AND to state that all the rule conditions must be met in order for the message to be trapped. Click Insert OR to state that at least one of the conditions must be met in order for the message to be trapped.
- Create the second condition as you did the first, then click OK.
- Continue adding conditions until you are satisfied with the rule, and then click OK.
- When you return to the Inbound or Outbound Rules tab, do one of the following:
- If you created an inbound rule and are on the Inbound Rules tab, enter a mailbox or address that you want the rule to be sent to if it is trapped. For more information, see "Creating an Inbound Delivery Rule".
- If you created an outbound rule and are on the Outbound Rules tab, select one of the rule actions listed on this tab. For more information, see "Creating an Outbound Delivery Rule for a Host".
- When you are finished, click Apply to save your changes.
Processing Order for Conditions
Conditions are processed in the order that they appear from top to bottom as boolean expressions. To change the processing order of a condition, select it in the Rules dialog box, and click Up or Down.
Order of Rules
Delivery rules are processed from the top down until a match is found. Therefore, you should sequence the rules in the order in which you want them processed. To move a delivery rule up or down in the list, select it from the Active Rules text box on the Inbound or Outbound Rules tab, and click the Move up or Move down buttons. For information on processing order, see "Processing Order".
Testing a Delivery Rule
- On the Inbound or Outbound Rules tab, select a rule in the Active Rules text box, and click Test. Observe that the Rule Tester dialog box appears.
- In the Test Text box, enter a message that meets your intended search criteria.
- Click Test.
- If the delivery rule does what you set it to do, TRUE appears in the Test Result box.
- If the delivery rule does not test true, FALSE appears in the Test Result box. Edit the rule and test again. For a long or complex rule, we suggest you test one part of the rule at a time.
- Click OK to save the rule.
Note: You cannot edit the rule from the Rule Tester dialog box. To edit the rule, you must return to the Inbound or Outbound Rules tab, select the rule and click Edit. Rule Syntax
When you create a delivery rule, the rule is entered into a file named either rules.ima (inbound rules) or orules.ima (outbound rules) in the following format:
message_area condition search_text quantifier: mailbox_name
message_area condition search_text quantifier !AND!/ !OR! message_area condition search_text quantifier: mailbox_name
Note that search_text can be any combination of literal text and the text patterns.
For example, a rule with a single condition that looks like this on the Inbound Rules dialog box:
![]()
... searches the message body for the words word1 or word2 or word3; if at least one of the words is found, the message will be delivered to the words123 mailbox.
The above rule looks like this in the rules.ima file:
![]()
Example 2: A rule with multiple conditions that looks like this on the Inbound Rules dialog box:
![]()
... searches both the subject of the message and the message body for the words Lose Weight Quick. If those three words are found in either location, the message will be deleted.
The above rule looks like this in the rules.ima file:
![]()
The expressions for each element of a delivery rule are shown in the following tables.
Message Areas Expression From: F Subject: S Sender: N To: T entire header (everything preceding the body) H entire body of message B
Condition Expression contains ~ does not contain !~ equals = does not equal !=
Quantifier Expression Zero or more * One or more + Exactly 100 {100} At least n1, but not more than n2 (where n1 and n2 are numbers) {n1,n2}
Determining Which Rule Trapped a Message
When a message is trapped by a rule, an X-Header is placed in the message, to identify which rule caught the message. If multiple rules trap a message, only the first rule will be placed in the X-Header. The X-Header also contains up to 30 characters of the message data that caused the message to be trapped. Message data will not be included, when a message is trapped by a negative rule (does not contain or does not equal). The maximum length of any rule X-Header is 250 characters.
If a host rule traps the message, the X-Header is added to all local deliveries. If a message is trapped by a user's rule, the X-Header is only added to deliveries to the user. When a message destined for local delivery is trapped by an outbound rule, a line with the rule causing the trap will be written to the Queue file. When this message is delivered, and that line exists in the Queue file, it will be written as an X-Header in the message. Outbound messages that are not delivered locally, will not have an X-Header. The format of this rule X-Header is:
X-IMAIL-RULE:rule- message data that matched the rule
![]()
Disabling the X-IMail-Rule Header. If you want to disable the X-IMail-Rule header, so that it does not appear in the message header, you must add an entry to the registry. In the registry, go to HKEY_LOCAL_MACHINE\SOFTWARE\Ipswitch\IMail\Global and add the entry BlockRuleHdr with a non-zero value. This is a server wide setting and affects all domain and user rules on the server. If BlockRuleHdr is not present or is set to zero, then the X-IMail-Rule header is enabled and will be displayed in the header of messages.
Storing Search Text in External Files
If you need to frequently update and disseminate the search text for delivery rules, you can use external text files to store the search text. Then, all you have to do is distribute the text file. The external text file must have a file extension of .rul.
For example, an administrator can use this method to catch mail from known spammers. The administrator might create a text file named spam.rul. Each time a new spammer address is discovered, the administrator can add it to the spam.rul file. The rules.ima or orules.ima file can reference the text file named spam.rul. The procedure for storing search text in an external file is the same for inbound and outbound rules.
Example: To send spam messages to a mailbox named spambox, the rules.ima file would contain the line: h~:spam:spambox
Note that the .rul file name is preceded by a colon. IMail Server reads the rules.ima file and looks for the referenced spam.rul file at the same location as the rules.ima file.
To create a delivery rule that references an external text file:
- Select the mail host, user, or list that you want to create a rule for. Then click either the Inbound or Outbound Rules tab (depending on which type of rule you are creating), and click Add.
![]()
- In the Rules dialog box, select the External File option and do one of the following:
- If the external text file already exists, select the file. For example, select :rulefilename where rulefilename is the name of the .rul file you want to reference.
- If the external text file does not exist, enter a new, unique name for the .rul file. Do not enter the file extension rul as IMail Server will append it to whatever you enter.
- Click Edit File to open and edit the .rul file in Windows Notepad (or your default text editor). If the rule file does not exist, it will be automatically created. See the "Rule Syntax" topic in the previous section to create the search text.
- From Select Rule, select the area that you want to search (From, To, Subject, Sender, Body text, or Header text).
- Select contains to have the delivery rule look for messages that contain the search string; select doesn't contain to look for messages that do not contain the search string.
- Select Match Case to search for text that matches the case of the search string; to ignore case, clear Match Case.
- Click OK. You are returned to the Inbound or Outbound Rules tab. Select a message action as described in "Creating an Inbound Delivery Rule" and "Creating an Outbound Delivery Rule for a Host".
- Click Apply to save the rule.
Limitations
Each delivery rule is limited to 5000 characters.
Delivery rules search the first 32,000 bytes of a message. If a message contains fewer than 32,000 text characters plus attachments, the rule will scan the attachment as though it is text. Rarely, when the message text is only a few characters, a delivery rule could find something in an attachment that looks like a match, but isn't.
Commonly Used Rule Examples
The following examples explain how to manually write rules in the rules.ima and orules.ima files.
Example 1: Forwarding Using Rules
A school administrator wants to filter for offensive language and deliver such messages to a specific user account to be reviewed by a faculty member. The administrator could create the following rules:
B~filtered content in body:spambox
S~filtered content in subject:spambox
H~filtered content in header:spambox
F~filtered content in From address:spambox
T~filtered content in To address:spambox
N~filtered content in Sender:spambox
For example, if you want to catch all mail with the subject "kill dusty" then you would have a rule like this: S~Kill Dusty:spambox.
This would also catch messages with the subject "I want to kill Dusty", but it would not catch "I am going to kill that guy Dusty".
The messages are sent to a mailbox called spambox. Unfortunately, this would create a file named spambox.mbx in the users folder which is accessible by the user.
To prevent the user from having access to the spambox mailbox, do the following. Put a forward file in each user's folder. This file must match the name of the mailbox that you used in your rule i.e. spambox.fwd. The only thing that should be in the spambox.fwd file is the account to which you want the filtered messages to go. If you have an account called abuse@ipswitch.com, the spambox.fwd file would look like this: abuse.
When the filtered message is in the abuse-spambox, you can log in to the abuse box and see whether the message contained offensive language, or whether it was caught accidentally. If it was caught accidentally, it can be forwarded on to the original recipient.
Example 2: Deleting messages which contain specific text
If you want to filter for the words "Get Rich Quick" in the subject of a message and delete it without sending it to a mailbox, you would create a rule that looks like this:
Example 3: Filtering messages that have attachments
The rules file would look like this:
B~(name=".*\.vbs"|name=".*\.shs"|name=".*\.scr"):spambox
B~(begin 6.*\.vbs|begin 6.*\.shs|begin 6.*\.scr):spambox
The first rule filters MIME attachments, characterized by the string: name="filename.ext" while the second rule filters unencoded attachments, characterized by the string Begin 6.
These rules include the \s text pattern to search for "any white space" (spaces, tabs or carriage returns) after an attachment extension. Without this pattern, the number of false positives will rise.
Example 4: Filtering messages with no subject
You need your rule to say: If the subject does not contain any character, send to the mailbox called test.
This rule will catch messages that have no subject in the header, and messages that have no word characters in the subject.
Note: In the above example, \s matches any white space character. Note to Killer WebMail and Classic WebMail Users
If you are using the Killer WebMail or Classic WebMail templates, be aware that the "main" mailbox is displayed as the "Inbox" mailbox. Although, the name displayed on the templates is different, IMail Server still regards the "Inbox" as the "main" mailbox. When creating delivery rules, you should always send mail to the "main" mailbox, not to "Inbox". This will correctly place mail in the "Inbox" mailbox in the Killer WebMail and Classic WebMail templates.
![]() Ipswitch, Inc. http://www.ipswitch.com |
| ©Ipswitch 2005 | |||