On this page
Sommatic Docs
Open portal

Read Email (IMAP)

Read emails from IMAP server.

View as Markdown
Open in
Input and output Available io.imap Version 1.0.0 Execution: async

Connects to an IMAP mailbox, searches one folder with IMAP criteria and returns the matching messages with subject, sender, date, raw text body and attributes; no match leaves through empty.

How it works

  1. Resolves the config. connection_id, box (default INBOX), searchCriteria (default ["UNSEEN"]) and markSeen (default true) fall back to the same keys of the incoming payload; an empty box or empty criteria array counts as not set.
  2. Resolves the credential: host, port (default 993) and tls (default true) from its config; username (or user) and password (or pass) from its secret. Authentication waits up to 10 s.
  3. Opens box, runs the search and fetches the HEADER and TEXT parts of every match. With markSeen, fetched messages are flagged as read.
  4. Maps each message to { subject, from, date, body, attributes } and closes the connection.
  5. At least one message leaves through out as { emails }; none leaves through empty with {}.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-read-invoices",
  "label": "Read invoice mailbox",
  "operator_slug": "io.imap",
  "operator_version": "1.0.0",
  "config": {
    "connection_id": "pi-credential-xxxx",
    "box": "INBOX",
    "searchCriteria": [
      "UNSEEN"
    ],
    "markSeen": true
  }
}

Configuration

connection_id string Required

Credential for the IMAP mail server. Accepts credentials of type `basic-auth` (username + password + host + port).

box string Optional

Default: INBOX

searchCriteria array Optional

Criteria like UNSEEN, ALL, or ['SINCE', date]

Default: ["UNSEEN"]

markSeen boolean Optional

Default: true

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

searchCriteria
IMAP search criteria as an array, for example ["UNSEEN"], ["ALL"] or ["UNSEEN", ["SINCE", "2026-11-01"]]. An empty array falls back to the payload, then to ["UNSEEN"].
markSeen
Only an explicit false keeps messages unread. With the default UNSEEN criteria, this is what keeps the next run from returning the same messages.
connection_id
Accepts basic-auth credentials. A value containing : or a JSON object is treated as a raw host:port for local tests, with the user and password read from the incoming payload.

Output ports

out default

The search matched at least one message. subject, from and date are the first value of each header; body is the raw TEXT part (MIME source for multipart messages); attributes holds the IMAP uid, flags and date.

Data
{
  "emails": [
    {
      "subject": "Invoice INV-2026-0042",
      "from": "Billing <billing@example.com>",
      "date": "Wed, 25 Nov 2026 14:12:09 +0000",
      "body": "Hello,\r\nPlease find the invoice attached.\r\n",
      "attributes": {
        "uid": 1842,
        "flags": [
          "\\Seen"
        ],
        "date": "2026-11-25T14:12:09.000Z"
      }
    }
  ]
}
empty

The search matched no messages.

Data
{}
error

Missing connection_id, credential, connection, login, folder or search failure. Data is { error, details }, where details carries the error code, stack and its raw serialization.

Data
{
  "error": "Invalid credentials (Failure)",
  "details": {
    "code": null,
    "stack": "<stack>",
    "raw": "<serialized error>"
  }
}

In expressions

What a later node can read from this node's output with $("Read Email (IMAP)").item.json.<path> (write your node's label instead of Read Email (IMAP)). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.

ExpressionEditorWorker
$("Read Email (IMAP)").item.json.emailsarray= […] (1)List of found emails

Errors

Message Port Cause and fix
connection_id is required (check config or config.payload) error No credential in the config nor in the incoming payload. Select an IMAP credential.
<IMAP server error> error Wrong user or password, the folder in box does not exist, or the criteria are invalid. For mail providers that require app passwords, store one in the credential.
Failed to resolve connection <connection_id>: <detail> error The credential does not exist or this workflow cannot use it.

Input contract

connection_id string Required
box string Optional
searchCriteria array Optional
markSeen boolean Optional

Output contract

emails array Optional

List of found emails

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "io.imap",
  "name": "Read Email (IMAP)",
  "category": "io",
  "version": "1.0.0",
  "description": "Read emails from IMAP server.",
  "capabilities": [
    "email",
    "imap",
    "communication"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string",
        "title": "IMAP Credential",
        "description": "Credential for the IMAP mail server. Accepts credentials of type `basic-auth` (username + password + host + port).",
        "ui_widget": "connection_picker",
        "ui_options": {
          "credential_types": [
            "basic-auth"
          ],
          "types": [
            "imap"
          ]
        }
      },
      "box": {
        "type": "string",
        "default": "INBOX"
      },
      "searchCriteria": {
        "type": "array",
        "default": [
          "UNSEEN"
        ],
        "description": "Criteria like UNSEEN, ALL, or ['SINCE', date]"
      },
      "markSeen": {
        "type": "boolean",
        "default": true
      }
    },
    "required": [
      "connection_id"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string"
      },
      "box": {
        "type": "string"
      },
      "searchCriteria": {
        "type": "array"
      },
      "markSeen": {
        "type": "boolean"
      }
    },
    "required": [
      "connection_id"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "emails": {
        "type": "array",
        "description": "List of found emails"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Emails",
      "description": "List of found emails",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "empty",
      "label": "No Emails",
      "description": "No emails found matching criteria",
      "is_default": false,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Connection or fetch error",
      "is_default": false,
      "supports_condition": false
    }
  ],
  "execution_mode": "async",
  "required_resources": [],
  "compatible_worker_pools": [
    "standard-io"
  ],
  "tags": [
    "email",
    "communication"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_link_loom",
    "profile": {
      "name": "Link Loom",
      "verified": true,
      "url": "https://me.veripass.com/link-loom",
      "logo_url": null
    }
  }
}

Execution

Execution
async
Stateful
No
Credentials
Resolved on the server from connection_id; the secret never reaches the workflow.
Capabilities
emailimapcommunication
Tags
emailcommunication

Notes and limits

  • All matching messages are fetched in one run, with no limit or pagination; narrow searchCriteria on large mailboxes.
  • Attachments are not extracted: they stay inside the raw MIME body.
  • Not idempotent with markSeen: true: a run changes the mailbox state.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs