User Tools

Site Tools


reference:lua_smtp_server_script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
reference:lua_smtp_server_script [2013/06/03 08:28] – [SMTP Server Lua Scripting] paulreference:lua_smtp_server_script [2024/05/01 14:12] (current) – [ProcessMessage()] paul
Line 1: Line 1:
 ======SMTP Server Lua Scripting====== ======SMTP Server Lua Scripting======
  
-The SMTP Server [[http://wiki.pscs.co.uk/reference;lua_scripting|Lua Script]] is called SMTPSVR.LUA and should be placed in the VPOP3 folder. This script is called whenever an instance of the VPOP3 SMTP server is launched - ie whenever someone opens a connection to port 25 on the VPOP3 server to send it a message, whether from a local user or an incoming SMTP message.+The SMTP Server [[http://wiki.pscs.co.uk/reference;lua_scripting|Lua Script]] is called SMTPSVR.LUA and can be edited from the Settings -> Scripts page in the VPOP3 settings. This script is called whenever an instance of the VPOP3 SMTP server is launched - ie whenever someone opens a connection to port 25 on the VPOP3 server to send it a message, whether from a local user or an incoming SMTP message.
  
 Each SMTP server instance has its own instance of the SMTPSVR.LUA script. No threading conflicts will occur. Each SMTP server instance has its own instance of the SMTPSVR.LUA script. No threading conflicts will occur.
Line 28: Line 28:
   * **MessageLine()** - (v5+) called after processing each message line received by VPOP3   * **MessageLine()** - (v5+) called after processing each message line received by VPOP3
   * **EndMessage()** - (v5+) called when the message terminator . has been received at the end of a message   * **EndMessage()** - (v5+) called when the message terminator . has been received at the end of a message
-  * **CheckRecipients()** - (v6.3+) called at the end of a message to check if recipients are allowed +  * **CheckRecipients()** - (v6.3+ Enterprise Only) called at the end of a message to check if recipients are allowed 
-  * **LogRecipients()** - (v6.3+) called at the end of a message to allow customised logging of recipients +  * **MonitorBcc()** - (v6.3+ Enterprise Only) called to customise monitoring of messages with BCCs 
-  * **LogRecipientsBlocked()** - (v6.3+) called at the end of a message if recipients have been blocked to allow customised logging of recipients+  * **LogRecipients()** - (v6.3+ Enterprise Only) called at the end of a message to allow customised logging of recipients 
 +  * **LogRecipientsBlocked()** - (v6.3+ Enterprise Only) called at the end of a message if recipients have been blocked to allow customised logging of recipients
   * **End()** - called when the SMTP service session ends   * **End()** - called when the SMTP service session ends
 =====SMTP Server Global Variables===== =====SMTP Server Global Variables=====
Line 42: Line 43:
   * **AllowedUsers** - (IN/OUT) - string - List of allowed usernames (separated by spaces) if there are any username restrictions for this client IP address   * **AllowedUsers** - (IN/OUT) - string - List of allowed usernames (separated by spaces) if there are any username restrictions for this client IP address
  
 +===V5 and later===
 +  * **AuthenticatedUser** - (IN) - string - username of authenticated sender (using SMTP or POP3-then-SMTP authentication)
 +  * **SMTPAuthenticatedUser** - (IN) - string - username of authenticated sender (using SMTP authentication only)
 +  * **ForceDisconnect** - (IN/OUT) - boolean - drop the connection as soon as possible
 +  * **UseBATV** - (IN/OUT) - boolean - use [[http://en.wikipedia.org/wiki/Bounce_Address_Tag_Validation|BATV]] (Bounce Address Tag Validation)
 +
 +===V6 and later===
 +  * **MaxRecipientsPerLocalMessage** - (IN/OUT) - number - maximum number of recipients allowed for locally sent messages
 +  * **MaxRecipientsPerIncomingMessage** -  (IN/OUT) - number - maximum number of recipients allowed for incoming messages
 +  * **MaxMessagesPerLocalSession** - (IN/OUT) - number - maximum number of messages allowed per local session
 +  * **MaxLineLength** - (IN/OUT) - number - maximum line length
 +  * **AddUserAddresses** - (IN/OUT) - boolean - add recipients of locally sent messages to the autocomplete address list
 +
 +===V6.5 and later===
 +  * **ServerID** - (IN) - number - ID of SMTP Service in VPOP3
 +  * **ServerName** - (IN) - string - name of SMTP Service in VPOP3
 ====In VPOP3 Enterprise Only==== ====In VPOP3 Enterprise Only====
   * **CheckRBL**   * **CheckRBL**
Line 50: Line 67:
   * **RBLRejectMessage**   * **RBLRejectMessage**
   * **RBLHeader**   * **RBLHeader**
 +
 +===V7.10 and later===
 +  * **Encryption** - (IN) - boolean - Is the session encrypted
 +  * **EncryptionDetails** - (IN) - string - SSL/TLS version and SSL/TLS cipher being used (if encrypted)
 =====SMTP Server "Start()"===== =====SMTP Server "Start()"=====
 ''Start()'' ''Start()''
Line 136: Line 157:
  
 This function should return the text to return to the client (or "" to use the default VPOP3 text) This function should return the text to return to the client (or "" to use the default VPOP3 text)
 +=====DoVRFY()=====
 +''DoVRFY(<recipient list>, "<current response>)''
 +
 +This function is called by VPOP3 when it receives a //VRFY// command
 +
 +The 'Recipient list' contains the expanded list of recipients which the command's parameter expands to. The 'current response' contains the response which VPOP3 would return if the script doesn't exist.
 +
 +This function should return the text to return to the client (return the value of the <current response> parameter to return VPOP3's normal response)
 +=====DoEXPN()=====
 +''DoEXPN(<recipient list>, "<current response>)''
 +
 +This function is called by VPOP3 when it receives a //EXPN// command
 +
 +The 'Recipient list' contains the expanded list of recipients which the command's parameter expands to. The 'current response' contains the response which VPOP3 would return if the script doesn't exist.
 +
 +This function should return the text to return to the client (return the value of the <current response> parameter to return VPOP3's normal response)
 =====DoMAILFROM()===== =====DoMAILFROM()=====
-DoMAILFROM("<data>", "<mailfrom>", <parameters>)+DoMAILFROM("<data>", "<mailfrom>", <parameters>, "<SPF Result>", "<Auth Sender>")
  
 This function is called by VPOP3 when it receives a valid //MAIL FROM// command This function is called by VPOP3 when it receives a valid //MAIL FROM// command
Line 143: Line 180:
 The **<data>** is the raw data after the //MAIL FROM:// command\\ The **<data>** is the raw data after the //MAIL FROM:// command\\
 The **<mailfrom>** is the address after the //MAIL FROM:// command\\ The **<mailfrom>** is the address after the //MAIL FROM:// command\\
-The **<parameters>** is a table of parameters to the //MAIL FROM:// command (if any) with the table entry key being the parameter name and the table entry value being the parameter value+The **<parameters>** is a table of parameters to the //MAIL FROM:// command (if any) with the table entry key being the parameter name and the table entry value being the parameter value\\ 
 +The **<SPF Result>** is the result (pass, fail, softfail, etc) of the SPF check (if any) on the connection (in v5 and later).
  
 This function should return **<new parameters>, <SMTP Result string>** This function should return **<new parameters>, <SMTP Result string>**
Line 189: Line 227:
     * Reason string - text string to use if a reason is needed for the action     * Reason string - text string to use if a reason is needed for the action
     * Recipients table - table containing new/replacement recipients for the message     * Recipients table - table containing new/replacement recipients for the message
-    * HeaderModifiers table - list of message header modifications to make+    * HeaderModifiers table - list of message header modifications to make - each entry is the full header line (eg "From: <user@company.com>")
   * <message MIME structure> is a table with one or more of the following entries   * <message MIME structure> is a table with one or more of the following entries
     * Path string - the IMAP style path to the message section     * Path string - the IMAP style path to the message section
Line 211: Line 249:
 This function should return <new actions table>, <results string> This function should return <new actions table>, <results string>
  
-In this function the VPOP3 ProcessMessage helper functions can be used.+(In version 7.0 and later, the returned 'results string' is ignored) 
 + 
 +In this function the [[lua_scripting#only_in_pop3cltlua_and_smtpsvrlua_processmessage_function|VPOP3 ProcessMessage helper functions]] can be used. 
 +=====CheckRecipients()===== 
 +''CheckRecipients(<Recipient List>, <To Recipients>, <Cc Recipients>, <Bcc Recipients>, "<Sender IP Address>", "<Authenticated Sender>", "<Sender Address>", "Subject", <locally sent>, <message size>'' 
 + 
 +This function is called after the entire message has been received (so the message headers can be parsed by VPOP3) and allows a script to check that the recipients, and recipient types (eg Bcc) are allowed for this message 
 + 
 +  * Recipient List  - table containing a list of the recipient email addresses (from the RCPT TO envelope) 
 +  * To Recipients  - table containing a list of the recipient email addresses parsed from the To header field 
 +  * Cc Recipients  - table containing a list of the recipient email addresses parsed from the Cc header field 
 +  * Bcc Recipients  - table containing a list of the Bcc recipient email addresses. (This is calculated as taking the recipient list, and removing any entries from the To or Cc header fields) 
 +  * Sender IP Address - string containing the IP address of the sender 
 +  * Authenticated Sender - string containing the authenticated user name of the sender (if any) 
 +  * Sender Address - string containing the email address of the sender 
 +  * Subject - string containing the message's subject 
 +  * Locally Sent - boolean containing whether the message was sent by a local user (true) or is incoming SMTP (false) 
 +  * Message Size - number containing the size of the message 
 + 
 +This function should return either nothing, or a 4xx/5xx error response to return to the email client if the message is to be rejected 
 =====End()===== =====End()=====
 ''End()'' ''End()''
  
 This function is called by VPOP3 when the SMTP service session ends This function is called by VPOP3 when the SMTP service session ends
reference/lua_smtp_server_script.1370244496.txt.gz · Last modified: 2018/11/14 10:44 (external edit)