Skip to main content

IMAP Component

Interact with your IMAP email account

Component key: imap

Changelog ↓

Description

IMAP (Internet Message Access Protocol) is an Internet standard protocol used by email clients to retrieve email messages from a mail server over a TCP/IP connection. This component gives you the ability to list mailboxes, search and fetch emails, manage message flags, and copy or move messages on any IMAP server.

API Documentation

This component was built using the ImapFlow Node.js library.

Connections

IMAP Connection

key: imap

To configure a connection to an IMAP server, the server's host address, port, login credentials, and TLS settings are required.

The setup can vary widely depending on the email service in use. Context for some popular services is provided below.

Prerequisites

  • Access to an IMAP-enabled email account
  • The IMAP server host address and port
  • Valid login credentials (username and password or app password)

Setup Steps

Gmail

To set up an IMAP connection to a Gmail account, create a Google App Password:

  1. Navigate to the Google Account page and select Security.
  2. Under Signing in to Google, select App Passwords. Sign-in may be required.
  3. If the App Passwords option is not available, possible reasons include:
    • 2-Step Verification is not set up for the account
    • 2-Step Verification is only set up for security keys
    • The account is through work, school, or another organization
    • Advanced Protection is enabled
  4. At the bottom, click Select App and choose Mail, then click Select device and choose Other (Custom name).
  5. Click GENERATE.
  6. A 16-character code will be generated — this is the app password. Copy it to a safe location.

If authentication problems occur, ensure the account has IMAP enabled.

Microsoft Office 365

If the Office 365 domain does not use multi-factor authentication (this is rare), the username and password can be used to authenticate directly.

If MFA is enabled, an app password is required to authenticate. To create an app password:

  1. Log in to the Microsoft Security Center and open the Security info tab.
  2. Click +Add method and choose App password.
  3. Enter a name for the app password, and copy the password that is generated.

If the App password option is unavailable, contact the Office 365 administrator to enable it.

Configure the Connection

Create a connection of type IMAP Connection and enter the following values:

InputDescriptionDefault
HostThe IMAP server hostname (e.g., imap.gmail.com for Gmail, outlook.office365.com for Office 365)
PortThe IMAP server port993
SecureWhether to use a secure (TLS) connectiontrue
UsernameThe email address or username for the IMAP account
PasswordThe account password or app password
Minimum TLS VersionThe minimum TLS version accepted by the connectionTLSv1.1
Maximum TLS VersionThe maximum TLS version accepted by the connectionTLSv1.3
Min DH SizeMinimum key size (in bits) to accept in a TLS connection1024

On-prem enabled: this connection can be configured to connect to an on-prem resource on a private network. Learn more.

InputNotesExample
Host

Provide the host address for the desired IMAP server.

imap.example.com
Maximum TLS Version

Provide a valid TLS version to be used in the connection.

TLSv1.3
Min DH Size

Minimum size of bits to accept in a TLS connection

512
Minimum TLS Version

Provide a valid TLS version to be used in the connection.

TLSv1.1
Password

Provide the password for the given user. This value is required if secured is set to true.

examplePassword
Port

Provide the port for the desired IMAP server.

993
Secure

Determines if the connection is secure.

true
Username

Provide a valid username or email.

someone@example.com

Triggers

New Emails

Fetches new emails from a specified mailbox on a recurring schedule. | key: newEmailsPollingTrigger

InputNotesExample
Connection

The IMAP connection to use.

Fetch Content

When enabled, downloads and parses the full message body for each new email.

false
Mailbox

Provide a string value for the name of the mailbox.

INBOX
Mark as Read

When enabled, sets the Seen flag on new emails after polling.

false

Checks for new emails in a specified mailbox on a configured schedule. This trigger uses IMAP UIDs to track which messages have already been processed, ensuring each email is only returned once.

How It Works

  1. On the first execution, the trigger connects to the IMAP server and records the current UID state of the mailbox. No emails are returned on this initial run.
  2. On subsequent executions, the trigger checks for emails with UIDs greater than the last recorded value.
  3. If the mailbox's uidValidity changes (indicating the mailbox was rebuilt or re-created), the trigger resets its state and begins tracking from the new baseline.
  4. New emails are returned as an array in the trigger payload.

