Skip to content

IMAP

IMAP 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 {#imap}

Provide the details of your IMAP server.

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:
  4. 2-Step Verification is not set up for the account
  5. 2-Step Verification is only set up for security keys
  6. The account is through work, school, or another organization
  7. Advanced Protection is enabled
  8. At the bottom, click Select App and choose Mail, then click Select device and choose Other (Custom name).
  9. Click GENERATE.
  10. 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:

Input Description Default
Host The IMAP server hostname (e.g., imap.gmail.com for Gmail, outlook.office365.com for Office 365)
Port The IMAP server port 993
Secure Whether to use a secure (TLS) connection true
Username The email address or username for the IMAP account
Password The account password or app password
Minimum TLS Version The minimum TLS version accepted by the connection TLSv1.1
Maximum TLS Version The maximum TLS version accepted by the connection TLSv1.3
Min DH Size Minimum key size (in bits) to accept in a TLS connection 1024
Input Comments Default
Host Provide the host address for the desired IMAP server.
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.
Password Provide the password for the given user. This value is required if secured is set to true.
Minimum TLS Version Provide a valid TLS version to be used in the connection. TLSv1.1
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 1024

Triggers

New Emails {#newemailspollingtrigger}

Fetches new emails from a specified mailbox on a recurring schedule.

Input Comments Default
Connection The IMAP connection to use.
Mailbox Provide a string value for the name of the mailbox.
Fetch Content When enabled, downloads and parses the full message body for each new email. false
Mark as Read When enabled, sets the Seen flag on new emails after polling. false

Actions

Add Flags {#addflags}

Add new flags to an existing message

Input Comments Default
Connection The IMAP connection to use.
Mailbox Provide a string value for the name of the mailbox.
Range Provide a range of messages. Alternatively you can specify * to get the latest message.
Flags For each item, provide a string value to be added to an existing message.

Append Message {#appendmessage}

Appends a new message to an existing mailbox

Input Comments Default
Connection The IMAP connection to use.
Mailbox Provide a string value for the name of the mailbox.
Path Mailbox path to upload the message to.
Message Content The raw RFC 822 formatted message content to append.

Copy Message {#copymessage}

Copies a message from one mailbox to another.

Input Comments Default
Connection The IMAP connection to use.
Mailbox Provide a string value for the name of the mailbox.
Range Provide a range of messages. Alternatively you can specify * to get the latest message.
New Path Mailbox path to upload the message to.

Create Mailbox {#createmailbox}

Creates a new mailbox folder and sets up subscription for the created mailbox

Input Comments Default
Connection The IMAP connection to use.
Path Mailbox path to upload the message to.

Delete Message {#deletemessage}

Delete an existing message

Input Comments Default
Connection The IMAP connection to use.
Mailbox Provide a string value for the name of the mailbox.
Message UID The UID of the message.

Download Message {#downloadmessage}

Download either full RFC-822 formatted message or a specific body structure part

Input Comments Default
Connection The IMAP connection to use.
Mailbox Provide a string value for the name of the mailbox.
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.

Get Mailbox Status {#getstatus}

Returns the status of a mailbox's properties

Input Comments Default
Connection The IMAP connection to use.
Mailbox Provide a string value for the name of the mailbox.

List Mailboxes {#listmailboxes}

Returns a list of available mailboxes

Input Comments Default
Connection The IMAP connection to use.

Remove Flags From Message {#removeflags}

Remove existing flags from an existing message

Input Comments Default
Connection The IMAP connection to use.
Mailbox Provide a string value for the name of the mailbox.
Range Provide a range of messages. Alternatively you can specify * to get the latest message.
Flags For each item, provide a string value to be added to an existing message.

Rename Mailbox {#renamemailbox}

Change the name of an existing mailbox

Input Comments Default
Connection The IMAP connection to use.
Path Mailbox path to upload the message to.
New Path Mailbox path to upload the message to.

Search / List Mailbox Messages {#searchmailbox}

Returns all messages in the given mailbox

Input Comments Default
Connection The IMAP connection to use.
Mailbox Provide a string value for the name of the mailbox.
From Filter email messages by sender.
To Filter email messages by recipient.
Read / Unread Filter Filter messages by read or unread status. all
Filter Options Extra parameters to filter the search results.

Set Flags {#setflags}

Set a value for an existing message flag

Input Comments Default
Connection The IMAP connection to use.
Mailbox Provide a string value for the name of the mailbox.
Range Provide a range of messages. Alternatively you can specify * to get the latest message.
Flags For each item, provide a string value to be added to an existing message.