n8n Email Trigger Node - Tutorial, Examples, Best Practices
đź“§
Trigger Node

n8n Email Trigger Node

Master the n8n Email Trigger (IMAP) node to automate workflows when emails arrive. Learn Gmail/Outlook setup, attachment handling, filtering, troubleshooting, and production best practices.

Your inbox is a workflow waiting to happen. Every invoice, support request, and lead notification sitting in your email represents manual work that could be automated.

The Email Trigger node transforms your inbox into a workflow trigger, starting automations the moment specific emails arrive.

Why Email Trigger?

Unlike dedicated service triggers (Gmail Trigger, Outlook Trigger), the Email Trigger node works with any email provider that supports IMAP:

  • Gmail, Outlook, Yahoo
  • Corporate Exchange servers
  • Self-hosted mail servers
  • Any standard IMAP provider

This makes it the universal solution for email automation.

The Authentication Challenge

Universal does not mean simple. IMAP authentication trips up most users:

  • Gmail requires App Passwords (regular passwords fail)
  • Outlook needs specific OAuth configuration
  • Connections drop after hours of inactivity
  • Emails get processed multiple times without proper settings

This guide covers everything you need: provider-specific setup, attachment handling, filtering, troubleshooting, and production patterns that prevent missed emails.

Common Use Cases

  • Invoice processing: Extract data from PDF attachments instantly
  • Support tickets: Route customer emails to your helpdesk
  • Lead capture: Forward form submissions to your CRM
  • Document archival: Save attachments to cloud storage
  • Alert monitoring: Trigger responses when system alerts arrive

The Reliability Problem

A workflow that works during testing can fail silently in production.

Emails pile up unprocessed. Attachments disappear. Nobody notices until a customer complains.

The Email Trigger node, properly configured, solves these problems. Improperly configured, it creates them.

