To get to this page, to to Services → SMTP Server → Filtering → Edit SMTP Rules
This page lets you configure rules for how VPOP3 processes messages it receives using SMTP (either from local senders or via an incoming SMTP feed).
VPOP3 processes SMTP rules in order from top to bottom. When it finds a rule whose conditions match the incoming message, it will process the rule, and then stop processing any further messages (except where stated otherwise below in the Action descriptions). You can re-order the rules by clicking the up/down arrows to the left of the rule names.
The A/R/M/D icon before the function name indicates the Stage at which that rule is processed. See below for information on processing stages.
In VPOP3 Enterprise, each SMTP Service has its own set of SMTP Rules. When you create a new SMTP Service, the new service is created with a copy of the first SMTP Service's SMTP Rules, but from then on they can be edited separately.
You can add a new rule by pressing the Add Rule button at the top of the page, delete a rule by pressing the Delete button to the right of the rule name, or edit the rule by pressing the Edit button to the right of the rule name. Changes to rules take effect immediately, so there is no Submit button; just press the Close button to close the editor.
When you add or edit a rule, the rule editor will be displayed as below
The Name box contains a name you specify for the rule. The name can be anything, but it is best to make it something meaningful to make the rules easier to maintain and to help when looking in log files.
The Stage box lets you specify the stage of the SMTP transaction when the rule will be processed. The default is Auto when VPOP3 will look at the conditions being checked to work out when a suitable time to process the rule is. A message transaction has three stages:
1.MailFrom - when the sender specifies the email address that the message is being sent from (the 'return path'). VPOP3 also knows authenticated sender details (if any), sender IP address, current date & time, and possibly message size at this point. It does not know who the message is for, or any message header data such as message subject.
2.RcptTo - when the sender specifies who the message is being sent to (the 'recipients'). VPOP3 knows all the data for the MailFrom stage, plus the current recipient, previously specified recipients and the number of recipients. VPOP3 processes the rule once for each recipient specified by the sender, not just once per message. Note that VPOP3 knows 'recipients' at this stage, it does not know whether the recipient was specified in the To, Cc or Bcc header. That is only discovered when VPOP3 has received the message headers in the Message Data stage.
3.Message Data - when the sender has sent the message to VPOP3. VPOP3 knows all the data for the RcptTo stage as well as the message size and message headers and the type of recipients.
The Action box lets you specify what happens when the rule conditions match. See the Action Descriptions section below for more details.
The Redirect to box lets you specify an email address which the message should be redirected to if the rule matches. This box is only present for Redirect actions. A similar Copy to box is displayed for Copy rules. You can specify multiple email addresses by separating them with commas. With VPOP3 Enterprise you can also specify a target folder for local targets by adding a space and the folder name after the username - eg fred Customers, bob will send it to the "inbox" for the user "bob" and the "Customers" folder for the user "fred".
For Set Header actions, there is a Header Line box where you can specify the header line to add.
For the Block IP Address action, there is a Duration box where you can specify how long to block the sender IP address for.
For the Call Lua Function action, there is a Function Name box where you can specify the Lua function name to call.
The Condition match box lets you specify whether all the conditions must match for the rule to be triggered, or only any one of the conditions must match.
Below this you specify the conditions for the rule. You can specify as many conditions as you want. Press the Add Condition button to add a new condition, and delete an existing condition by pressing the relevant Delete button. See the Condition Descriptions section below for more details.
•Accept - VPOP3 will accept the message as normal.
•Reject - VPOP3 will reject the message with a 5xx or 4xx response. If the conditions included any DayNow or TimeNow conditions, then VPOP3 will use a 4xx response to tell the sender to try again later, otherwise it will use a 5xx response to indicate that the message should not be retried. The reject response will say something like 550 5.7.1 Sender Prohibited (x), where 'x' indicates the number of the SMTP rule which matched to help the VPOP3 administrator diagnose what happened.
•Redirect - the message will not be delivered to the original recipient(s) but will be redirected to the recipients specified in the SMTP Rule.
•Ignore - the message will be ignored by VPOP3. The sender will think the message was delivered OK. The message will be 'blackholed'.
•Copy - the message will be delivered to the original recipient(s) and will also be copied to the recipients specified in the SMTP Rule.
•Hold - the message will be accepted by VPOP3, but will be 'held' by VPOP3 which means that only administrators can see the message, and it will not be sent out or delivered to the user's email client.
•Reject and Disconnect - VPOP3 will reject the message as with the Reject action, but the SMTP session will be dropped immediately as well.
•Set Header and Continue - VPOP3 will add a message header to the incoming message. VPOP3 will then continue to process further Download Rules. (Note that the header is modified AFTER the download rules have run, so you cannot check for the changed header in later download rules).
•Set Header and Accept - VPOP3 will add a message header to the incoming message and accept the message. VPOP3 will then not process further Download Rules.
•If - if this rule does not match, VPOP3 will not process any more rules until it encounters an Else or EndIf rule.
•Else - this type of rule cannot have any Conditions. It must be used after an If rule.
•EndIf - this type of rule cannot have any Conditions. It must be used after an If or Else rule.
•Block IP Address - VPOP3 will block the sender IP address for the specified time.
•Call Lua Function - VPOP3 will call the specified Lua function in the SMTP Rule script and use the result of that function as the SMTP rule result
Conditions have 4 parts:
1.the type of condition
2.optional Not flag. If this is set, then the match operator is inverted (eg if the match operator is 'Contains', then if you check the Not box, the match condition becomes 'Does not contain')
3.match operator (eg Contains, Equals etc)
The condition type can be ANY message header field, as well as some special pseudo-headers.
Common header fields to check are From, To, Subject etc. Note that if VPOP3 is checking a message header field it does not process the header data, but uses the full data from the raw header. This means that if you check for "From" "Equals" "email@example.com", it is actually unlikely to match messages from firstname.lastname@example.org. This is because often the From header would actually say From: Bob Wright <email@example.com>, so VPOP3 will be comparing Bob Wright <firstname.lastname@example.org> to just email@example.com, and they are not equal.
You can check multiple headers by separating them with commas - a common example would be To,Cc to check both the To and Cc header fields. If either header matches, then the condition matches.
If you prefix the header field name with 'mimedec_', then VPOP3 will MIME decode the message header data before comparing it. For instance, mimedec_subject will make VPOP3 compare the decoded Subject header field, rather than the original raw Subject header field.
The pseudo-headers supported by VPOP3 are:
•Always - if the data is '1' then the condition matches, if the data is '0' then the condition doesn't match. The actual message data is not checked at all.
•TimeNow - this checks if the time now is within the range specified by the condition data. You can specify times as hh:mm or just hh and indicate ranges by using the '-' character. Eg '9:00-17:00' will match if the current time is between 9.00 am and 5.00 pm inclusive or 9-17 will match if the current time is between 9.00am and 5.59 pm. If you do not specify a From time, then 0:00 is assumed. If you don't specify a To time, then 23:59 is assumed. VPOP3 uses the local time on the VPOP3 computer for time checks. The match operator is ignored.
•DayNow - this checks if the day of week now is specified in the condition data. Sunday is 1, Monday is 2 etc. So, DayNow - 135 will match if the current day is Sunday, Tuesday or Thursday. The match operator is ignored.
•IPAddress - this checks the sender's IP address against the condition data.
•MailFrom - this checks the SMTP Return Path/Mail From value against the condition data.
•AuthUser - this checks the SMTP authenticated user (if any) against the condition data.
•RcptTo - this checks to see if the recipient specified in the condition data is in the SMTP recipients already specified for the message.
•ThisRcptTo - this checks to see if the recipient specified in the condition data matches the SMTP recipient currently being specified for the message.
•RcptCount - this checks the number of SMTP recipients specified for the message.
•Bcc - this checks to see if the condition data matches any of the BCC recipients for the message. VPOP3 determines if a recipient is a Bcc recipient by comparing the SMTP recipients against those specified in the To and Cc header fields. Any SMTP recipient which is not listed in the header is assumed to be a Bcc recipient.
•BccCount - this checks the number of BCC recipients specified for the message.
•Size - this checks to see if the message size matches the condition data as indicated by the match operator.
All matches apart from regex matches are case insensitive. Numeric data is checked numerically for numeric operators like greater than etc. If you check numeric data with contains, begins with, regex etc, then the numeric data is converted to a string a tested as text.
•equals - the value matches the condition data exactly.
•is - the same as equals
•not equals - the value does not match the condition data.
•greater than - the value is greater than the condition data (text data is compared alphabetically).
•greater or equal - the value is greater than or equal to the condition data (text data is compared alphabetically).
•less than - the value is less than the condition data (text data is compared alphabetically).
•less or equal - the value is less than or equal to the condition data (text data is compared alphabetically).
•contains - the value contains the condition data as a substring.
•wildcard matches - the value matches the condition data when processed as a wildcard string (* and ? wildcards).
•begins with - the value begins with the condition data.
•ends with - the value ends with the condition data.
•regex matches - the value matches the specified regular expression - specified as /<regex>/<flags> - eg /my cat/i
VPOP3 creates a log file in the log path called SMTPRULES.LOG. This log file contains information on all download rules which are triggered.
If the message is rejected by the SMTP rules, the rejection text will contain the rule number in parentheses. Possible SMTP rejection lines are:
•450 4.7.1 Recipient Prohibited
•450 4.7.1 Sender Prohibited
•454 4.7.1 Message Prohibited
•550 5.7.1 Recipient Prohibited
•550 5.7.1 Sender Prohibited
•554 5.7.1 Message Prohibited