Mandala
Tools

IMAP Blocks

Retrieve emails on-demand and download attachments using the IMAP protocol.

IMAP (Internet Message Access Protocol) is the standard protocol for fetching emails from a remote server. In addition to the IMAP Email Trigger, Mandala offers two action blocks for interacting with IMAP mailboxes at any step of a workflow.


1. IMAP: Get Attachments Block (imap_fetch_attachments)

The IMAP: Get Attachments block connects to a mailbox and downloads files attached to a specific email. It uses a persistent message UID to retrieve the attachments, making it perfect for chaining after an IMAP trigger.

Configuration Inputs

ParameterTypeRequiredDefaultDescription
messageUidstringYes-The IMAP message UID (e.g. wire from {{trigger.email.id}})
imapHoststringYes-IMAP server hostname (e.g. imap.gmail.com)
imapPortstringYes993IMAP server port
imapSecuredropdownYesSSLSecurity mode: SSL, TLS, or None
imapUsernamestringYes-Your email address
imapPasswordstringYes-Your password or App Password
mailboxstringNoINBOXFolder where the message resides

Outputs

  • attachments: An array of base64-encoded attachment objects:
    [
      {
        "name": "invoice_123.pdf",
        "mimeType": "application/pdf",
        "data": "JVBERi0xLjQKJdPr6g...",
        "size": 45120
      }
    ]
  • count: Number of attachments found.
  • messageUid: The target email's UID.

2. IMAP Standalone Block (imap)

The standalone IMAP block retrieves and filters emails on-demand at a specific point in your workflow execution.

Configuration Inputs

ParameterTypeRequiredDefaultDescription
imapHoststringYes-IMAP server hostname
imapPortstringYes993IMAP server port
imapSecuredropdownYesSSLSecurity mode: SSL, TLS, or None
imapUsernamestringYes-Your email username
imapPasswordstringYes-Password or App Password
mailboxstringNoINBOXFolder to fetch emails from
filterUnreadOnlyswitchNofalseRetrieve only unread messages
markAsReadswitchNofalseMark emails as read after processing
includeAttachmentsswitchNofalseWhether to parse and include attachments
maxResultsnumberNo10Maximum number of emails to retrieve
filterFromstringNo-Filter emails by sender address
filterSubjectstringNo-Filter emails by subject keyword

Outputs

  • emails: Array of retrieved emails:
    [
      {
        "id": "12345", 
        "subject": "June Invoice",
        "from": "billing@company.com",
        "to": "you@domain.com",
        "cc": "finance@domain.com",
        "date": "2026-06-16T10:15:30.000Z",
        "bodyText": "Hello...",
        "bodyHtml": "<p>Hello...</p>",
        "hasAttachments": false,
        "attachments": []
      }
    ]
  • count: Total number of emails retrieved.

Typical Workflow: Email Attachment Parser

Here is the recommended setup to automatically process incoming email attachments:

graph TD
  A["IMAP Trigger<br>(/triggers/imap)"] -->|ID: trigger.email.id| B["IMAP: Get Attachments<br>(downloads base64 files)"]
  B -->|Data: attachments[0].data| C["Parser Block<br>(Processes file)"]

Wiring Instructions:

  1. Configure the IMAP Trigger to listen for emails.
  2. Connect it to IMAP: Get Attachments. Wire Message UID to:
    {{trigger.email.id}}
  3. Pass the file data to your Parser block using:
    {{imap_fetch_attachments.attachments[0].data}}
IMAP Blocks