User Tools

Site Tools


reference:lan_forwarding_script

LAN Forwarding Scripting

(Added in V8.7)

This is stored in the 'LanForwarding.lua' script in Settings → Scripts

There are two global variables set:

  • MessageType - this is the state VPOP3 is in when calling the script.
  • message = this is a message received from outside of VPOP3 (the usual state)
  • internal = this is a message generated by VPOP3 itself (eg errors, autoresponders, etc)
  • check = this is an intermediate state when VPOP3 is checking to see if a message should be LAN forwarded or not

* MessageType2 - if MessageType is “check”, this contains more information about the stage of internal processing

In “check”, the original return path address may not be known, the script may be called many times. It will be a new instance of the script each time. Only the “PreprocessRules” function will be called in this state

In “message” or “internal”, there is once instance of the script per recipient- “PreprocessRules” is called first, then “GetReturnPath” is called if the message will be LAN Forwarded.

There are two functions:

PreprocessRules

This allows the script to see and potentially modify LAN Forwarding Rules

PreprocessRules(return path, recipient, check mode, mail collector, recipient local part, recipient domain, rules)
  • return path = original return path
  • recipient = recipient
  • check mode =
  • mail collector = the numeric ID of the Mail Collector the message came from (or -1 if SMTP)
  • recipient local part = the part of the recipient's email address before '@' (or blank if not a local address)
  • recipient domain = the part of the recipient's email address after '@'
  • rules = table of LAN forwarding rules, each table entry is another table containing
    • InAddress - address to match
    • ServerAddress - server address (and optional port) for the message to be LAN Forwarded to
    • ServerUsername - optional username to log onto the other server
    • ServerPassword - optional password to log onto the other server
    • OutAddress - rewrite email address if necessary
    • Comment - Rule comment (currently blank on entry)
    • ExtraData - Rule extra data (currently blank on entry)

The function can return a modified 'rules' table containing new rules to check while processing this message. If it returns nothing, the original rules will be used.

GetReturnPath

This allows the script to modify the SMTP Return Path used when sending the message using LAN Forwarding. It is called when the message is added to the LAN Forwarding queue

GetReturnPath(return path, original recipient, target recipient, mail collector, target server, rule id, rule comment, run extra data)
  • return path = original return path
  • original recipient = the message recipient before LAN Forwarding rewriting
  • target recipient = the message recipient after LAN Forwarding rewriting
  • mail collector = the numeric ID of the Mail Collector the message came from (or -1 if SMTP)
  • target server = the target server details (see below)
  • rule id = the numeric LAN Forwarding Rule ID which matched (or 0 if it was an explicit SMTP:… forwarding or assistant)
  • rule comment = the comment associated with the rule
  • rule extra data = extra data associated with the rule

The function should return a new return path (if nothing is returned, the original return path is used)

Currently “rule comment” and “rule extra data” will be blank, unless specified by the “PreprocessRules” function

Target Server is one of:

  • user:pass@server
  • user<tab>pass<tab>server
reference/lan_forwarding_script.txt · Last modified: 2024/10/29 16:29 by paul