Skip to main content

Lua Functions Summary

Last updated October 2021

This section contains tables of Lua functions. Click the function name for details.

ac:esmtp_capability_add – Add a capability to the EHLO responsenamemsys.extended.ac4.0connect, ehlo
ac:esmtp_capability_remove – Removes a capability string from the EHLO responsenamemsys.extended.ac4.0connect, ehlo
ac:inbound_session_count – If called with no arguments, returns the current inbound session count to this listener for the connecting IP[cidr], [service_type]msys.extended.ac4.0any
client:do_request – Perform an HTTP requesttype, url, [data]msys.http.client4.0any
client:get_body – Get the body of a web page msys.http.client4.0any
client:get_headers – Get a client's headers msys.http.client4.0any
client:get_status – Return the status of an HTTP request msys.http.client4.0any
client:parse_headers – Parse the headers of an HTTP responseheadersmsys.http.client4.0any
client:set_header – Set a client's header[header]msys.http.client4.0any
client:set_timeout – Set the timeout for an HTTP client[number]msys.http.client4.0any
json.decode – Create a JSON object from a JSON stringstrjson4.0any
json.encode – Convert a Lua variable or expression so that it can be added to a JSON objectobjjson4.0any – Create an empty JSON object json4.0any
json.strerror – Return the description of a JSON error codecodejson4.0any
msg.batch_id – Returns the human-readable ec_message.batch_id msys.extended.message4.0data, data_spool, data_spool_each_rcpt, set_binding
msg.conn_id – Returns the human-readable ec_message.conn_id msys.extended.message4.0data, data_spool, data_spool_each_rcpt, set_binding – Returns the human-readable msys.extended.message4.0data, data_spool, data_spool_each_rcpt, set_binding
msg:binding – Sets the binding to the named binding, if one is provided[value]msys.extended.message4.0set_binding
msg:binding_group – Sets the binding_group to the named binding, if one is provided[value]msys.extended.message4.0set_binding
msg:body – Set or get the message body (minus headers)[...]msys.extended.message4.0data, data_spool, data_spool_each_rcpt, set_binding
msg:body_match – Streaming interface to a PCRE search of a message body (minus headers)patternmsys.extended.message4.0data, data_spool, data_spool_each_rcpt, set_binding
msg:body_replace – Streaming interface to a PCRE replacement of a message body (minus headers)pattern, replacementmsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:build – Create a messageheaders, parts, attachmentsmsys.extended.message4.0data, data_spool, data_spool_each_rcpt, set_binding
msg:code – Get or set the message code[number], [string]msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:context_delete – Delete a context variabletype, keymsys.core4.0data, data_spool, data_spool_each_rcpt, set_binding
msg:context_exists – Check if a context variable existstype, keymsys.core4.0data, data_spool, data_spool_each_rcpt, set_binding
msg:context_exists_and_get – Check if a context variable exists and get ittype, keymsys.core4.0data, data_spool, data_spool_each_rcpt, set_binding
msg:context_get – Get a context variabletype, keymsys.core4.0data, data_spool, data_spool_each_rcpt, set_binding
msg:context_set – Set a context variabletype, key, valuemsys.core4.0data, data_spool, data_spool_each_rcpt, set_binding
msg:discard – Silently discard a message[reason]msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:forward – Forward current message to recipients other than the original recipients. A new message is created and the original message is attached to itsender, rcptto, text, [subject], [charset]msys.extended.message4.0data, data_spool, data_spool_each_rcpt, rcptto, set_binding
msg:get_delivery_method – Return the delivery method for a message msys.core4.0data, data_spool, data_spool_each_rcpt
msg:get_envelope2 – Get envelope valuesflags, localpart_str, domain_strmsys.extended.message4.0data, data_spool, data_spool_each_rcpt, set_binding
msg:get_message_size – Get the size of a message msys.core4.0data, data_spool, data_spool_each_rcpt
msg:header – Manipulate message headershdr, [value], [mode]msys.extended.message4.0data, data_spool, data_spool_each_rcpt, set_binding
msg:inject – Use this function to send mailmailfrom, rcpttomsys.extended.message4.0data, data_spool, data_spool_each_rcpt, set_binding
msg:listener_addr – Gets the recv_via IP and/or PORT[flag]msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:mailfrom – Sets the 'MAIL FROM' email address if one is provided. Returns the current/new value[value]msys.extended.message4.0data, data_spool, data_spool_each_rcpt, rcptto, set_binding
msg:makeBoundary – Generates a unique boundary string...msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:makeContainer – Creates a new, unlinked, container message partmimetype, [boundary], [add_terminator]msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:makePart – Creates a new, unlinked, singleton (or leaf) message partmimetype, [body], [encoding]msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:mime – Returns the top of the MIME tree for the message, a message part[readonly]msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:raw – Sets the message content if value is provided and returns the raw message and message length[value]msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:raw_match – Streaming interface to PCRE search message contentpatternmsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:raw_replace – Streaming interface to a PCRE replacement of message contentpattern, replacementmsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:rcptto – Sets the 'RCPT TO' email address if one is provided. Returns the current/new value[value]msys.extended.message4.0data, data_spool, data_spool_each_rcpt, rcptto, set_binding
msg:reception_peer – Returns the IP and/or PORT of the remote injection source[flag]msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:routing_domain – Returns the routing domain for the message[...]msys.extended.message_routing4.0data_spool_each_rcpt, rcptto
msg:text – Returns the transfer decoded text for the body...msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:text – The entire message body is replaced by the supplied textvalue, [type], [charset]msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:text_match – Streaming PCRE search across the transfer-decoded, UTF-8 text version of the message bodypatternmsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msg:text_replace – Streaming interface to PCRE replacement of textual content from the message bodypattern, replacementmsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:addFirstChild – Adds a child as the first child on this partchildmsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:addLastChild – Adds a child as the last child on this partchildmsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:address_header – Parse each instance of the named header for RFC2822 addressesheadername, [component]msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:body_match – Streaming interface to PCRE search a message body part (minus headers)patternmsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:body_replace – Streaming interface to a PCRE replacement of a message body part (minus headers)pattern, replacementmsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:content_type – Returns a table of content type related information msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:header – Returns an array of headers values for the given namenamemsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:header – Unset the header name of the current message partname, nilmsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:header – If mode is replace (or unspecified): first deletes all other headers of that name before appending the new value to the message headersname, value, [mode]msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:insertAfter – Insert this part into the MIME tree after the given parameteraftermsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:insertBefore – Insert this part into the MIME tree before the given parameterbeforemsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:raw_match – Streaming interface to PCRE search of the current message partpatternmsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:raw_replace – Streaming interface to PCRE replacement of message part contentpattern, replacementmsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:text – Returns the transfer decoded text for the message part, in UTF-8...msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:text – The entire message body part is replaced by the supplied textvalue, [type], [charset]msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:text_match – Streaming PCRE search across the transfer-decoded UTF-8 text version of the message body partpatternmsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:text_replace – Streaming interface to a PCRE replacement of textual content from the message body parts. Only parts that have a 'text' mime type will be included in the searchpattern, replacementmsys.extended.message4.0data, data_spool, data_spool_each_rcpt
msgpart:unlink – Removes the part (and its children) from the MIME tree msys.extended.message4.0data, data_spool, data_spool_each_rcpt
msys.adaptive.registerRules – Register adaptive rulesrules, [type]msys.adaptive4.0adaptive
msys.apn.apn_status_classifier – Determine whether the status code indicates a permanent or temporary failurestatusmsys.apn4.0apn_response_eval, msg_dispose
msys.asyncOk – Returns true if the current execution environment is suitable for suspend/resume operation msys4.0any
msys.audit.connections – Returns the number of connections that have occurred for a CIDR block within a configured time windowmonitor, [options]msys.audit4.0any
msys.audit.inbound_session_count – Counts connections currently established from the specified cidr to the specified servicecidr, servicenamemsys.audit4.0any
msys.audit.receptions – Returns the number of receptions that have occurred for a CIDR block within a configured time windowmonitor, [options]msys.audit4.0any
msys.audit.rejections – Returns the number of rejections that have occurred for a CIDR block within a configured time windowmonitor, [options]msys.audit4.0any
msys.audit_series.add – Adjusts the counter for the current time window of a named seriesname, [options]msys.audit_series4.0any
msys.audit_series.count – Returns the total associated with the named seriesname, [options]msys.audit_series4.0any
msys.audit_series.define – Define an audit seriesname, type, interval, num_windows, [options]msys.audit_series4.0init
msys.audit_series.remove_item – Removes a counter from a named seriesname, [key]msys.audit_series4.0any
msys.av.engines – Returns a list of configured engine names in a table msys.av4.0data, data_spool, data_spool_each_rcpt
msys.av.scan – This function performs a virus scan[av_engine_name], [msg], [validate_context]msys.av4.0data, data_spool, data_spool_each_rcpt
msys.av.scan_part – This function takes an optional msg (msys.core:_ec_message), an optional engine name and performs a virus scan on a specific partmsg_part, [av_engine_name], [validate_context]msys.av4.0data, data_spool, data_spool_each_rcpt
msys.base64.decode – Decode a base64 encoded stringencoded_text, [charset]msys.base644.0any
msys.base64.encode – Base64-encode a stringoriginal, [fold], [charset]msys.base644.0any
msys.bounce.classify – Create a bounce classification for a messagemsgmsys.bounce4.0data, data_spool, data_spool_each_rcpt, set_binding
msys.bounce.classify_smtp_response – Create a bounce classification from SMTP response text and domain nameresponse_text, domainmsys.bounce4.0any
msys.brightmail.scan – Use Brightmail to scan messagesmsg, accept, vctxmsys.brightmail4.0data, data_spool, data_spool_each_rcpt
msys.cast – Cast an object to the specified classobject, classnamestringmsys4.0any
msys.cidr.define – Define a named CIDR objectname, optionsmsys.cidr4.0init
msys.cidr.query – Look up address against the named CIDRname, [address]msys.cidr4.0any
msys.cidr.reload – Refreshes CIDRs of type 'datasource' and 'rbldnsd'namemsys.cidr4.0any
msys.cloudmark.analyze – Analyze a message using Cloudmarkhdr, [msg], [vctx]msys.cloudmark4.0data, data_spool, data_spool_each_rcpt
msys.cloudmark.score – Scan messages using Cloudmark[msg], [accept], [vctx]msys.cloudmark4.0data, data_spool, data_spool_each_rcpt
msys.commtouch.diagnose – Scan message using Commtouch[msg], [accept], [vctx]msys.commtouch4.0data, data_spool, data_spool_each_rcpt
msys.config – Set or get configuration valuesaction, parametersmsys4.0any
msys.core.dns_get_domain – Get a domain recorddomainmsys.core4.0any
msys.core.get_now_ts – Get the current time msys.core4.0any
msys.core.io_wrapper_open – Open a handle to a resourcefilename, [options], [mode]msys.core4.0any
msys.core.mail_queue_delay_domain – Add a domain record to the delayed queuedr, notemsys.core4.0any
msys.core.string_new – Create an ec_string data type msys.core4.0any
msys.counter.add – Add to the current value of the specified counterobject_or_path, deltamsys.counter4.0any – Increment a counterobject_or_pathmsys.counter4.0any – Create a counter objectcounter_path, [semantics]msys.counter4.0any – Read the specified counterobject_or_pathmsys.counter4.0any
msys.counter.reset – Reset a counterobject_or_pathmsys.counter4.0any
msys.counter.unlink – Unlink a countercounter_pathmsys.counter4.0any
msys.db.execute – Executes a query that is not expected to return data (such as an insert or an update query)cachename, query, [queryparams], [options]msys.db4.0any
msys.db.fetch_row – If successful, return the first row of the query result as a tablecachename, query, [queryparams], [options]msys.db4.0any
msys.db.query – Query a datasourcecachename, query, [queryparams], [options]msys.db4.0any – Get the current message from the session contextsessmsys.delivery4.0http_response_eval
msys.dnsLookup – Perform a DNS lookupname, [recordtype], [options]msys4.0any
msys.dumper.Dumper – Dump information about an objectresmsys.dumper4.0any
msys.expandMacro – Expand macros (such as sieve, spf and custom_logger macros)stringmsys4.0any
msys.expurgate.scan – Scan using the Eleven antivirus enginemsg, accept, vctxmsys.expurgate4.0data, data_spool, data_spool_each_rcpt
msys.gauge_cache.dec – Decrements the value associated with keystring in the named cachecachename, keystringmsys.gauge_cache4.0any
msys.gauge_cache.define – Create a cache that can be used to maintain a set of countersname, maxelems, ttl, [replicated]msys.gauge_cache4.0any
msys.gauge_cache.get – Looks up the value associated with keystring in the named cachecachename, keystringmsys.gauge_cache4.0any – Increments the value associated with keystring in the named cachecachename, keystringmsys.gauge_cache4.0any
msys.gauge_cache.remove_item – Removes the value associated with keystring from the named cachecachename, keystringmsys.gauge_cache4.0any
msys.gcm.gcm_classify_error – Determine the delivery status of the "DLV_Response_Status" variablestatusmsys.gcm4.0gcm_response_eval, http_response_eval, msg_dispose
msys.gcm.gcm_get_result_error_code – Get the error code from the response results errorerrormsys.gcm4.0gcm_response_eval, http_response_eval, msg_dispose
msys.getClassMetaTable – Returns the metatable for the named classclassnamestringmsys4.0any – Create an HTTP client msys.http.client4.0any
msys.httpclnt.http_status_classifier – Determine the delivery status of the "DLV_Response_Status" variablestatusmsys.httpclnt4.0http_response_eval
msys.httpsrv.register – Register a Lua function as an HTTP endpoint  4.0 
msys.idn.to_idn – Attempts to convert the domain to the IDN formatnamemsys.idn4.2any
msys.idn.to_utf8 – Converts an IDN formatted string to unicodenamemsys.idn4.2any
msys.lock – The current running OS level thread obtains a lock on the named mutexmutexnamemsys4.0any
msys.mstore.load – Retrieve a message from Riak data storagebucket_id, msgidmsys.mstore4.0SMPP
msys.os.statvfs_read – Request a snapshot of the streampathmsys.os4.0any
msys.os.statvfs_subscribe – Provide a "stream" for statvfs updatespath, intervalmsys.os4.0any
msys.parseRFC2822Addresses – Parse the address string per the address parsing rules defined in RFC2822addressstring, componentmsys4.0data, data_spool, data_spool_each_rcpt
msys.pcre.match – Perform a PCRE regex match operationstr, patternmsys.pcre4.0any
msys.pcre.replace – Perform a PCRE replace operationsubject, pattern, replacementmsys.pcre4.0any
msys.pcre.split – Perform a PCRE split operationsubject, patternmsys.pcre4.0any
msys.qp.decode – Decode a quoted-printable messageencoded_txt, [charset]msys.qp4.0any
msys.qp.encode – Quoted-printable encode a stringoriginal, [charset], [dotstuffing]msys.qp4.0any
msys.readfile – Read the entire contents of the specified file or URIfilename_or_urimsys4.0any
msys.registerAuth – Register an authentication/authorization scheme that can be used for SMTP or control channel authenticationschemename, authtablemsys4.0init
msys.registerControl – Register a command with the control channel subsystemprefix, closuremsys4.0init
msys.registerModule – Registers a Lua module with the systemname, functablemsys4.0any
msys.rfc3464.compute_delivery_status – Generate RFC3464 compliant delivery status headersmsg, actionmsys.rfc34644.0any
msys.rfc3464.compute_delivery_status_string – Generate RFC3464 compliant delivery status headersresponse_textmsys.rfc34644.0any
msys.rfc3464.create_mdn – Generate an MDN from a messagemsg, actionmsys.rfc34644.0any
msys.rfc3464.extract_delivery_status – Return a table of parsed email headersmsgmsys.rfc34644.0any
msys.rfc3464.send_mdn – Generate and enqueue an MDNmsg, actionmsys.rfc34644.0any
msys.runInPool – Run a function in a separate threadpoolpool, closure, [...]msys4.0any
msys.sleep – When called in the scheduler thread, suspend the current session for the specified durationduration_in_secondsmsys4.0any
msys.snmpTrap – Issue an SNMP traptraptablemsys4.0any
msys.symantec_beik.scan – Scan using BEIKmsg, vctxmsys.symantec_beik4.0data, data_spool, data_spool_each_rcpt
msys.threadpool.count – Returns the current number of thread pools msys.threadpool4.0any
msys.threadpool.find – Finds a thread pool name from a job class ID or a job class ID from a thread pool name[threadpoolname], [jobclassID]msys.threadpool4.0any
msys.threadpool.stat – Return stats regarding a threadpool[threadpoolname], [jobclassID]msys.threadpool4.0any
msys.timer.after – Execute closure after a given length of timedelta, closure, [name]msys.timer4.0any – Execute closure at a given timenumber, closure, [name]msys.timer4.0any
msys.timer.every – Execute closure every intervalinterval, closure, [name]msys.timer4.0any
msys.tls_params.set - Set a tls parameter string on a per connection basistls_params, param, valmsys.tls_params4.4any
msys.type – Return the type name of the supplied parameterparametermsys4.0any
msys.unlock – Releases a lock obtained via msys.lockmutexnamemsys4.0any – This function requires module "dk_validate". "msg" is a mail message. "ctx" is the validation context. It returns the responsible domain for the current messagemsg, ctxmsys.validate.dk4.0data, data_spool, data_spool_each_rcpt – Sign a message using a Domain Keymsg, ctx, optionsmsys.validate.dk4.0core_data_validation
msys.validate.opendkim.get_num_sigs – Return the number of DKIM signaturesdkimmsys.validate.opendkim4.0data, data_spool, data_spool_each_rcpt
msys.validate.opendkim.get_sig – Get a signature from a DKIM objectdkim, [num]msys.validate.opendkim4.0data, data_spool, data_spool_each_rcpt
msys.validate.opendkim.get_sig_canons – Fetch the canonicalizers used for a DKIM signaturedkim_sigmsys.validate.opendkim4.0data, data_spool, data_spool_each_rcpt
msys.validate.opendkim.get_sig_domain – Fetch the signing domain from a DKIM_SIGINFO objectdkim_sigmsys.validate.opendkim4.0data, data_spool, data_spool_each_rcpt
msys.validate.opendkim.get_sig_errorstr – Fetch the error associated with a DKIM signaturedkim_sigmsys.validate.opendkim4.0data, data_spool, data_spool_each_rcpt
msys.validate.opendkim.get_sig_flags – Fetch the flags associated with a DKIM signaturedkim_sigmsys.validate.opendkim4.0data, data_spool, data_spool_each_rcpt
msys.validate.opendkim.get_sig_hdrsigned – Determine whether a given header was signeddkim_sig, header_namemsys.validate.opendkim4.0data, data_spool, data_spool_each_rcpt
msys.validate.opendkim.get_sig_identity – Fetch the identity associated with a DKIM signaturedkim, dkim_sigmsys.validate.opendkim4.0data, data_spool, data_spool_each_rcpt
msys.validate.opendkim.get_sig_keysize – Fetch the size of the key used to generate a DKIM signaturedkim_sigmsys.validate.opendkim4.0data, data_spool, data_spool_each_rcpt
msys.validate.opendkim.get_sig_selector – Fetch the selector associated with a DKIM signaturedkim_sigmsys.validate.opendkim4.0data, data_spool, data_spool_each_rcpt
msys.validate.opendkim.get_sig_signalg – Return the signing algorithm as a stringdkim_sigmsys.validate.opendkim4.0data, data_spool, data_spool_each_rcpt
msys.validate.opendkim.sign – Sign a message using OpenDKIMmsg, vctx, [options]msys.validate.opendkim4.0core_final_validation
msys.validate.opendkim.verify – Verify an DKIM signaturemmsys.validate.opendkim4.0data, data_spool, data_spool_each_rcpt
sess:request_add_header – Set the header of an HTTP sessionheader, value, replacemsys.httpclnt4.0http_request_eval
sess:request_delete_header – Delete a header from an HTTP sessionheadermsys.httpclnt4.0http_request_eval
sess:request_finalize – Finalize changes to an HTTP requestupdatemsys.httpclnt4.0http_request_eval
sess:request_set_body – Set the body of an HTTP sessionrequestmsys.httpclnt4.0http_request_eval
session:request_url_get – Get the request URL  4.0 
session:response_status_set_std – Set the HTTP status for the session response  4.0 
thread.mutex – Create a new mutex[type]thread4.0any
vctx:add_recipient – Adds address (which may be a table representing multiple addresses) to the recipient list for the inbound sessionaddressmsys.extended.vctx4.0data, data_spool, data_spool_each_rcpt, rcptto
vctx:disconnect – Disconnect the current session[code], [message]msys.core4.0any
vctx:get – Get the value of a context variabletype, keymsys.core4.0any
vctx:recipient_list – Return or set the current recipient list[addresses]msys.extended.vctx4.0 
vctx:remove_recipient – Removes an address (which may be a table representing multiple addresses) from the recipient listaddressmsys.extended.vctx4.0data, data_spool, data_spool_each_rcpt, mailfrom, rcptto
vctx:set – Set the value of a context variabletype, key, valuemsys.core4.0any
vctx:set_code – Sets the inbound disposition and response messagecodenum, messagemsys.core4.0any
vctx:tarpit – Issues a time cost on the inbound session, if supported by the listener (currently only SMTP supports this)intervalmsys.extended.vctx4.0connect
Was this page helpful?