Skip to main content

ClamAV

ClamAV is an open-source antivirus engine for detecting trojans, viruses, malware & other malicious threats. This plugin provide a bridge between the clamd daemon and your vSMTP service.

Usage

In this example, we will setup the ClamAV plugin to be used in the Working service. First, create a the bridge in an isolated rhai module.

// /etc/vsmtp/working/services/antivirus.rhai
import "plugins/libclamav_plugin" as clamav;

export const bridge = clamav::connect(#{
// The socket where clamd listens for connections.
address: "172.23.0.3:3310",
});

Then scan any email from your rules.

// /etc/vsmtp/working/script.rhai
import "services/antivirus.rhai" as antivirus;

fn on_post_queue(ctx) {
ctx.run([
// Rule that stores the email in a `virus` quarantine folder
// if the email is compromised.
rule "run antivirus" |ctx| {
if antivirus::bridge.scan(ctx) {
status::quarantine("virus")
} else {
status::success()
}
}

]);
}