Configuration

  • Connection: An IMAP connection with the server host, port, credentials, and TLS settings.
  • Mailbox: The mailbox to monitor (default: INBOX).
  • Fetch Content: When enabled, downloads and parses the full message body (plain text and HTML) for each new email. Disabled by default to reduce payload size.
  • Mark as Read: When enabled, sets the \Seen flag on new emails after polling. Disabled by default.

Returned Data

Example Payload
{
"data": [
{
"uid": 76791,
"envelope": {
"from": [{ "address": "sender@example.com", "name": "Sender Name" }],
"to": [
{ "address": "recipient@example.com", "name": "Recipient Name" }
],
"subject": "Example Subject",
"date": "2026-02-18T12:00:00.000Z",
"messageId": "<unique-id@example.com>"
},
"flags": ["\\Recent"],
"internalDate": "2026-02-18T12:00:00.000Z",
"size": 4523
},
{
"uid": 76792,
"envelope": {
"from": [
{ "address": "another@example.com", "name": "Another Sender" }
],
"to": [
{ "address": "recipient@example.com", "name": "Recipient Name" }
],
"subject": "Another Email",
"date": "2026-02-18T12:05:00.000Z",
"messageId": "<unique-id-2@example.com>"
},
"flags": [],
"internalDate": "2026-02-18T12:05:00.000Z",
"size": 8912,
"text": "Plain text body (when Fetch Content is enabled)",
"html": "<p>HTML body (when Fetch Content is enabled)</p>",
"attachments": [
{
"filename": "report.pdf",
"size": 24576,
"contentType": "application/pdf"
}
]
}
]
}

Notes

  • The trigger returns an empty array when no new emails are found since the last poll.
  • Enabling Fetch Content increases the payload size and execution time, especially for emails with large attachments. Only attachment metadata (filename, size, content type) is included — not the actual attachment data.
  • The polling schedule is configured at the integration level, not within the trigger itself.

Data Sources

List Mailboxes

Returns a picklist of available mailboxes that users can choose from | key: listMailboxes | type: picklist

InputNotesExample
Connection

The IMAP connection to use.


Actions

Add Flags

Add new flags to an existing message | key: addFlags

InputNotesExample
Connection

The IMAP connection to use.

Flags

For each item, provide a string value to be added to an existing message.

exampleFlag
Mailbox

Provide a string value for the name of the mailbox.

INBOX
Range

Provide a range of messages. Alternatively you can specify * to get the latest message.

1,2,4:6

{
"data": true
}

Append Message

Appends a new message to an existing mailbox | key: appendMessage

InputNotesExample
Connection

The IMAP connection to use.

Message Content

The raw RFC 822 formatted message content to append.

From: someone@<yourcompany>.com Subject: A basic RFC 850 formatted message Newsgroups: comp.<yourcompany>.test The body of this message is plain text. Note the blank line between the header information and the body of the message.
Mailbox

Provide a string value for the name of the mailbox.

INBOX
Path

Mailbox path to upload the message to.

INBOX

{
"data": {
"destination": "INBOX",
"uid": 456,
"uidValidity": "596391842",
"seq": 61
}
}

Copy Message

Copies a message from one mailbox to another. | key: copyMessage

InputNotesExample
Connection

The IMAP connection to use.

Mailbox

Provide a string value for the name of the mailbox.

INBOX
New Path

Mailbox path to upload the message to.

INBOX
Range

Provide a range of messages. Alternatively you can specify * to get the latest message.

1,2,4:6

{
"data": {
"path": "My-Source-Mailbox",
"destination": "My-Destination-Mailbox",
"uidValidity": "596391920",
"uidMap": {}
}
}

Create Mailbox

Creates a new mailbox folder and sets up subscription for the created mailbox | key: createMailbox

InputNotesExample
Connection

The IMAP connection to use.

Path

Mailbox path to upload the message to.

INBOX

{
"data": {
"path": "New-Mailbox",
"created": true
}
}

Delete Message

Delete an existing message | key: deleteMessage

InputNotesExample
Connection