What You’ll Learn

  • Step-by-step Gmail setup with App Passwords (the #1 authentication hurdle)
  • Outlook and Microsoft 365 IMAP configuration
  • Generic IMAP settings for any email provider
  • How to filter emails using custom rules and search criteria
  • Attachment downloading and binary data handling
  • Why your trigger stops working after hours and how to fix it
  • Expression patterns for accessing email data
  • Real-world workflow examples you can adapt
  • Production reliability patterns that prevent missed emails

When to Use the Email Trigger Node

n8n offers multiple ways to trigger workflows from emails. Understanding the differences helps you choose the right approach.

Trigger TypeProtocolBest ForLimitations
Email Trigger (IMAP)IMAPAny email provider, self-hosted servers, universal compatibilityRequires IMAP credentials, polling-based
Gmail TriggerGoogle APIGmail accounts, real-time push notificationsGmail only, requires Google Cloud project
Microsoft Outlook TriggerMicrosoft GraphOutlook/M365, real-time push notificationsMicrosoft accounts only, OAuth setup required
Webhook nodeHTTPEmail services that support webhooks (SendGrid, Mailgun)Not all providers support webhooks

Use Email Trigger (IMAP) when:

  • Your email provider does not have a dedicated n8n trigger
  • You need a universal solution that works across providers
  • You are connecting to a self-hosted or corporate mail server
  • You want simpler credential setup than OAuth flows
  • You need to process emails from multiple providers in one workflow

Use dedicated triggers (Gmail, Outlook) when:

  • You need real-time push notifications instead of polling
  • You want OAuth-based authentication
  • You are already invested in that ecosystem’s API

Rule of thumb: Start with the dedicated trigger if one exists for your provider. Fall back to Email Trigger (IMAP) for universal compatibility or when dedicated triggers are unavailable.

Understanding IMAP Connections

Before configuring the node, understand how IMAP email retrieval works. This knowledge helps you troubleshoot problems and configure optimal settings.

How IMAP Works

IMAP (Internet Message Access Protocol) is a standard protocol for accessing email on remote servers. Unlike POP3, which downloads and often deletes emails, IMAP keeps emails on the server and syncs state between clients.

The Email Trigger node connects to your mail server via IMAP and checks for new messages at regular intervals. When new emails matching your criteria arrive, the node triggers your workflow with the email data.

Polling vs Push

The Email Trigger uses a polling model:

  1. n8n establishes an IMAP connection to your mail server
  2. The connection stays open, listening for new emails
  3. When the server notifies of new mail, n8n retrieves it
  4. The email data triggers your workflow

This is not true real-time push (like webhooks), but it is faster than scheduled polling because the connection remains open and receives server notifications.

Why Connections Drop

IMAP connections are not permanent. They drop for several reasons:

  • Server timeouts: Mail servers close idle connections after 10-30 minutes
  • Network interruptions: Brief connectivity issues break the connection
  • Server maintenance: Email providers restart servers periodically
  • Credential expiration: App Passwords or tokens may expire

When a connection drops, the Email Trigger must reconnect. The Force Reconnect Every Minutes option helps by proactively resetting the connection before the server drops it.

Key IMAP Concepts

TermDescription
MailboxA folder on the mail server (INBOX, Sent, custom folders)
UIDUnique identifier for each email message
FlagsStatus markers (\Seen, \Flagged, \Deleted)
IDLEIMAP extension allowing the server to push notifications

Provider Setup Guides

Each email provider has specific IMAP settings and authentication requirements. Follow the guide for your provider.

Gmail Setup

Gmail requires two-factor authentication and an App Password for IMAP access. Regular passwords do not work.

Step 1: Enable Two-Factor Authentication

  1. Go to Google Account Security
  2. Under “How you sign in to Google,” click 2-Step Verification
  3. Follow the prompts to enable 2FA

Step 2: Generate an App Password

  1. Go to Google App Passwords
  2. Select Mail as the app
  3. Select your device (or choose “Other” and name it “n8n”)
  4. Click Generate
  5. Copy the 16-character password (spaces are optional)

Step 3: Enable IMAP in Gmail

  1. Open Gmail and go to Settings (gear icon) > See all settings
  2. Click the Forwarding and POP/IMAP tab
  3. Under “IMAP access,” select Enable IMAP
  4. Click Save Changes

Step 4: Configure n8n Credentials

Create IMAP credentials in n8n with these settings:

SettingValue
Hostimap.gmail.com
Port993
UserYour full Gmail address (e.g., you@gmail.com)
PasswordThe 16-character App Password
SecureYes (SSL/TLS)

Common Gmail Errors:

ErrorCauseSolution
”Invalid credentials”Wrong password typeUse App Password, not your regular password
”Please log in via your web browser”App Password not set upComplete the App Password generation
”Username and Password not accepted”2FA not enabledEnable 2FA first, then generate App Password

For more authentication troubleshooting, see our guide to fixing n8n authentication errors.

Outlook and Microsoft 365 Setup

Microsoft supports both App Passwords (personal accounts) and OAuth (work/school accounts). The IMAP approach works for personal Outlook.com accounts.

For Personal Outlook.com Accounts:

Step 1: Enable Two-Factor Authentication

  1. Go to Microsoft Account Security
  2. Click Advanced security options
  3. Enable Two-step verification

Step 2: Generate an App Password

  1. On the same security page, find App passwords
  2. Click Create a new app password
  3. Copy the generated password

Step 3: Configure n8n Credentials

SettingValue
Hostoutlook.office365.com
Port993
UserYour full Outlook email address
PasswordThe generated App Password
SecureYes (SSL/TLS)

For Work/School Microsoft 365 Accounts:

Corporate M365 accounts often disable App Passwords for security. In this case:

  1. Check if your organization allows IMAP access (many disable it)
  2. Consider using the Microsoft Outlook Trigger node instead (uses OAuth)
  3. Contact your IT administrator about IMAP access policies

Generic IMAP Settings

For other email providers, use these common settings as a starting point:

ProviderHostPortSecure
Yahoo Mailimap.mail.yahoo.com993Yes
iCloudimap.mail.me.com993Yes
Zoho Mailimap.zoho.com993Yes
ProtonMailNot supported (use ProtonMail Bridge)--
Self-hostedYour server hostname993 or 143Depends on config

Finding Your Provider’s Settings:

  1. Check your email provider’s help documentation for “IMAP settings”
  2. Look for settings labeled for “third-party email clients”
  3. Port 993 with SSL/TLS is standard; port 143 with STARTTLS is less common

Your First Email Trigger

Let’s create a working email-triggered workflow step by step.

Step 1: Add the Email Trigger Node

  1. Open n8n and create a new workflow
  2. Click + to add a node
  3. Search for “Email Trigger” or “IMAP”
  4. Click Email Trigger (IMAP) to add it

Step 2: Configure Credentials

  1. In the node panel, click Credential to connect with
  2. Click Create New Credential
  3. Enter your IMAP settings (see provider guides above)
  4. Click Save

Step 3: Configure the Node

With credentials connected, configure the trigger:

  1. Mailbox Name: Leave as INBOX or specify a folder
  2. Action: Choose “Mark as Read” to prevent reprocessing
  3. Download Attachments: Toggle off for now (we will cover attachments later)
  4. Format: Leave as “Simple” for readable output

Step 4: Test the Trigger

  1. Click Fetch Test Event to check if the connection works
  2. n8n will retrieve a recent email from your mailbox
  3. Inspect the output to see available fields

Step 5: Activate for Production

  1. Add processing nodes after the Email Trigger
  2. Save the workflow
  3. Toggle the workflow to Active

Now, every email arriving in your INBOX will trigger the workflow.

Accessing Email Data

After the trigger fires, access email data in subsequent nodes using expressions:

// Basic email fields
{{ $json.from }}           // Sender email address
{{ $json.to }}             // Recipient address
{{ $json.subject }}        // Email subject line
{{ $json.date }}           // Date received
{{ $json.text }}           // Plain text body
{{ $json.html }}           // HTML body

// Headers for advanced cases
{{ $json.headers }}        // All email headers
{{ $json.messageId }}      // Unique message ID

For complex expressions, test them with our expression validator tool.

Node Configuration Deep Dive

Each configuration option affects how the Email Trigger behaves. Understanding these options prevents common problems.

Mailbox Name

Specifies which folder to monitor.

ValueBehavior
INBOXMonitors the main inbox (default)
SentMonitors sent mail
[Gmail]/SpamGmail spam folder (note bracket syntax)
Projects/ActiveCustom folder path

Best practice: Create a dedicated folder for automated processing and use email rules to move relevant messages there. This prevents the trigger from processing every email in your inbox.

Action (Read Status)

Controls whether emails are marked as read after processing.

OptionBehaviorUse When
NoneLeave email unreadYou want to see emails in your client too
Mark as ReadMark as read after triggeringPrevent reprocessing; most common choice

Important: Without “Mark as Read,” the same email may trigger your workflow multiple times after reconnections. Always use “Mark as Read” for production workflows.

Download Attachments

Controls whether file attachments are downloaded.

SettingBehaviorImpact
OffIgnore attachmentsFaster processing, less memory
OnDownload all attachments as binary dataRequired for file processing

When to enable:

  • Processing invoice PDFs
  • Saving attachments to cloud storage
  • Extracting data from attached spreadsheets

Caution: Large attachments consume memory and increase processing time. If you only need email metadata, leave attachments disabled.

Format

Determines how email data is structured in the output.

FormatDescriptionBest For
SimpleClean, parsed fields (from, to, subject, body)Most use cases
ResolvedFull data with attachments as binaryProcessing attachments
RAWBase64-encoded raw messageAdvanced parsing, debugging

Recommendation: Start with “Simple” for readability. Switch to “Resolved” when you need attachments.

Force Reconnect Every Minutes (Options)

Found under Options, this setting proactively reconnects the IMAP connection.

ValueBehavior
0 (default)Never force reconnect
5-10Reconnect every 5-10 minutes
60Reconnect every hour

Why this matters: IMAP connections drop silently. Without Force Reconnect, your workflow may stop receiving emails until n8n detects the dead connection and reconnects, sometimes taking 30+ minutes.

Recommendation: Set Force Reconnect to 10-15 minutes for production workflows. This adds minimal overhead while ensuring reliable delivery.

Email Filtering with Custom Rules

By default, the Email Trigger processes all new emails in the specified mailbox. Custom rules let you filter which emails trigger your workflow.

Using Custom Email Rules

  1. Open the Email Trigger node
  2. Expand Options
  3. Find Custom Email Rules
  4. Enter filter criteria using node-imap search syntax

Common Filter Examples

Filter by Sender:

FROM "invoices@vendor.com"

Filter by Subject:

SUBJECT "Order Confirmation"

Filter by Unread Only:

UNSEEN

Filter by Date (since yesterday):

SINCE 1-Dec-2024

Combine Multiple Criteria:

FROM "support@" SUBJECT "ticket" UNSEEN

Filter Syntax Reference

CriteriaDescriptionExample
FROM "email"Sender contains stringFROM "sales@"
TO "email"Recipient contains stringTO "support@mycompany.com"
SUBJECT "text"Subject contains stringSUBJECT "invoice"
UNSEENUnread emails onlyUNSEEN
SEENRead emails onlySEEN
FLAGGEDStarred/flagged emailsFLAGGED
SINCE dateEmails after dateSINCE 1-Jan-2024
BEFORE dateEmails before dateBEFORE 31-Dec-2024
LARGER sizeLarger than size in bytesLARGER 1000000

Combining criteria: Multiple criteria are ANDed together. FROM "vendor" SUBJECT "invoice" matches emails from “vendor” that also have “invoice” in the subject.

Handling Email Attachments

Processing email attachments requires specific configuration and understanding of n8n’s binary data system.

Enabling Attachment Download

  1. In the Email Trigger node, set Download Attachments to On
  2. Set Format to “Resolved” for the best attachment handling
  3. Attachments appear as binary data in the output

Accessing Attachment Data

After the trigger fires with attachments enabled:

// Check if attachments exist
{{ $json.attachments }}           // Array of attachment metadata

// Access first attachment info
{{ $json.attachments[0].filename }}    // "invoice.pdf"
{{ $json.attachments[0].contentType }} // "application/pdf"
{{ $json.attachments[0].size }}        // Size in bytes

// Binary data is available separately
{{ $binary.attachment_0 }}        // First attachment binary
{{ $binary.attachment_1 }}        // Second attachment binary

Processing Attachments

Common attachment processing patterns:

Save to Google Drive:

Email Trigger → Google Drive (Upload File)

In the Google Drive node, select the binary property containing the attachment.

Extract Data from PDF:

Email Trigger → Extract from File → Process Data

Use the Extract from File node to parse PDF, Excel, or other file formats.

Save to S3:

Email Trigger → AWS S3 (Upload)

For more on handling binary data and attachments, see our binary data guide.

Attachment Size Considerations

Large attachments impact performance:

  • Memory usage: Each attachment loads into memory
  • Processing time: Large files take longer to download and process
  • Timeout risk: Very large attachments may cause workflow timeouts

Best practices:

  • Use email rules to filter out large, unnecessary emails
  • Process one email at a time (avoid batch processing with large attachments)
  • Consider streaming to cloud storage instead of holding in memory

Accessing Email Data

Reference for all email fields available after the trigger fires.

Standard Email Fields

ExpressionReturnsExample Value
$json.fromSender email"John Smith <john@example.com>"
$json.toRecipient email"support@mycompany.com"
$json.subjectSubject line"Order #12345 Confirmation"
$json.dateDate received"2024-12-15T10:30:00Z"
$json.textPlain text body"Hello, your order..."
$json.htmlHTML body"<html><body>..."
$json.messageIdUnique message ID"<abc123@mail.example.com>"
$json.ccCC recipients"manager@example.com"
$json.bccBCC recipientsUsually empty

Extracting Sender Name and Email

The from field often includes both name and email. Extract them separately:

// Full from field: "John Smith <john@example.com>"

// Extract just the email using regex
{{ $json.from.match(/<(.+)>/)?.[1] ?? $json.from }}
// Returns: john@example.com

// Extract just the name
{{ $json.from.replace(/<.+>/, '').trim() }}
// Returns: John Smith

Working with Email Body

ScenarioExpression
Use plain text body$json.text
Use HTML body$json.html
Prefer text, fallback to HTML$json.text || $json.html
Extract text from HTMLUse a Code node with regex or HTML parsing

Common Data Extraction Patterns

Extract Order ID from Subject:

// Subject: "Order #12345 Confirmation"
{{ $json.subject.match(/Order #(\d+)/)?.[1] }}
// Returns: 12345

Check if Email is a Reply:

{{ $json.subject.toLowerCase().startsWith('re:') }}
// Returns: true or false

Get Domain from Sender:

{{ $json.from.match(/@([^>]+)/)?.[1] }}
// Returns: example.com

For advanced data manipulation, see our Code node guide.

Error Handling and Reliability

Email triggers can fail for various reasons. Proper error handling ensures you know when problems occur and can recover quickly.

Common IMAP Error Codes

These are the specific error messages you will encounter in n8n Email Trigger:

Error MessageCauseSolution
AUTHENTICATIONFAILEDWrong username or passwordVerify credentials, use App Password for Gmail/Outlook
Invalid credentialsPassword rejected by serverGenerate new App Password, check 2FA is enabled
LOGIN failedAuthentication rejectedUse App Password instead of regular password
AUTH=PLAIN not supportedServer requires different authEnable “Less secure apps” or use App Password
Connection timeoutServer unreachableCheck host/port, verify firewall allows port 993
ETIMEDOUTNetwork timeoutCheck internet connection, try different network
ECONNREFUSEDServer rejected connectionVerify IMAP is enabled on mail server
ENOTFOUNDInvalid hostnameCheck IMAP host spelling (e.g., imap.gmail.com)
Connection closed unexpectedlyIMAP session droppedEnable Force Reconnect (10-15 min)
Socket closed unexpectedlyNetwork interruptionEnable Force Reconnect, check network stability
certificate has expiredSSL certificate invalidUpdate server certificate or disable TLS verification
self signed certificateUntrusted certificateUse proper SSL cert or set Secure to false
unable to verify the first certificateCertificate chain issueInstall intermediate certificates on server
Mailbox doesn't existWrong folder nameCheck exact folder name (INBOX, Sent, etc.)
Mailbox not foundFolder does not existVerify folder exists, check case sensitivity
NO SELECT Mailbox not foundInvalid mailbox pathUse correct path (e.g., INBOX, [Gmail]/Sent Mail)
Too many simultaneous connectionsProvider limit reachedReduce concurrent Email Trigger workflows
User is authenticated but not connectedSession state errorEnable Force Reconnect to reset connection
IMAP connection not availablen8n lost IMAP handleRestart workflow, enable Force Reconnect

Gmail-Specific Errors

Error MessageCauseSolution
Username and Password not acceptedRegular password usedCreate App Password at myaccount.google.com/apppasswords
Please log in via your web browserAccount security blockComplete security check in Gmail, then retry
Web login requiredGoogle blocked sign-inVisit accounts.google.com, verify identity
Application-specific password required2FA enabled, no App PasswordGenerate 16-character App Password
IMAP access is disabledIMAP turned off in GmailEnable in Settings > Forwarding and POP/IMAP
Too many login failuresRate limitedWait 1 hour, check credentials are correct

Outlook and Microsoft 365 Errors

Error MessageCauseSolution
Authentication unsuccessfulOAuth or password issueUse App Password or configure OAuth
ADALErrorCode: interaction_requiredOAuth token expiredRe-authenticate OAuth credentials in n8n
AUTHENTICATE failedModern Auth requiredCreate App Password in Microsoft account security
Logon failure: unknown user name or bad passwordInvalid credentialsVerify email and App Password
BasicAuthentication is disabledBasic auth blocked by adminContact admin or use OAuth authentication

Connection State Errors

Error MessageCauseSolution
Not authenticatedSession expiredEnable Force Reconnect (10-15 min)
Connection ended unexpectedlyServer closed connectionSet Force Reconnect to 5-10 minutes
read ECONNRESETConnection reset by serverCheck server logs, enable Force Reconnect
write EPIPEBroken pipe, connection lostEnable Force Reconnect, check network
Timed out while authenticatingSlow network or serverIncrease timeout, check network latency
IDLE not supportedServer lacks IDLE commandn8n uses polling, should still work

Force Reconnect Best Practices

The Force Reconnect option is critical for production reliability:

  1. Set to 10-15 minutes for most use cases
  2. Set to 5 minutes if you notice missed emails
  3. Never leave at 0 for production workflows

This ensures the connection resets before the mail server drops it, preventing silent failures.

Monitoring for Missed Emails

Even with Force Reconnect, emails can occasionally be missed. Implement monitoring:

Pattern 1: Heartbeat Check

Create a scheduled workflow that sends a test email and verifies it triggers your email workflow within a reasonable time.

Pattern 2: Count Comparison

Compare email counts from your mail provider’s API against processed emails in your workflow logs.

Pattern 3: Error Workflow

Connect an Error Trigger workflow to receive alerts when the email workflow fails.

Retry Strategies

If email processing fails, you have options:

  1. Enable “Continue On Fail” on processing nodes to handle partial failures
  2. Use the Error Trigger to capture failures and alert your team
  3. Do not mark as read on failure so the email can be reprocessed

For timeout-related issues, see our timeout troubleshooting guide.

Real-World Examples

Example 1: Invoice Processing Workflow

Scenario: Automatically extract data from invoice PDFs and save to a spreadsheet.

Email Trigger (filter: FROM "invoices@")
  → Extract from File (PDF to text)
  → Code node (parse invoice data)
  → Google Sheets (append row)

Email Trigger Configuration:

  • Mailbox: Invoices (dedicated folder)
  • Download Attachments: On
  • Format: Resolved
  • Action: Mark as Read
  • Custom Rules: FROM "vendor@" SUBJECT "invoice"

Data extraction in Code node:

const text = $json.text;
const invoiceNumber = text.match(/Invoice #?(\d+)/i)?.[1];
const amount = text.match(/Total:?\s*\$?([\d,]+\.?\d*)/i)?.[1];
const date = text.match(/Date:?\s*([\d\/\-]+)/)?.[1];

return [{
  json: {
    invoiceNumber,
    amount: parseFloat(amount?.replace(',', '') || 0),
    date,
    vendor: $('Email Trigger').first().json.from,
    receivedAt: new Date().toISOString()
  }
}];

Example 2: Support Ticket Creation

Scenario: Create helpdesk tickets from customer support emails.

Email Trigger (filter: TO "support@")
  → IF node (check not auto-reply)
  → HTTP Request (create ticket in helpdesk API)
  → Email Send (send confirmation)

IF node condition:

{{ !$json.subject.toLowerCase().includes('auto-reply') &&
   !$json.subject.toLowerCase().includes('out of office') }}

HTTP Request to create ticket:

{
  "subject": "{{ $json.subject }}",
  "description": "{{ $json.text }}",
  "customer_email": "{{ $json.from.match(/<(.+)>/)?.[1] ?? $json.from }}",
  "priority": "normal",
  "source": "email"
}

Example 3: Lead Capture from Web Forms

Scenario: Process contact form submissions forwarded by email.

Email Trigger (filter: SUBJECT "Contact Form")
  → Code node (parse form fields)
  → HubSpot (create contact)
  → Slack (notify sales team)

Example 4: Email-to-Database Archival

Scenario: Archive all emails to a database for compliance.

Email Trigger
  → Postgres (insert email record)
  → IF (has attachments?)
    → True: S3 Upload + Postgres (update with attachment URL)
    → False: Continue

Example 5: Attachment Processing Pipeline

Scenario: Save email attachments to Google Drive and log to Airtable.

Email Trigger (attachments: on)
  → Split Out (process each attachment)
  → Google Drive (upload file)
  → Airtable (log file info)

For more workflow patterns, see our workflow best practices guide.

Pro Tips and Best Practices

1. Use Dedicated Folders

Do not monitor your entire INBOX. Create a dedicated folder and use email rules to route relevant messages:

  • Create folder: n8n-processing or Automated
  • Set up email rules in your provider to move matching emails
  • Point the Email Trigger at this specific folder

Benefits: Cleaner inbox, faster processing, easier debugging.

2. Always Mark as Read

Unless you have a specific reason not to, always set Action to “Mark as Read”:

  • Prevents duplicate processing after reconnections
  • Provides clear visibility into what has been processed
  • Avoids infinite loops with other automation tools

3. Set Force Reconnect

Never leave Force Reconnect at the default (disabled) for production:

  • Set to 10-15 minutes as a baseline
  • Reduce to 5 minutes if you experience missed emails
  • This single setting prevents most “trigger stopped working” issues

4. Filter Aggressively

Use Custom Email Rules to process only relevant emails:

  • Reduces workflow executions
  • Lowers resource usage
  • Simplifies debugging

5. Handle Connection Drops Gracefully

Accept that IMAP connections will drop. Design your workflow to handle this:

  • Use Error Trigger for alerting
  • Implement monitoring for missed emails
  • Do not assume 100% reliability without verification

6. Secure Your Credentials

Protect your email credentials:

  • Use App Passwords instead of main account passwords
  • Never log or expose credentials in workflow outputs
  • Consider creating a dedicated email account for automation
  • Rotate App Passwords periodically

For credential management best practices, see our credential management guide.

7. Test with Real Emails

Do not rely on “Fetch Test Event” alone:

  1. Send yourself test emails that match your filters
  2. Verify they trigger the workflow correctly
  3. Check that all data fields are accessible
  4. Test edge cases (no attachments, unusual characters, large files)

When to Get Help

Email automation seems straightforward until edge cases appear. Some scenarios benefit from expert assistance:

  • Complex filtering logic combining multiple criteria with business rules
  • High-volume email processing with performance optimization needs
  • Multi-provider setups requiring different configurations
  • Compliance requirements for email archival and audit trails
  • Integration with legacy mail servers with non-standard IMAP implementations

Our workflow development services include production-ready email automation patterns. For strategic guidance on email integration architecture, explore our consulting services.

Frequently Asked Questions

Why does my Email Trigger work in test mode but not when the workflow is active?

This is the most common issue. It comes down to connection persistence.

What happens in test mode:

  • n8n creates a fresh connection to your mail server
  • Retrieves a recent email
  • Connection closes after the test

What happens in production:

  • The connection must stay alive indefinitely
  • IMAP connections drop due to server timeouts (10-30 minutes), network interruptions, or server restarts
  • Your workflow silently stops receiving emails

The fix:

Enable Force Reconnect Every Minutes in node options. Set it to 10-15 minutes. This proactively reconnects before the server drops the connection.

Also verify:

  • Your workflow is Active (check the toggle in the top right)
  • The Email Trigger is the first node in the workflow

How do I set up Gmail with the Email Trigger node?

Gmail requires two-factor authentication and an App Password. Your regular Gmail password will not work.

Step 1: Enable 2FA

Enable 2FA in your Google Account security settings if you have not already.

Step 2: Generate App Password

Go to Google App Passwords:

  • Select “Mail” as the app
  • Generate a 16-character password
  • Copy it immediately (you will only see it once)

Step 3: Enable IMAP in Gmail

Navigate to: Settings > See all settings > Forwarding and POP/IMAP > Enable IMAP

Step 4: Create IMAP credentials in n8n

SettingValue
Hostimap.gmail.com
Port993
UserYour full Gmail address
PasswordThe 16-character App Password
SecureYes

Common mistake: Using your regular password instead of the App Password.

Why is my IMAP trigger missing some emails?

Email Trigger reliability depends on connection stability.

Why emails get missed:

  • IMAP connection drops (server timeouts, network issues, maintenance)
  • Emails arrive during the disconnection period
  • Emails get skipped when the connection re-establishes

How to improve reliability:

  1. Enable Force Reconnect Every Minutes - Set to 10-15 minutes to proactively maintain the connection

  2. Use Mark as Read - Creates a clear record of processed emails and prevents reprocessing

  3. Use a dedicated folder - Route emails via server-side rules to a specific folder instead of monitoring the entire INBOX

Still missing emails?

The issue might be on the mail server side. Some providers have strict rate limits or connection limits that cause missed emails under high volume.

How do I process email attachments in my workflow?

Required configuration:

  • Set Download Attachments to On
  • Set Format to “Resolved”

Attachments appear as binary data you can pass to other nodes.

Accessing attachment data:

DataExpression
Metadata (filename, type, size)$json.attachments (array)
First attachment binary$binary.attachment_0
Second attachment binary$binary.attachment_1

Common next steps:

  • Save to cloud storage - Connect Google Drive, S3, or similar node and select the binary property
  • Extract data - Use the Extract from File node for PDFs or spreadsheets

Performance warning:

Large attachments consume memory and increase processing time. Filter emails to only download attachments when necessary. Avoid processing very large files (10MB+) without adequate server resources.

Why does my Email Trigger stop working after a few hours?

IMAP connections are long-lived but not permanent.

Why connections drop:

  • Mail servers close idle connections after 10-30 minutes
  • Network interruptions
  • Server maintenance
  • Credential expiration

The primary fix:

Enable Force Reconnect Every Minutes in node options. Set to 10-15 minutes. This forces n8n to reset the connection periodically, preventing silent connection death.

Still having issues?

Check these additional causes:

  • App Password expired - Regenerate it in your Google/Microsoft account
  • Connection limits - Your provider may limit concurrent connections (reduce workflows)
  • Server-side issues - Check your provider’s status page
  • Workflow errors - Connect an Error Trigger workflow to monitor failures

Ready to Automate Your Business?

Tell us what you need automated. We'll build it, test it, and deploy it fast.

âś“ 48-72 Hour Turnaround
âś“ Production Ready
âś“ Free Consultation
⚡

Create Your Free Account

Sign up once, use all tools free forever. We require accounts to prevent abuse and keep our tools running for everyone.

or

You're in!

Check your email for next steps.

By signing up, you agree to our Terms of Service and Privacy Policy. No spam, unsubscribe anytime.

🚀

Get Expert Help

Add your email and one of our n8n experts will reach out to help with your automation needs.

or

We'll be in touch!

One of our experts will reach out soon.

By submitting, you agree to our Terms of Service and Privacy Policy. No spam, unsubscribe anytime.