IMAP icon

IMAP

Retrieve emails via IMAP

Overview

This node retrieves multiple emails from an IMAP mailbox based on specified criteria. It is useful for scenarios where users need to fetch emails for processing, filtering, or analysis, such as automating email workflows, monitoring inboxes, or extracting email data for further use. For example, it can fetch all unread emails from a specific folder within a date range or filter emails by sender or subject.

Use Case Examples

  1. Fetch up to 50 recent unread emails from the INBOX mailbox.
  2. Retrieve emails flagged as important with specific subject keywords.
  3. Get emails received within a certain date range and containing attachments.

Properties

Name Meaning
Credential Type Selects the type of IMAP credentials to use for connecting to the mailbox.
Mailbox Specifies the mailbox folder path to retrieve emails from.
Date Range Filters emails by their received date, specifying start (Since) and end (Before) dates.
Flags Filters emails based on various IMAP flags such as answered, deleted, draft, flagged, recent, seen, and custom flags.
Search Filters Additional case-insensitive filters combined with AND logic to match emails by BCC, CC, From, Subject, Text, To, or specific UIDs.
Limit Maximum number of emails to return, helping to control memory usage and execution time.
Include Message Parts Specifies which parts of the email to include in the output, such as text content, HTML content, attachments info, flags, size, body structure, and headers.
Include All Headers Whether to include all headers in the output when headers are included.
Headers to Include Comma-separated list of specific headers to include if not including all headers.

Output

JSON

  • uid - Unique identifier of the email.
  • flags - Flags set on the email, such as seen, answered, flagged.
  • date - Date the email was received.
  • from - Sender's email address.
  • to - Recipient email addresses.
  • cc - CC recipient email addresses.
  • bcc - BCC recipient email addresses.
  • subject - Subject line of the email.
  • textContent - Plain text content of the email, if requested.
  • htmlContent - HTML content of the email, if requested.
  • attachmentsInfo - Information about attachments, if requested.
  • size - Size of the email, if requested.
  • bodyStructure - Structure of the email body, if requested.
  • headers - Email headers, either all or selected, if requested.

Dependencies

  • Requires IMAP credentials, either provided directly in the node or via an existing N8N IMAP Trigger node.

Troubleshooting

  • Connection failures due to incorrect IMAP credentials or network issues. Verify credentials and network connectivity.
  • Errors during email retrieval may occur if the mailbox path is incorrect or the mailbox is inaccessible.
  • Large result sets may cause memory or performance issues; use the Limit property to restrict the number of emails fetched.
  • If the node returns no data, check the search filters and flags to ensure they match existing emails.
  • Errors related to IMAP protocol or server responses are caught and logged; review error messages for specific issues.

Links

Discussion