Skip to content

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.

  • 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.

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.

OptionTypeDescription
filenamestring
default "${iso8601}.eml"

Name of the file within path

Variables written as ${name} are replaced: ${iso8601}, ${timestamp}, ${id}, ${messageId}, ${from}, ${subject} and ${to}

namestring

Name of the component, used in the logs and the output metrics, defaults to <type>_<position in the list>

pathrequiredstring

Folder to store the emails in, created if it does not exist

typerequired"file"

Type of the component

Accept emails from the local machine and store them in ./received_emails/:

configs/fake-smtp.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": [
{
"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):

file.yaml
$schema: https://raw.githubusercontent.com/loopingz/smtp-relay/main/config.schema.json
flows:
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