Filtering Reference
This section reference all Rhai functions used through the rule engine and vSMTP configuration. Those functions are split by modules.
They list:
- All standard functions available for email filtering. (referred by the
fn
keyword) - Operators. (referred by the
op
keyword) - Objects getters. (referred by the
get
keyword) - Objects setters. (referred by the
set
keyword)
Documentation
Documentation for each function is written using markdown, and is split between sections (tabs):
Section | Description |
---|---|
Args | Arguments to pass to the function. |
Return | Value that the function returns. |
SMTP Stages | SMTP stages where this function can be called from. |
Note | Additional comments for the function. |
Examples | Code examples using the function. |
Errors | Errors that can happen during the execution of the function. |
A function that is marked with the Errors
section can fail. (It can throw a Rhai exception)
Exceptions stops the evaluation of the rule engine and return a deny code.
To handle exceptions, you can use the try catch
statement in Rhai.
Dynamic objects
Rhai uses the concept of dynamic objects, which means that some functions can take any parameter types or return anything.
fn my_function(arg1: ?) -> ? {
return arg1;
}
As you can see, dynamic values are marked with the ?
symbol in the documentation. This means that my_function
can be passed
any type of parameter, and will return any object type.
my_function("hello, world!"); // using a string, returns the "hello, world!" string.
my_function(42); // using a number, returns the 42 number.
// ...
Checkout the Rhai Dynamic reference for more details.
Example
Here is an example of how a function will be rendered in the documentation.
fn
my_function
fn hello_world(name: String) -> String
- Description
- Args
- Return
- SMTP stages
- Example
This is the description section of the hello_world
function.
This function returns a "hello world!" string with the name passed as parameter.
name
- The name to display next to the "hello world" string.
String
- A "hello world!" string.
All of them!
let hello_world = hello_world("John"); // Returns "Hello World, John!".