Basic configuration
vSMTP Configuration
Letβs build a vSMTP configuration step by step.
When installing vSMTP, the package manager creates the following basic configuration.
/etc/vsmtp
+β£ vsmtp.vsl
+β conf.d/
+ β config.vsl
vSMTP default configuration
Configure vSMTP
Modify the /etc/vsmtp/conf.d/config.vsl
file with this configuration:
fn on_config(config) {
// Name of the server.
config.server.name = "doe-family.com";
// addresses that the server will listen to.
// (change `192.168.1.254` for the desired address)
config.server.interfaces = #{
addr: ["192.168.1.254:25"],
addr_submission: ["192.168.1.254:587"],
addr_submissions: ["192.168.1.254:465"],
};
config
}
Configuring vSMTP
For complex configurations, it is recommended to split the file into Rhai modules.
To get an exhaustive list of parameters that can be changed in the configuration, see the Configuration Reference chapter.
The server can now listen and serve SMTP connections.
Filtering objects
Letβs define all the required objects for John Doeβs MTA. Those objects are used to configure vSMTP and simplify filtering rules.
Create the /etc/vsmtp/objects/family.vsl
file with following objects:
// Doe's family domain name.
export const domain = fqdn("doe-family.com");
// Mailboxes.
export const john = address("john.doe@doe-family.com");
export const jane = address("jane.doe@doe-family.com");
export const jimmy = address("jimmy.doe@doe-family.com");
export const jenny = address("jenny.doe@doe-family.com");
export const addresses = [john, jane, jimmy, jenny];
// Paths for quarantines.
export const virus_queue = "virus";
export const untrusted_queue = "untrusted";
// A user blacklist file
export const blacklist = file("domain-available/example.com/blacklist.txt", "fqdn");
Objects that will be used during filtering
See the Object chapter for more information.
Blacklist
Define a blacklist file at /etc/vsmtp/domain-available/example.com/blacklist.txt
with the following contents:
domain-spam.com
spam-domain.org
domain-spammers.com
foobar-spam-pro.org
Blacklist content
Listen and serve
The file structure of /etc/vsmtp
should now look like this.
/etc/vsmtp/
β£ vsmtp.vsl
β£ conf.d/
β β config.vsl
β£ domain-available/
+β β example.com/
+β β blacklist.txt
+β objects/
+ β family.vsl
Adding objects and the blacklist to the configuration directory
If no interface is specified, the server listens on localhost on port 25, 465 and 587. Remote connections are therefore refused.
$> sudo systemd restart vsmtp
$> telnet 192.168.1.254:25
# 220 doe-family.com Service ready
# 554 permanent problems with the remote server
Test by opening a connexion to the server