Skip to main content


The Lightweight Directory Access Protocol (LDAP) is an application protocol for accessing distributed directory information services. This plugin provide a bridge between the LDAP databases.


In this example, we will setup the plugin to be used in the SMTP SMTP Receiver service. First, create a connection pool to the LDAP database.

// /etc/vsmtp/smtp-receiver/services/db.rhai
// Import the plugin stored in the `plugins` directory.
import "plugins/libldap_plugin" as ldap;

export const directory = ldap::connect(#{
// Url poiting to the database.
url: "ldap:// ",
// Timeout allowed for each LDAP query.
timeout: "1m",
// Number of connections to open in the pool.
connections: 10,
import "services/db" as db;

fn on_rcpt_to(ctx) {[
rule "check recipient in directory" || {
let recipient = ctx.rcpt();
let address = recipient.domain();
let user = recipient.local_part();

let results =
// Search the whole tree.
// Match on the user id and address.
// Get all attributes from the entries.

// Use the `results` variable to filter the
// recipient.