IMAP icon

IMAP

Retrieve emails via IMAP

Overview

This node connects to an IMAP email server to retrieve multiple emails from a specified mailbox. It supports filtering emails by date range, flags (such as answered, deleted, draft, flagged, recent, seen), and various search filters like sender, recipient, subject, and text content. Users can specify which parts of the message to include in the output, such as text content, HTML content, attachments info, flags, size, body structure, and headers.

Common scenarios for this node include:

  • Automating email processing workflows by fetching new or specific emails.
  • Archiving or analyzing emails based on custom criteria.
  • Integrating email data into other systems or databases.

Practical example: A user wants to fetch all unread emails from the "INBOX" received since a certain date, including their text content and attachments info, to process them further in an automation workflow.

Properties

Name Meaning
Credential Type Choose between using credentials defined in this node or reusing existing credentials from an N8N IMAP Trigger node.
Mailbox Select the mailbox folder to fetch emails from. Can be chosen from a list or specified by full path (e.g., "INBOX").
Date Range Optional start ("Since") and end ("Before") dates to filter emails by their received date.
Flags Filter emails by flags: whether they are answered, deleted, draft, flagged, recent, or seen (read). For "Is Seen", true returns only seen emails; false returns only unseen emails.
Search Filters Additional case-insensitive filters combined with AND logic. Includes filtering by BCC, CC, From, Subject, Text content, To, and specific UIDs (comma-separated list).
Include Message Parts Specify which parts of the email to include in the output. Options: Text Content, HTML Content, Attachments Info, Flags, Size, Body Structure, Headers.
Include All Headers If headers are included, choose whether to include all headers or only specific ones.
Headers to Include Comma-separated list of specific headers to include if not including all headers (e.g., "received,authentication-results,return-path").

Output

The node outputs an array of JSON objects representing the fetched emails. Each email object may contain:

  • Standard email fields such as sender, recipients, subject, date, and UID.
  • Selected message parts depending on the "Include Message Parts" property, e.g.:
    • textContent: plain text body of the email.
    • htmlContent: HTML body of the email.
    • attachmentsInfo: metadata about attachments.
    • flags: email flags like seen, answered, etc.
    • size: size of the email.
    • bodyStructure: detailed MIME structure.
    • headers: either all headers or selected headers as specified.

If binary data (like attachments) is included, it will be represented accordingly but is not detailed here.

Dependencies

  • Requires valid IMAP credentials to connect to the email server. Credentials can be provided directly in the node or reused from an existing IMAP trigger node.
  • The node uses an internal IMAP client library to communicate with the mail server.
  • No additional external services are required beyond the IMAP server itself.
  • Environment variable N8N_LOG_LEVEL can influence logging verbosity (debug mode enables more detailed logs).

Troubleshooting

  • Connection failures: Errors during connection usually indicate incorrect credentials, wrong server settings, or network issues. Verify credentials and server accessibility.
  • No emails returned: Check that the mailbox path is correct and that filters (date range, flags, search filters) are not too restrictive.
  • Unknown operation or resource errors: Ensure the node's Resource is set to "Email" and Operation to "Get Many" (or "getEmailsList" internally).
  • Error messages containing responseText or unknown error: These often come from the IMAP server or network layer. Inspect the error message for clues and verify server status.
  • Timeouts or slow responses: Large mailboxes or complex filters may cause delays. Consider narrowing filters or increasing timeout settings if available.

Links and References


This summary is based solely on static analysis of the provided source code and property definitions.

Discussion