Path variables
Three settings are paths built for each email, and accept variables written as ${name}:
cachePath, the temporary file of each email;filenameof thefileoutput;storage.pathof theawsandgcpoutputs.
Variables
Section titled “Variables”The example values are those of a session opened on 30 November 2026 at 09:15:02.117 UTC.
| Variable | Value | Example |
|---|---|---|
${iso8601} |
Time the connection was opened, ISO 8601 without separators | 20261130T091502117Z |
${timestamp} |
Same time, as UNIX milliseconds | 1796030102117 |
${id} |
Session id given by the SMTP server, unique per connection | 3ieb2d4f6ng7jgor |
${from} |
Envelope sender (MAIL FROM) |
alice@example.com |
${to} |
Envelope recipients (RCPT TO) the flow accepted, comma separated |
support@mydomain.com,billing@mydomain.com |
${messageId} |
Message-ID header of the email |
<4f1c2e@mail.example.com> |
${subject} |
Subject of the email | Invoice 2026-11 |
${attachment} |
File name of the attachment, only for storage.type: attachments |
invoice.pdf |
${attachment}falls back toattachment_<n>(attachment_0,attachment_1…) for an attachment without a file name.- In
cachePath, the email is not parsed yet:${messageId}and${subject}are empty, and${to}lists every recipient of the email, not those of one flow. - An unknown variable is left as written.
Values are inserted as they are, without escaping. A subject or a Message-ID can contain /, spaces or <>:
build file names and keys from ${iso8601}, ${timestamp} and ${id}, and use the other variables with care.
${iso8601}, ${timestamp} and ${id} belong to the connection: two emails sent on the same connection get the
same values, so with the file output’s default name, ${iso8601}.eml, the second one replaces the first. If
your clients send several emails per connection, add a value that differs per email, such as ${messageId}.
Example
Section titled “Example”{ "$schema": "https://raw.githubusercontent.com/loopingz/smtp-relay/main/config.schema.json", "flows": { "inbound": { "filters": [{ "type": "whitelist", "to": ["regexp:.*@mydomain.com"] }], "outputs": [ // ./received_emails/20261130T091502117Z_3ieb2d4f6ng7jgor.eml { "type": "file", "path": "./received_emails/", "filename": "${iso8601}_${id}.eml" }, // attachments/3ieb2d4f6ng7jgor/invoice.pdf in the bucket { "type": "aws", "storage": { "bucket": "mydomain-attachments", "type": "attachments", "path": "attachments/${id}/${attachment}" } } ] } }, "cachePath": "/tmp/smtp-relay/${timestamp}_${id}.eml", "options": { "authOptional": true }}