Skip to main content

IMAP Trigger

What it does​

Starts a workflow when a new unseen email is found in the configured IMAP mailbox. The scheduler polls at a configurable interval; each new email fires one workflow run.

Inputs / config​

  • No runtime inputs.
  • Config fields:
    • credentials_id (required): IMAP credential id (host, port, username, password, TLS).
    • mailbox (optional, default Inbox): mailbox folder to poll. Use the exact folder name as seen by your IMAP server (e.g. Inbox, INBOX, Sent, custom-folder).
    • poll_interval_seconds (optional, default 30, minimum 10): how often to poll for new emails.
    • mark_as_seen (optional, default true): mark processed emails as \Seen after the workflow fires.

Outputs​

FieldTypeDescription
triggered_atstring (RFC3339)UTC time when the email triggered the run
triggerstringAlways imap_trigger
subjectstringEmail subject line
fromstringSender address (e.g. Name <[email protected]>)
tostringFirst recipient address
datestring (RFC3339)Date header from the email
body_textstringPlain-text body
body_htmlstringHTML body (empty string if not present)
uidintegerIMAP UID of the message
mailboxstringMailbox the email was fetched from
run_idstringUnique run identifier (imap:{proxyID}:{nodeID}:{uidvalidity}:{uid})

Referencing outputs​

Use {{ $json['<node_id>'].field }} in downstream node inputs:

{{ $json['imap_trigger_1'].subject }}
{{ $json['imap_trigger_1'].from }}
{{ $json['imap_trigger_1'].body_text }}
{{ $json['imap_trigger_1'].uid }}

Credential setup​

Create a credential of type IMAP in Settings → Credentials. Required fields:

FieldDescription
HostIMAP server hostname (e.g. imap.gmail.com)
PortIMAP port (993 for TLS, 143 for STARTTLS)
UsernameIMAP login username
PasswordIMAP login password (encrypted at rest)
Use TLSCheck for direct TLS (port 993)

Multi-pod behaviour​

In a multi-pod deployment, only one pod polls the mailbox at a time. A Redis ownership lock (imap_owner_lock:{proxyID}:{nodeID}) is acquired on startup and held via a heartbeat goroutine. Other pods wait and retry. If the owning pod dies, the lock expires and another pod takes over (within one lock TTL, which is max(60s, poll_interval × 3)).

Per-message UID deduplication (imap_uid_seen:…, TTL 7 days) ensures at-most-once processing even during failover handoffs.

Semantics​

  • At-most-once: a UID is claimed in Redis before the email body is fetched. If the workflow fails after claiming but before completing, the email is not retried (avoids duplicate downstream side effects).
  • mark_as_seen: marking occurs after the workflow fires and is best-effort. If it fails, the UID deduplication key prevents a duplicate run on the next poll.

Testing with "Listen for an email"​

Before enabling the workflow in production, use the Listen for an email test mode in the editor:

  1. Click Listen for an email next to Test workflow at the bottom of the canvas (or open the Incoming email step and use the listen panel in its step editor).
  2. The editor connects read-only to your IMAP mailbox and waits for the first unseen email.
  3. Send a test email to the configured account (or use an existing unseen email).
  4. The captured email payload streams into the editor and the downstream workflow runs automatically.
  5. Click each step to check its output and validate expressions and logic.

Note: Listen for an email works on both enabled and disabled workflows. You do not need to enable the workflow to run a test.

Production vs. test mode​

ModeTrigger conditionWorkflow must be enabled?
Production schedulerPolls at poll_interval_seconds; fires on every new unseen emailYes
Listen for an email (test)Fires once on the first unseen email foundNo
Execute Workflow (test)Runs with pinned/mock dataNo

Starter template​

The IMAP Email Echo template (imap_trigger_echo) connects an IMAP trigger to a code node that logs the email's subject, sender, UID, and a 200-character body preview to the run output.