reference:user_delivery_script

User Delivery Script

(VPOP3 v6.5 or later)

If there is a <username>/delivery.lua script, this Lua script can override VPOP3's message delivery options. You can edit this in the Settings → Scripts page in the settings. This script affects how VPOP3 will handle how messages being delivered to this user are handled.

If that script doesn't exist, but there is a delivery.lua script, that Lua script will be used instead.

The script can contain two functions “PreDeliver” and “DeliverMessage”. These functions are called with no parameters, but will have access to global variables containing information about the message and can modify global variables to alter the way the message delivery is handled.

(Prior to v6.20, only the DeliverMessage function is used)

Global Variables set before functions are called

  • User - the username the message is to be delivered to
  • Subject - the subject of the message
  • Originator - the email address of the message sender
  • Filename - the temporary name of the file containing the message to be delivered
  • MessageSize - the size of the message to be delivered
  • Held - whether the message is to be delivered as held
  • Seen - whether the message is to be delivered as marked read
  • Flagged - whether the message is to be delivered as flagged/starred
  • Keywords - a table containing a list of keywords to be associated with the message
  • Folders - a table containing a list of folders for the message to be delivered to
  • SpamScore - the VPOP3 spam filter's score assigned to the message
  • Headers - the message headers (table of string pairs - [1] field name, [2] data
  • Forwards - email addresses to forward the message to (table of strings)
  • HeaderMods - header modifiers (table of strings)
  • ForwardingSenderAddress - the sender address for any forwards
  • ForwardingSenderText - the text name of the sender for any forwards
  • Quarantine - bool - whether the message should be quarantined or not

PreDeliver

PreDeliver is called at the beginning of the delivery process, after Message Rules have been handled. It can modify any globals, but only the Quarantine, Forwards, HeaderMods, ForwardingSenderAddress and ForwardingSenderText globals are read after it has been called. Any other changes made by this function will be left unchanged and will be processed after the DeliverMessage function is called.

Global Variables which can be set by the PreDeliver function

  • Forwards - email addresses to forward the message to (table of strings)
  • HeaderMods - header modifiers (table of strings)
  • ForwardingSenderAddress - the sender address for any forwards
  • ForwardingSenderText - the text name of the sender for any forwards
  • Quarantine - bool - whether the message should be quarantined or not

DeliverMessage

DeliverMessage is called in the middle of the delivery process, as long as the message is still being delivered into at least one message folder.

If the message is quarantined or Message Rules have indicated that it is not to be delivered to any folders, then it will not be delivered further so DeliverMessage will not be called.

Global Variables which can be set by the function

  • Held - whether the message is to be delivered as held
  • Seen - whether the message is to be delivered as marked read
  • Flagged - whether the message is to be delivered as flagged/starred
  • Keywords - a table containing a list of keywords to be associated with the message
  • Folders - a table containing a list of folders for the message to be delivered to

Note that the script can do other things as well, such as saving the message contents elsewhere (using the 'Filename' variable) or calling an external program, or whatever. If the script doesn't alter the global variables, the message will be delivered just as if the script hadn't been called.

reference/user_delivery_script.txt · Last modified: 2018/11/14 10:45 by 127.0.0.1