n8n / Triggers
Process incoming email with the IMAP trigger
Start an n8n workflow for every new email in any IMAP mailbox, with the right credentials, read status and attachment settings.
Intermediate 15 min Updated
Many processes start with an email: an invoice, an order, a request from a form. The Email Trigger (IMAP) node starts a workflow each time a new message arrives in a mailbox. It works with almost any email provider, including business mailboxes hosted by Viralistic.
When to use it
Use the IMAP trigger for any mailbox that supports IMAP. For Gmail you can also use the dedicated Gmail Trigger.
Note: IMAP no longer works for Outlook.com and Microsoft 365 mailboxes, because Microsoft switched off password-based access. Use the Microsoft Outlook Trigger node for those.
Tip: Use a dedicated mailbox or folder for automation, such as
invoices@yourcompany.com. Then the workflow only sees mail meant for it, and nobody accidentally marks messages as read before n8n gets them.
Step 1: Create the IMAP credential
-
Add an Email Trigger (IMAP) node to a new workflow.
-
In Credential to connect with, create a new credential.
-
Fill in the fields:
Field Value User The full email address Password The mailbox password, or an app password Host Your provider’s IMAP server, such as imap.gmail.comPort 993SSL/TLS On Allow Self-Signed Certificates Off, unless your administrator says otherwise -
Save. n8n tests the connection.
For a Viralistic mailbox, use the server from your welcome email. The full settings are in Log in to your email with IMAP.
App passwords
Many providers block normal passwords for apps like n8n, especially when two-step verification is on. Gmail, for example, requires 2-step Verification and an app password. Create one in your account’s security settings, give it a name like “n8n”, and paste it as the password. Some providers revoke app passwords when you change your main password, so update the credential if the trigger suddenly fails to log in.
Step 2: Configure the trigger
| Setting | What it does | Recommended |
|---|---|---|
| Mailbox Name | The folder to watch | INBOX, or a dedicated folder |
| Action | What happens to the email after n8n reads it | Mark as Read |
| Download Attachments | Fetches attachments as files | On only if you need them |
| Format | How the email is returned | Simple for most uses. Resolved returns every part of the email, with attachments as files |
Mark as Read is the safest choice. By default the node fetches unread messages, so marking them read prevents the same email from being processed twice.
Filter which emails start the workflow
Under Options, Custom Email Rules lets you narrow the search with IMAP search criteria, written as a JSON array. For example, only unread mail from one sender:
["UNSEEN", ["FROM", "billing@supplier.com"]]
You can also filter later in the workflow with an IF node, which is easier to read and test.
Force Reconnect Every Minutes is useful if your mail server drops long connections. Set it to something like 30 if the trigger stops picking up mail after a while.
Step 3: Test with a real email
- Select Execute step on the trigger node.
- Send an email to the mailbox, ideally with an attachment if you need those.
- Wait for the node to show the message. Check the fields: sender, subject, text, HTML and date.
- Pin the output so you can build the rest of the workflow without sending more emails.
Working with attachments
With Download Attachments on, each attachment arrives as binary data on the item, usually named attachment_0, attachment_1 and so on. You can pass these straight to nodes that accept files, such as Google Drive (upload), Extract from File (read a PDF or spreadsheet), or an AI node that reads documents.
Warning: Downloading attachments uses memory, especially with large files or busy mailboxes. Only turn it on when the workflow needs the files, and filter out emails you do not need early.
Step 4: Publish
Click Publish. From now on, n8n stays connected to the mailbox and starts the workflow for each new email. Check the Executions tab after the first real emails arrive.
Example: invoice intake
Email Trigger (IMAP) → IF has attachment → Google Drive upload → Data Table log
- Trigger on
invoices@yourcompany.comwith Mark as Read and attachments on. - Keep only emails with a PDF attachment.
- Upload the PDF to a Drive folder.
- Log sender, subject, date and file link in a data table.
Add an AI step later to read the invoice amount and due date.
Troubleshooting
- Authentication failed: check the username is the full address, and use an app password.
- Connection timed out: check host and port. On self-hosted n8n, make sure your server can reach port 993 outbound.
- Nothing triggers: confirm the workflow is published, the folder name is right, and messages are still unread.
- More email issues: Fix common email problems.
Next steps
Still stuck?
Send us what you tried and a screenshot, and we will help you further. For new projects, book a strategic call.
Strategic call