The IMAP connection to use.

Mailbox

Provide a string value for the name of the mailbox.

INBOX
Message UID

The UID of the message.

5

{
"data": true
}

Download Message

Download either full RFC-822 formatted message or a specific body structure part | key: downloadMessage

InputNotesExample
Connection

The IMAP connection to use.

Mailbox

Provide a string value for the name of the mailbox.

INBOX
Message Index or ID

The index of the message you would like to download (1 for the oldest message, 2 for second oldest, etc), or the ID of the message.

5

{
"data": {
"meta": {
"expectedSize": 12345,
"contentType": "message/rfc822"
},
"message": {
"headers": {
"from": {
"value": [
{
"address": "sender@example.com",
"name": "Sender"
}
]
},
"to": {
"value": [
{
"address": "recipient@example.com",
"name": "Recipient"
}
]
},
"subject": "Example Subject",
"date": "2025-07-21T12:00:00.000Z"
},
"attachments": [],
"attachmentsMetadata": [],
"text": "This is the plain text body of the email.",
"html": "<p>This is the HTML body of the email.</p>"
}
}
}

Get Mailbox Status

Returns the status of a mailbox's properties | key: getStatus

InputNotesExample
Connection

The IMAP connection to use.

Mailbox

Provide a string value for the name of the mailbox.

INBOX

{
"data": {
"path": "INBOX",
"highestModseq": "10914782",
"messages": 61,
"recent": 0,
"uidNext": 76791,
"uidValidity": "596391842",
"unseen": 41
}
}

List Mailboxes

Returns a list of available mailboxes | key: listMailboxes

InputNotesExample
Connection

The IMAP connection to use.

{
"data": [
{
"path": "Drafts",
"flags": {},
"delimiter": "/",
"listed": true,
"name": "Drafts",
"subscribed": true
},
{
"path": "INBOX",
"flags": {},
"delimiter": "/",
"listed": true,
"specialUse": "\\Inbox",
"name": "INBOX",
"subscribed": true
},
{
"path": "Sent",
"flags": {},
"delimiter": "/",
"listed": true,
"name": "Sent",
"subscribed": true
}
]
}

Remove Flags From Message

Remove existing flags from an existing message | key: removeFlags

InputNotesExample
Connection

The IMAP connection to use.

Flags

For each item, provide a string value to be added to an existing message.

exampleFlag
Mailbox

Provide a string value for the name of the mailbox.

INBOX
Range

Provide a range of messages. Alternatively you can specify * to get the latest message.

1,2,4:6

{
"data": true
}

Rename Mailbox

Change the name of an existing mailbox | key: renameMailbox

InputNotesExample
Connection

The IMAP connection to use.

New Path

Mailbox path to upload the message to.

INBOX
Path

Mailbox path to upload the message to.

INBOX

{
"data": {
"path": "Old-Mailbox",
"newPath": "New-Mailbox"
}
}

Search / List Mailbox Messages

Returns all messages in the given mailbox | key: searchMailbox

InputNotesExample
Connection

The IMAP connection to use.

Filter Options

Extra parameters to filter the search results.

From

Filter email messages by sender.

someone@example.com
Mailbox

Provide a string value for the name of the mailbox.

INBOX
Read / Unread Filter

Filter messages by read or unread status.

all
To

Filter email messages by recipient.

someone@example.com

{
"data": [
1,
5,
12,
45,
78
]
}

Set Flags

Set a value for an existing message flag | key: setFlags

InputNotesExample
Connection

The IMAP connection to use.

Flags

For each item, provide a string value to be added to an existing message.

exampleFlag
Mailbox

Provide a string value for the name of the mailbox.

INBOX
Range

Provide a range of messages. Alternatively you can specify * to get the latest message.

1,2,4:6

{
"data": true
}

Changelog

2026-02-18

  • Added New Emails polling trigger to fetch new emails from a specified mailbox on a recurring schedule

2025-07-21

  • Modified Download Message action for enhanced functionality and improved message handling
  • Added metadata fields to the Download Attachment action for better message processing capabilities
  • Modernized IMAP component and added more metadata fields to actions for improved email management and processing