file
The file output copies the raw email, as received, to a folder: one .eml file per email, which any mail
client can open. The folder is created at startup if it does not exist.
The file is the email after the server’s header changes (mailHeaders, x-smtp-relay by default, see
options) and the headers added by mail-auth.
When to use it
Section titled “When to use it”- A local debug inbox: point an application under development at smtp-relay and read what it sends, without any email leaving your machine.
- Keeping a copy of every email on disk next to another output.
File names
Section titled “File names”filename is the name of the file in path, ${iso8601}.eml by default, and accepts the
path variables. ${iso8601} is the time the connection was opened: when a client sends
several emails on one connection, give a name that differs per email, for example
${iso8601}_${messageId}.eml, or the later ones replace the first.
Options
Section titled “Options”Example
Section titled “Example”Accept emails from the local machine and store them in ./received_emails/:
// 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": [ { "type": "file", // Send store files in emails/ "path": "./received_emails/" } ] } }, "options": { "disableReverseLookup": false, // Do not require auth "authOptional": true }}A folder for the support address, with the session id in the names, and one with every email sent from the local machine (an email to the support address from the local machine lands in both):
$schema: https://raw.githubusercontent.com/loopingz/smtp-relay/main/config.schema.jsonflows: support: filters: - type: whitelist to: ["support@example.com"] outputs: - type: file path: ./mail/support/ filename: ${iso8601}_${id}.eml local: filters: - type: whitelist ips: ["127.0.0.1"] outputs: - type: file path: ./mail/all/options: authOptional: true