Rules


This file specifies the Rules items. In rules you can specify any conditions and string functions you could ever need. Most of the time you can use the Rules dialog to edit it.

Formal Syntax:

filteritems = *(filteritem)  
filteritem = (defaultitem / filteritem / standarditem) CRLF  
defaultitem = actionitem  
actionitem = ("0" / "1" / "2" / "3" / "4" / "5")  
filteritem = [actionitem [filterflags] ":"] filters  
filters = filter *([booloperator filter])  
booloperator = (andoperator / oroperator)  
andoperator = "{(O)=&}"  
oroperator = "{(O)=|}"  
filter = itemcondition itemfunction itemvalue  
itemvalue = conditionstring  
standarditem = (ipaddress / domainstring / emailstring)  
ipaddress = (ipaddress / ipaddressmask)  
domainstring = (domain / domainmask)  
emailstring = emailaddress / emailmask)  
filterflags = "(" flags ")"  
flags = *(flagitem ",")  
flagitem = (continueflag / disabledflag / imflag / messageflag / forwardflag / returnflag / bodyflag / folderflag / copytofolderflag / titleflag / encryptflag / priorityflag / messageflags / editheaderflag)  
disabledflag = "X" Specifies that this rule is disabled/inactive
continueflag = "C" Next filters will be processed
imflag = "I" The email sent using the forwardflag will be sent to IM
messageflag = "M=" messagetext You can set your own message headers and text for the forwardflag, encode the whole message structure using the URL Encode function
forwardflag = "F=" *(emailaddress ";") Email will be forwarded to the email address. Email address is url encoded
returnflag = "R="("0" / "1") Sets the return result
bodyflag = "B" The filter is applied only when the full message has been received
folderflag = "D=(foldername)" Message will be moved to the folder. Use only for account filters
copytofolderflag = "P=(foldername)" Message will be copied to the folder. Use only for account filters
sessionflag = "S" Filtering will be stopped if reached this flag and the message was not received yet (the session did not receive the message yet. Typically this happens for SMTP conditions.) If you want to combine SMTP and Body filters you should use this flag as a standalone filter for all and then define all filters below.
titleflag = "T=(titlename)" Title or comment for the filter
encryptflag = "E" Encrypt message
prioritytflag = "Y=(priorityvalue)" Sets the message priority value. 1 - Highest, 2 - Hight, 3 - Normal, 4 - Low, 5 - Lowest
messageflags = "G=(flagsvalue)" Sets the message flags value - each bit represents some IMAP flags (Flagged, Seen, Junk, NonJunk, Label1..Label6)
editheaderflag = "H=(editheader)" Edits the message header. Structure of editheader follows *(headeraction headername headervalue CRLF) Eg. 0Subject: Text (0 - Add/Edut, 1 - Delete)
Filter flag values can contain system variables. In result you can easily create an auto responder or message forwarder.

Structure of the filter file:


The file is constructed by several rules filter items. Each filter is placed on a separate line. By default all filters will reject all messages. Sometimes you might want to accept some messages instead. For this purpose you can use the prefixes at the beginning of the line:
0: - Reject  
1: - Accept  
2: - Delete  
3: - Spam  
4: - No Action This will make a filter exception but will not affect other filters.
5: - Quarantine  
 
You can also specify the whole area to be accepted or rejected by a single line containing 1 or 0. That means all following filters are meant to be rejected (0) or accepted (1) unless the filter record itself has the reject/accept prefix.

Syntax of the filter:


Conditions:

* - All messages  
H - Header item matches value  
B - Body matches value  
A - Attachment matches value  
S - Sender matches value  
R - Recipient matches value  
I - IP Address matches value  
Y - Any Header matches value  
P - rDNS (PTR) matches value  
T - Session has been SMTP AUTHenticated  
G - Message size is greater than. Value in bytes  
L - Message size is lower than. Value in bytes  
M - Message is spam  
C - Spam score is grater or equal than. Value a truncated real number multiple of 100  
D - Message contains any attachments  
E - Sender is trusted or authenticated IP address  
N - Sender/Recipient is local/remote  
F - Time condition  
 

Functions:

~ - Contains  
^ - RegEx  
{ - Starts With  
} - Ends With  
= - Is  
& - Contains list from file  
! - NOT (Negates the function)  
$ - Case Sensitive  
% - Whole word match  
# - Ignore XML  
 

Filter Examples:

A~.com;.exe;.bat;.cmd;.scr Attachment contains any of the file types
~Subject: win;free;!!! Header "Subject" contains any of the strings
I=205.128.218.193 IP Address
Y$^^Subject: WIN Free!!!$ Any header contains case sensitive RegEx expression
!~Subject: money Header "Subject" does NOT contain the string
 

Examples with default (Standard) item:

205.*.*.193 Sender's IP Address matches the mask
domain.com Sender's domain name match
bill*@domain.com Sender's email address matches the mask
Note: all mentioned filters don't have an action specified explicitly therefore "Reject" as the default action applies.
Note: in case neither Item nor Function are specified then Item Standard (ie. either sender's email, domain or IP address) is taken by default.
Note: in case no Item is specified but the Function is specified then Item Header is taken. The first string you should specify in the body of such condition is the name of the header that should be checked (including the colon) and then the string condition itself.
 

More Sophisticated Filter Examples:

1:T Accept all SMTP AUTHenticated emails
1:~Subject: please help Accept if Subject contains "please help"
A~.com;.exe;.bat;.cmd;.scr Reject attachments contains any of the file types
1 Accept following filters
I=192.168.0.1 - Accept messages from IP 192.168.0.1
I=172.16.10.0/24 - Accept messages from IP range 172.16.10.0-255
0 Reject following filters
A~.vbs;.bat - Reject attachments containing any of these file types
S&C:\reject.txt - Reject in case sender matches some entry from C:\reject.txt file
1(C,I,F=john@doe.com):A~.exe Forward message to john@doe.com instant messaging account if it contains a .exe attachment and process following filters
 

Multiple condition filter:

1:~Subject: help{(0)=&}I=192.168.0.1 - Accepts messages if subject contains help and the message was sent from IP 192.168.0.1
 

Session filter

4(S):*~ Makes sure the filtering does not continue with other filters if the message was not received by the server yet