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 [2017/01/20 11:56] – [SMTP Server Global Variables] paulreference:lua_smtp_server_script [2026/05/29 11:39] (current) – [LoadLimits()] paul
Line 1: Line 1:
 +=====End()=====
 +''End()''
 +
 +This function is called by VPOP3 when the SMTP service session ends
 +
 ======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 10: Line 15:
   * **Start()** - called when the SMTP service session starts up, before the welcome message is sent to the SMTP client   * **Start()** - called when the SMTP service session starts up, before the welcome message is sent to the SMTP client
   * **RBLResults()** - (VPOP3 Enterprise Only) - called after the RBL checks have been performed   * **RBLResults()** - (VPOP3 Enterprise Only) - called after the RBL checks have been performed
 +  * **LoadLimits()** - (v8.7+ Enterprise Only) - called at connection to be able to dynamically alter service load limits
   * **GetMaxMessageSize()** - called at startup, and when the HELO and EHLO commands are received   * **GetMaxMessageSize()** - called at startup, and when the HELO and EHLO commands are received
   * **GetEHLOCapabilities()** - called when the EHLO command is received   * **GetEHLOCapabilities()** - called when the EHLO command is received
Line 67: Line 73:
   * **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 176: Line 186:
 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). The **<SPF Result>** is the result (pass, fail, softfail, etc) of the SPF check (if any) on the connection (in v5 and later).
  
Line 223: Line 233:
     * 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 245: Line 255:
 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()=====
 ''CheckRecipients(<Recipient List>, <To Recipients>, <Cc Recipients>, <Bcc Recipients>, "<Sender IP Address>", "<Authenticated Sender>", "<Sender Address>", "Subject", <locally sent>, <message size>'' ''CheckRecipients(<Recipient List>, <To Recipients>, <Cc Recipients>, <Bcc Recipients>, "<Sender IP Address>", "<Authenticated Sender>", "<Sender Address>", "Subject", <locally sent>, <message size>''
Line 268: Line 280:
  
 This function is called by VPOP3 when the SMTP service session ends This function is called by VPOP3 when the SMTP service session ends
 +
 +=====LoadLimits()=====
 +Added in v8.7
 +
 +  function LoadLimits(threadCounts, ipAddress, cpuLoad, spamfilterDuration)
 +  
 +(cpuLoad & spamfilterDuration added in v9.1)
 +
 +This function is called by VPOP3 when an SMTP session is about to start to determine whether the load limiting should allow it
 +
 +  * threadCounts = table of settings & counts
 +    * ThreadCount = total number of SMTP sessions
 +    * ThisClientThreadCount = number of SMTP sessions from this IP Address
 +    * ReservedAddresses = reserved addresses from settings
 +    * Response = (output) SMTP response if connection is to be rejected outright
 +    * MaxIncomingServerThreads = from settings
 +    * MinIncomingServerThreads = from settings (added in v9.1)
 +    * DynamicIncomingServerThreads = from settings (added in v9.1)
 +    * MaxLocalServerThreads = from settings
 +    * SingleAddressLimit = from settings
 +    * SingleAddressLimitLocal = from settings
 +    * ReservedThreads = from settings
 +    * LocalClient = boolean - is IP address local
 +  * ipAddress = client IP address
 +  * cpuLoad = CPU load % (0-100)
 +  * spamfilterDuration = average spam filter processing duration over last minute (in milliseconds)
 +
 +The function should return the 'threadCounts' table, potentially modified.
 +
 +If 'Response' contains text, then VPOP3 will return this response to the client and close the connection. It should begin with a valid SMTP response code, eg '421' to indicate a temporary problem
 +
 +If 'Response' is blank, then VPOP3 will continue with the normal load limiting processing, using the new settings from the returned threadCounts table.
reference/lua_smtp_server_script.1484913414.txt.gz · Last modified: (external edit)