Skip to main content

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):

SectionDescription
ArgsArguments to pass to the function.
ReturnValue that the function returns.
SMTP StagesSMTP stages where this function can be called from.
NoteAdditional comments for the function.
ExamplesCode examples using the function.
ErrorsErrors that can happen during the execution of the function.
Errors

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.

A function with a dynamic parameter and dynamic return value
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.

calling my_function with mutliple parameters types
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

This is the description section of the hello_world function.

This function returns a "hello world!" string with the name passed as parameter.