IMAP icon

IMAP

Retrieve emails via IMAP

Actions6

Overview

The "Email: Download as EML" operation in this custom n8n IMAP node allows users to download a specific email from an IMAP mailbox in the standard EML file format. This is useful for archiving, forwarding, or processing emails outside of the mail server. The node can output the email either as binary data (for direct file handling) or as plain text within JSON.

Common scenarios:

  • Archiving important emails as .eml files.
  • Integrating with document management systems that require email records.
  • Forwarding or analyzing raw email content in automation workflows.

Practical example:
A user wants to automatically save all invoices received in their "INBOX/Invoices" folder as .eml files to cloud storage for compliance purposes.


Properties

Name Type Meaning
Credential Type options Selects which set of credentials to use for connecting to the IMAP server: either from this node or from an existing N8N IMAP Trigger node.
Mailbox resourceLocator Specifies the mailbox (folder) from which to download the email. Can be selected from a list or entered as a full path.
Email UID string The unique identifier (UID) of the email to download from the specified mailbox.
Output to Binary Data boolean Determines if the email should be output as binary data (EML file) or as plain text in JSON.
Put Output File in Field string (Required if outputting to binary) The name of the binary property where the EML file will be stored in the output.

Output

  • If "Output to Binary Data" is true:

    • The output contains a binary field (with the name specified in "Put Output File in Field") holding the downloaded EML file.
    • The binary data represents the raw email in EML format, suitable for saving or further processing.
  • If "Output to Binary Data" is false:

    • The output contains a JSON field with the email content as plain text (the raw EML content as a string).

Dependencies

  • IMAP Server Access: Requires valid IMAP credentials for the target email account.
  • n8n Credentials: Must configure either "IMAP" credentials on this node or reference credentials from an existing N8N IMAP Trigger node.
  • Environment Variables: Optionally respects N8N_LOG_LEVEL for debug logging.

Troubleshooting

Common issues:

  • Invalid Credentials: If the provided IMAP credentials are incorrect, the node will fail to connect and throw a connection error.
  • Incorrect Mailbox Path: Specifying a non-existent mailbox path will result in errors when attempting to access the mailbox.
  • Invalid Email UID: Providing a UID that does not exist in the selected mailbox will cause the operation to return no data or an error.
  • Binary Property Name Missing: If "Output to Binary Data" is enabled but "Put Output File in Field" is left empty, the node will not know where to place the binary data and may throw a validation error.

Error messages:

  • "Connection failed: ..." – Indicates issues connecting to the IMAP server; check credentials and network.
  • "Unknown operation ..." – The selected operation is not supported; ensure correct configuration.
  • "Operation ... returned no data" – The specified email UID was not found; verify the UID and mailbox.
  • "IMAP server reported errors: ..." – The IMAP server returned one or more errors; review the error details for resolution.

Links and References

Discussion