Read Email Once

Reads new emails on trigger

Overview

The Read Email Once node connects to an IMAP email server and retrieves emails from the INBOX folder based on user-specified criteria. It allows users to fetch unread, read, or all emails, and optionally mark them as read after retrieval. This node is useful for automating workflows that need to process incoming emails only once, such as ticketing systems, notifications, or data extraction from email content.

Practical examples:

  • Fetching all unread support requests from a shared mailbox and marking them as read after processing.
  • Extracting order confirmations from a specific email account for further automation.
  • Monitoring a mailbox for new messages and triggering downstream n8n workflows.

Properties

Name Type Meaning
Kind Of Emails to Get options Specifies which emails to retrieve: Unread, Read, or All.
Mark As Read boolean If true, marks the retrieved emails as read after fetching.

Output

The node outputs an array of objects, each representing an email message. The structure of the json field in each output item mirrors the parsed email object returned by the mailparser library. Typical fields include:

{
  "json": {
    "subject": "Email subject",
    "from": { "value": [ { "address": "sender@example.com", "name": "Sender Name" } ] },
    "to": { "value": [ { "address": "recipient@example.com", "name": "Recipient Name" } ] },
    "date": "2024-06-01T12:34:56.000Z",
    "text": "Plain text body",
    "html": "<p>HTML body</p>",
    // ...other standard email fields
  }
}
  • If the email contains attachments, they may be included in the parsed object, but binary data is not directly output—only metadata about attachments.

Dependencies

  • IMAP Server: Requires access to an IMAP-compatible email server (e.g., Gmail, Outlook, custom mail servers).
  • Credentials: Needs valid credentials (host, port, secure, username, password) configured in n8n under the credential type readEmailOnceApi.
  • External Libraries: Uses imapflow for IMAP communication and mailparser for parsing email content.

Troubleshooting

Common Issues:

  • Authentication Errors: Incorrect username/password or server details will prevent connection. Double-check credentials and server configuration.
  • Mailbox Access Issues: If the specified mailbox (default: INBOX) does not exist or permissions are insufficient, the node will fail.
  • Network/Firewall Restrictions: Ensure n8n can reach the email server over the required port (usually 993 for secure IMAP).

Error Messages:

  • "There was an error with the Read Email OnceNode": Indicates a problem during email fetching or parsing. Check logs for more details; likely causes include invalid credentials, network issues, or unexpected mailbox state.
  • Connection Timeouts: May occur if the server is unreachable or slow to respond.

Resolution Steps:

  • Verify all credential fields.
  • Test connectivity to the IMAP server from the n8n host.
  • Ensure the mailbox exists and the user has appropriate permissions.

Links and References

Discussion