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 08:23] – [SMTP Server Lua Scripting] paul | reference: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:// | + | 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 17: | Line 17: | ||
* **DoNOOP()** - called when the NOOP command is received | * **DoNOOP()** - called when the NOOP command is received | ||
* **DoRSET()** - called when the RSET command is received | * **DoRSET()** - called when the RSET command is received | ||
+ | * **DoVRFY()** - (v5+) called when the VRFY command is received | ||
+ | * **DoEXPN()** - (v5+) called when the EXPN command is received | ||
* **DoMAILFROM()** - called when a valid MAIL FROM command is received | * **DoMAILFROM()** - called when a valid MAIL FROM command is received | ||
* **DoRCPTTO()** - called when a valid RCPT TO command is received | * **DoRCPTTO()** - called when a valid RCPT TO command is received | ||
Line 22: | Line 24: | ||
* **DoUnrecognised()** - called when VPOP3 receives an unrecognised SMTP command | * **DoUnrecognised()** - called when VPOP3 receives an unrecognised SMTP command | ||
* **ProcessMessage()** - called when an entire message has been received by VPOP3 | * **ProcessMessage()** - called when an entire message has been received by VPOP3 | ||
- | * **EndMessage()** - called when the message terminator . has been received at the end of a message | + | |
+ | * **MessageLineRaw()** - (v5+) called each time a message line is received by VPOP3 | ||
+ | * **MessageLine()** - (v5+) called after processing each message line received by VPOP3 | ||
+ | | ||
+ | * **CheckRecipients()** - (v6.3+ Enterprise Only) called at the end of a message to check if recipients are allowed | ||
+ | * **MonitorBcc()** - (v6.3+ Enterprise Only) called to customise monitoring of messages with BCCs | ||
+ | * **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===== | ||
The following variables are defined for the SMTP Server Lua script. They are accessible to all callback functions in the script, and can often be modified by the script to modify the VPOP3 behaviour. | The following variables are defined for the SMTP Server Lua script. They are accessible to all callback functions in the script, and can often be modified by the script to modify the VPOP3 behaviour. | ||
Line 35: | 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 43: | 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 129: | 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 136: | Line 180: | ||
The **< | The **< | ||
The **< | The **< | ||
- | The **< | + | The **< |
+ | The **<SPF Result> | ||
This function should return **<new parameters>, | This function should return **<new parameters>, | ||
Line 182: | 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 204: | 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 |