nodemailer
The nodemailer output sends each email through an SMTP server with the
nodemailer library: your provider’s relay, a company mail server, Gmail, or another
smtp-relay.
What is sent
Section titled “What is sent”The email is rebuilt from the parsed message: From, To and Cc headers, subject, text and HTML bodies, and
attachments. The other headers of the received email are not forwarded; nodemailer writes its own (Date,
Message-ID…).
It is delivered to the recipients the flow accepted (RCPT TO), including blind copies, and not to the To and Cc
headers: two flows that split the recipients of one email each deliver only to their own. The envelope sender is
the address of the received From header, even when override changes from.
override forces message fields on every email, for example a fixed from or extra headers. When override
sets to, cc, bcc or envelope, it takes over the delivery: nodemailer then sends to the recipients those
fields give, not to the flow’s.
DKIM signing
Section titled “DKIM signing”dkims holds one signing key per sender domain. The domain of the envelope sender (MAIL FROM) selects the
entry; emails from other domains are sent unsigned. The DKIM guide shows how to create a key and
publish it.
When to use it
Section titled “When to use it”- Relay the emails of applications that only speak SMTP to a provider that needs authentication or TLS, keeping the credentials in one place.
- Sign outgoing emails with DKIM.
- Forward emails to another SMTP server while storing a copy with another output.
Options
Section titled “Options”Examples
Section titled “Examples”Forward emails from the local machine to another SMTP server on localhost:10026 (for example a second
smtp-relay running fake-smtp-log.jsonc):
// Can replace fakeSMTP.jar{ "$schema": "https://raw.githubusercontent.com/loopingz/smtp-relay/main/config.schema.json", "flows": { "localhost": { "filters": [ // Allow only localhost { "type": "whitelist", "ips": ["127.0.0.1"] } ], "outputs": [ { // We just log to the console "type": "nodemailer", "nodemailer": { "host": "localhost", "port": 10026, "secure": false, "auth": { "user": "user", "pass": "pass" }, "tls": { "rejectUnauthorized": false } } } ] } }, "options": { "disableReverseLookup": false, // Do not require auth "authOptional": true }}Send through a provider with a connection URL, sign the emails of example.com, and add a header:
{ "$schema": "https://raw.githubusercontent.com/loopingz/smtp-relay/main/config.schema.json", "flows": { "outgoing": { "filters": [{ "type": "whitelist", "subnets": ["10.0.0.0/8"], "from": ["regexp:.*@example.com"] }], "outputs": [ { "type": "nodemailer", "nodemailer": "smtps://relay-user:relay-password@smtp.provider.example:465", "override": { "headers": { "X-Relayed-By": "smtp-relay" } }, "dkims": { "example.com": { "keySelector": "default", "privateKey": "-----BEGIN PRIVATE KEY-----\nMIIEvQ...\n-----END PRIVATE KEY-----\n" } } } ] } }, "bind": "0.0.0.0", "options": { "authOptional": true }}