whitelist
The whitelist filter accepts or refuses at three steps of the SMTP session, each driven by its own lists:
| Step | Lists | Accepts when |
|---|---|---|
| connection | ips, subnets, domains |
the client address matches ips or subnets, or its hostname matches domains |
MAIL FROM |
from |
the envelope sender matches from |
RCPT TO |
to |
the recipient matches to (each recipient is judged on its own) |
A list that is not set gives no answer at its step. A whitelist with only to says nothing about the client or
the sender: it accepts or refuses each recipient.
When to use it
Section titled “When to use it”- Accept only the machines that may send, by IP address or subnet: a local debug server, a relay inside a private network or a cluster.
- Route by recipient: one flow per address or domain (see routing). A recipient refused by
every flow is refused at
RCPT TO. - Restrict the senders of a relay, for example to the domains of your SES identities.
Matching
Section titled “Matching”- A plain entry is compared with the whole value, ignoring case:
support@example.com. - An entry starting with
regexp:is a regular expression that must match the whole value:regexp:.*@example.com(smtp-relay adds the^and$anchors). Regular expressions are case sensitive. An invalid regular expression stops the server at startup. subnetsentries are in CIDR notation, IPv4 or IPv6:10.0.0.0/8,fd00::/8.domainsis compared with the client hostname found by reverse DNS lookup of its address. Withoptions.disableReverseLookup: truethere is no lookup, and the hostname is the address in brackets.
regexp:.* accepts anything: "ips": ["regexp:.*"] lets every client connect.
Options
Section titled “Options”Example
Section titled “Example”A debug server for Docker, accepting clients from the usual Docker bridge range and from the container itself:
// Can replace fakeSMTP.jar{ "$schema": "https://raw.githubusercontent.com/loopingz/smtp-relay/main/config.schema.json", "flows": { "localhost": { "filters": [ // Allow only localhost { "type": "whitelist", // Docker subnet are usually on class b network "subnets": ["172.16.0.0/12", "127.0.0.1/32"] } ], "outputs": [ { "type": "file", // Send store files in emails/ "path": "./received_emails/" } ] } }, // Listen on every interface so the server is reachable from outside its container "bind": "0.0.0.0", "options": { "disableReverseLookup": false, // Do not require auth "authOptional": true }}Clients from a private network, and only recipients of one domain:
$schema: https://raw.githubusercontent.com/loopingz/smtp-relay/main/config.schema.jsonflows: inbound: filters: - type: whitelist subnets: ["10.0.0.0/8"] to: ["regexp:.*@mydomain.com"] outputs: - type: file path: ./received_emails/bind: 0.0.0.0options: authOptional: trueWith the default AND operator, a client outside 10.0.0.0/8 is refused at connection, and a recipient outside
mydomain.com is refused at RCPT TO.