When VPOP3 is processing SMTP Rules for messages received by SMTP, it runs a script called smtprules_(x).lua, where (x) is replaced by the numeric ID of the SMTP service
VPOP3 processes SMTP Rules at least three times for each message - once when MAIL FROM has been received, once for each RCPT TO, and once when the whole message data has been received.
A function 'First' is called when the SMTP Rules processing starts
A function 'Last' is called when the SMTP Rules processing ends, only if no other rule has triggered and caused the rule processing to end
A function can also be called if a 'Call Lua Function' SMTP rule is triggered. In this case, the function name then is specified in the SMTP rule definition
In each case, the function has the same parameters
Message Data
Message Size (in bytes)
When the function is being called (1 = MAIL FROM, 2 = RCPT TO, 3 = DATA)
Table of header modifiers (one header line per table entry)
Name of SMTP Rule being processed (or 'First', or 'Last')
The function should return up to 10 values
Rule action. All actions other than 'None' will cause the rule processing to end immediately
Rule number for logging
Rule name for logging
Extra rule data (eg redirection address, etc)
New header modifiers (one header line per table entry) - Note that this *replaces* any existing, so the function should probably modify the header modifiers passed to the function rather than making a new table
block IP address - boolean - IP address is blocked temporarily (using IP address blocking timer)
disconnect - boolean - SMTP connection is dropped immediately after the message is processed
hold - boolean - the message is held, rather than being sent or delivered immediately
temporary - boolean - the rule is treated as a temporary one, so if the action is to reject the message, it is rejected with 4xx temporary failure, rather than a 5xx permanent failure
keywords - table of IMAP4 keywords to use for the message (only relevant for VPOP3 Enterprise). This replaces any existing in the MessageData, so the script should probably modify that rather than making a new table