Every time VPOP3 is going to send messages using direct MX sending, it runs a script called mxout.lua which can be created/edited in Settings → Scripts (or in the VPOP3 directory in VPOP3 v6.6 or earlier).
Starting with v8.8, the following global variables are defined:
For every message which is to be sent VPOP3 calls a function in that script called CheckFile.
The function signature is: CheckFile(Filename, Actions, Size, CreationTime, Retries, LastTryTime, ReturnPath, Recipients, HeaderData, HeaderLines)
The function returns an Actions object saying what to do with the message. If nothing else, the function should return the Actions parameter.
The Actions object contain four values:
If you need to tweak how VPOP3 connects to remote servers you can write a ServerDetails function. VPOP3 calls this function before sending each message.
(This function was added in VPOP3 v6.5)
The function signature is: ServerDetails(Parameters, HeaderLines, Actions)
The Parameters object contains details of the message being sent:
The function returns an Actions object saying what to do with the message. If nothing else, the function should return the Actions parameter.
The Actions object contains 9 or more values:
Starting with VPOP3 v6.17 it also contains:
Example - don't use SSL when connecting to 'mail.broken.com'
function ServerDetails(params, headers, actions)
if params["server"] == "mail.broken.com" then
actions["tryTLS"] = 0
end
return actions
end
(VPOP3 8.0 and later)
In VPOP3 v8.8 and later, a function is called as each message is sent, allowing the Lua script to rewrite the Return Path (MAIL FROM) address. This can be useful for implementing things such as SRS or other sender rewriting
The function signature is: ModifyReturnPath(Computed-Mail-From, Mail-From, Original-Mail-From, Auth-Sender, Recipients, Creation-Time, Headers, Size, Sender-IP-Address, Subject, All-Recipients)
The function can return a single string value which is the new Return Path to use (if it doesn't return anything, then the 'Computed-Mail-From' value will be used).
Starting in version 8.8, VPOP3 will call the function ReturnCodeHandler every time it receives a return code from the onward MX server.
The function signature is: ReturnCodeHandler(LastCommand, FullResponse)
The function optionally returns a string which contains the new full response. This must start with a numeric SMTP return code.
This function is intended to be used if the ISP returns inappropriate return codes. For instance, some ISPs return '4xx' return codes for 'bad recipient', which makes VPOP3 retry sending the message when they should really return a '5xx' return code to tell VPOP3 not to retry the message, and just generate a delivery failure report.