This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
reference:lua_smtp_server_script [2013/06/03 07:27] – [SMTP Server Lua Scripting] paul | reference:lua_smtp_server_script [2024/05/01 13:12] (current) – [ProcessMessage()] paul | ||
---|---|---|---|
Line 1: | Line 1: | ||
======SMTP Server Lua Scripting====== | ======SMTP Server Lua Scripting====== | ||
- | The SMTP Server [[http:// | + | The SMTP Server [[http:// |
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+ |
- | * **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+ |
+ | * **LogRecipientsBlocked()** - (v6.3+ | ||
* **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:// | ||
+ | |||
+ | ===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 " | =====SMTP Server " | ||
'' | '' | ||
Line 136: | Line 157: | ||
This function should return the text to return to the client (or "" | This function should return the text to return to the client (or "" | ||
+ | =====DoVRFY()===== | ||
+ | '' | ||
+ | |||
+ | This function is called by VPOP3 when it receives a //VRFY// command | ||
+ | |||
+ | The ' | ||
+ | |||
+ | This function should return the text to return to the client (return the value of the <current response> | ||
+ | =====DoEXPN()===== | ||
+ | '' | ||
+ | |||
+ | This function is called by VPOP3 when it receives a //EXPN// command | ||
+ | |||
+ | The ' | ||
+ | |||
+ | This function should return the text to return to the client (return the value of the <current response> | ||
=====DoMAILFROM()===== | =====DoMAILFROM()===== | ||
- | DoMAILFROM("< | + | DoMAILFROM("< |
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 **< | The **< | ||
The **< | The **< | ||
- | The **< | + | The **< |
+ | The **<SPF Result> | ||
This function should return **<new parameters>, | This function should return **<new parameters>, | ||
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/ | * Recipients table - table containing new/ | ||
- | * 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: < |
* <message MIME structure> | * <message MIME structure> | ||
* 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 ' |
+ | |||
+ | In this function the [[lua_scripting# | ||
+ | =====CheckRecipients()===== | ||
+ | '' | ||
+ | |||
+ | 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 | ||
+ | * Cc Recipients | ||
+ | * Bcc Recipients | ||
+ | * 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' | ||
+ | * 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()===== | ||
'' | '' | ||
This function is called by VPOP3 when the SMTP service session ends | This function is called by VPOP3 when the SMTP service session ends |