vSMTP feature set can be extended using plugins.

Plugins are dynamic libraries (.so files on Linux) that exposes vSL interfaces.


Plugin directory

Plugins are stored in the /etc/vsmtp/plugins directory.

  ┣ vsmtp.vsl
  ┃ conf.d/
  ┃  β”— ...
+ β”— plugins
+    ┣
+    β”— ...

To make things cleaner with Linux’s file system, it is recommended that plugins are stored in the /usr/lib/vsmtp directory, and symbolic links are used to link those libraries to the plugins directory.

  ┣ vsmtp.vsl
  ┃ conf.d/
  ┃  β”— ...
+ β”— plugins
+    ┣ -> /usr/lib/vsmtp/
+    β”— ...

Plugins are named using the libvsmtp-plugin-<name>-<vsmtp-version>.so nomenclature, with <name> begin the name of the plugin, and <vsmtp-version> the associated vSMTP version. Plugins must have the same version as the current vSMTP version to work correctly.

ln -s /usr/lib/vsmtp/ /etc/vsmtp/plugins/

Services directory

Some plugins create Rhai objects that use system resources like sockets or file descriptors. Constructing an instance of those objects can be costly.

Thus, it is HIGHLY recommended that objects created by plugins are declared inside .vsl files stored in the /etc/vsmtp/services directory. This way objects are initialized only once when vSMTP starts.

Here is an example:

  ┣ vsmtp.vsl
  ┣ filter.vsl
  ┣ conf.d/
  ┃     β”— config.vsl
  ┣ domain-available/
  ┃     β”—
  ┃       β”— ...
  ┣ domain-enabled/
  ┃     β”— -> ...
+ β”— services/
+       β”— command.vsl

Let’s define a command service that runs the echo command.

// Do not forget to use the `export` keyword when declaring
// the object to make it accessible trough `import`.
const echo = cmd::build(#{
    command: "echo",
    args: [ "-n", "executing a command from vSMTP!" ],

Creating a new command object in services/command.vsl

Check out the Command reference to get examples for the command plugin.

import "services/command" as command;

  connect: [
    action "use echo" ||,

Using the object in rules using Rhai's import statement