Incoming messages
The doe-family.com/incoming.vsl
script is run when the sender of the domain is not doe-family.com
and that recipients domains are doe-family.com
.
Thus, when this script is run, all recipients are guaranteed to have the doe-family.com
domain. We can then deliver emails locally using the Mailbox protocol.
import "objects/family" as family;
#{
delivery: [
action "setup delivery" || {
for rcpt in ctx::rcpt_list() {
// Deliver locally using Mailbox if the recipient is from Doe's family.
if rcpt in family::addresses { transport::mailbox(rcpt) }
}
}
],
}
doe-family.com/incoming.vsl
Jane wants a blind copy of her Jennyβs messages. Letβs create a Rhai function that does exactly that.
/etc/vsmtp
β£ vsmtp.vsl
β£ filter.vsl
β£ conf.d/
β β£ config.vsl
β β *.vsl
β£ domain-available/
β β doe-family.com/
+β β£ bcc.vsl
β β£ incoming.vsl
β β£ outgoing.vsl
β β internal.vsl
β£ domain-enabled/
β β example.com -> ...
β objects/
β family.vsl
adding a new script to the domain
import "objects/family" as family;
fn bcc_jenny() {
// add Jane as a blind carbon copy if the current recipient is Jenny.
if ctx::rcpt() == family::jenny {
bcc(family::jane)
}
}
doe-family.com/bcc.vsl
Now, letβs plug this function to our filtering rules by importing the bcc.vsl
script.
+ import "domain-available/doe-family.com/bcc" as bcc;
import "objects/family" as family;
#{
+ rcpt: [
+ action "bcc jenny" || bcc::bcc_jenny(),
+ ],
delivery: [
action "setup delivery" || {
for rcpt in ctx::rcpt_list() {
// Deliver locally using Mailbox if the recipient is from Doe's family.
if rcpt in family::family_addr { transport::mailbox(rcpt) }
}
}
],
}
doe-family.com/incoming.vsl
With Rhai modules and functions, it becomes easy to reuse code across different rules.