User Tools

Site Tools


reference:smtp_rules_script

Lua SMTP Rules Scripts

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

Function Prototype

In each case, the function has the same parameters

  1. Message Data
  2. Message Size (in bytes)
  3. When the function is being called (1 = MAIL FROM, 2 = RCPT TO, 3 = DATA)
  4. Table of header modifiers (one header line per table entry)
  5. Name of SMTP Rule being processed (or 'First', or 'Last')

The function should return up to 10 values

  1. Rule action. All actions other than 'None' will cause the rule processing to end immediately
    • 0 = None
    • 1 = Accept
    • 2 = Reject
    • 3 = Redirect
    • 4 = Copy
    • Other actions can be created by combining the above with other options below
  2. Rule number for logging
  3. Rule name for logging
  4. Extra rule data (eg redirection address, etc)
  5. 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
  6. block IP address - boolean - IP address is blocked temporarily (using IP address blocking timer)
  7. disconnect - boolean - SMTP connection is dropped immediately after the message is processed
  8. hold - boolean - the message is held, rather than being sent or delivered immediately
  9. 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
  10. 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
reference/smtp_rules_script.txt · Last modified: by paul