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 Type | Protocol | Best For | Limitations |
|---|---|---|---|
| Email Trigger (IMAP) | IMAP | Any email provider, self-hosted servers, universal compatibility | Requires IMAP credentials, polling-based |
| Gmail Trigger | Google API | Gmail accounts, real-time push notifications | Gmail only, requires Google Cloud project |
| Microsoft Outlook Trigger | Microsoft Graph | Outlook/M365, real-time push notifications | Microsoft accounts only, OAuth setup required |
| Webhook node | HTTP | Email 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:
- n8n establishes an IMAP connection to your mail server
- The connection stays open, listening for new emails
- When the server notifies of new mail, n8n retrieves it
- 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
| Term | Description |
|---|---|
| Mailbox | A folder on the mail server (INBOX, Sent, custom folders) |
| UID | Unique identifier for each email message |
| Flags | Status markers (\Seen, \Flagged, \Deleted) |
| IDLE | IMAP 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
- Go to Google Account Security
- Under “How you sign in to Google,” click 2-Step Verification
- Follow the prompts to enable 2FA
Step 2: Generate an App Password
- Go to Google App Passwords
- Select Mail as the app
- Select your device (or choose “Other” and name it “n8n”)
- Click Generate
- Copy the 16-character password (spaces are optional)
Step 3: Enable IMAP in Gmail
- Open Gmail and go to Settings (gear icon) > See all settings
- Click the Forwarding and POP/IMAP tab
- Under “IMAP access,” select Enable IMAP
- Click Save Changes
Step 4: Configure n8n Credentials
Create IMAP credentials in n8n with these settings:
| Setting | Value |
|---|---|
| Host | imap.gmail.com |
| Port | 993 |
| User | Your full Gmail address (e.g., [email protected]) |
| Password | The 16-character App Password |
| Secure | Yes (SSL/TLS) |
Common Gmail Errors:
| Error | Cause | Solution |
|---|---|---|
| ”Invalid credentials” | Wrong password type | Use App Password, not your regular password |
| ”Please log in via your web browser” | App Password not set up | Complete the App Password generation |
| ”Username and Password not accepted” | 2FA not enabled | Enable 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
- Go to Microsoft Account Security
- Click Advanced security options
- Enable Two-step verification
Step 2: Generate an App Password
- On the same security page, find App passwords
- Click Create a new app password
- Copy the generated password
Step 3: Configure n8n Credentials
| Setting | Value |
|---|---|
| Host | outlook.office365.com |
| Port | 993 |
| User | Your full Outlook email address |
| Password | The generated App Password |
| Secure | Yes (SSL/TLS) |
For Work/School Microsoft 365 Accounts:
Corporate M365 accounts often disable App Passwords for security. In this case:
- Check if your organization allows IMAP access (many disable it)
- Consider using the Microsoft Outlook Trigger node instead (uses OAuth)
- Contact your IT administrator about IMAP access policies
Generic IMAP Settings
For other email providers, use these common settings as a starting point:
| Provider | Host | Port | Secure |
|---|---|---|---|
| Yahoo Mail | imap.mail.yahoo.com | 993 | Yes |
| iCloud | imap.mail.me.com | 993 | Yes |
| Zoho Mail | imap.zoho.com | 993 | Yes |
| ProtonMail | Not supported (use ProtonMail Bridge) | - | - |
| Self-hosted | Your server hostname | 993 or 143 | Depends on config |
Finding Your Provider’s Settings:
- Check your email provider’s help documentation for “IMAP settings”
- Look for settings labeled for “third-party email clients”
- 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
- Open n8n and create a new workflow
- Click + to add a node
- Search for “Email Trigger” or “IMAP”
- Click Email Trigger (IMAP) to add it
Step 2: Configure Credentials
- In the node panel, click Credential to connect with
- Click Create New Credential
- Enter your IMAP settings (see provider guides above)
- Click Save
Step 3: Configure the Node
With credentials connected, configure the trigger:
- Mailbox Name: Leave as
INBOXor specify a folder - Action: Choose “Mark as Read” to prevent reprocessing
- Download Attachments: Toggle off for now (we will cover attachments later)
- Format: Leave as “Simple” for readable output
Step 4: Test the Trigger
- Click Fetch Test Event to check if the connection works
- n8n will retrieve a recent email from your mailbox
- Inspect the output to see available fields
Step 5: Activate for Production
- Add processing nodes after the Email Trigger
- Save the workflow
- 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.
| Value | Behavior |
|---|---|
INBOX | Monitors the main inbox (default) |
Sent | Monitors sent mail |
[Gmail]/Spam | Gmail spam folder (note bracket syntax) |
Projects/Active | Custom 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.
| Option | Behavior | Use When |
|---|---|---|
| None | Leave email unread | You want to see emails in your client too |
| Mark as Read | Mark as read after triggering | Prevent 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.
| Setting | Behavior | Impact |
|---|---|---|
| Off | Ignore attachments | Faster processing, less memory |
| On | Download all attachments as binary data | Required 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.
| Format | Description | Best For |
|---|---|---|
| Simple | Clean, parsed fields (from, to, subject, body) | Most use cases |
| Resolved | Full data with attachments as binary | Processing attachments |
| RAW | Base64-encoded raw message | Advanced 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.
| Value | Behavior |
|---|---|
| 0 (default) | Never force reconnect |
| 5-10 | Reconnect every 5-10 minutes |
| 60 | Reconnect 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
- Open the Email Trigger node
- Expand Options
- Find Custom Email Rules
- Enter filter criteria using node-imap search syntax
Common Filter Examples
Filter by Sender:
FROM "[email protected]"
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
| Criteria | Description | Example |
|---|---|---|
FROM "email" | Sender contains string | FROM "sales@" |
TO "email" | Recipient contains string | TO "[email protected]" |
SUBJECT "text" | Subject contains string | SUBJECT "invoice" |
UNSEEN | Unread emails only | UNSEEN |
SEEN | Read emails only | SEEN |
FLAGGED | Starred/flagged emails | FLAGGED |
SINCE date | Emails after date | SINCE 1-Jan-2024 |
BEFORE date | Emails before date | BEFORE 31-Dec-2024 |
LARGER size | Larger than size in bytes | LARGER 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
- In the Email Trigger node, set Download Attachments to On
- Set Format to “Resolved” for the best attachment handling
- 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
| Expression | Returns | Example Value |
|---|---|---|
$json.from | Sender email | "John Smith <[email protected]>" |
$json.to | Recipient email | "[email protected]" |
$json.subject | Subject line | "Order #12345 Confirmation" |
$json.date | Date received | "2024-12-15T10:30:00Z" |
$json.text | Plain text body | "Hello, your order..." |
$json.html | HTML body | "<html><body>..." |
$json.messageId | Unique message ID | "<[email protected]>" |
$json.cc | CC recipients | "[email protected]" |
$json.bcc | BCC recipients | Usually empty |
Extracting Sender Name and Email
The from field often includes both name and email. Extract them separately:
// Full from field: "John Smith <[email protected]>"
// Extract just the email using regex
{{ $json.from.match(/<(.+)>/)?.[1] ?? $json.from }}
// Returns: [email protected]
// Extract just the name
{{ $json.from.replace(/<.+>/, '').trim() }}
// Returns: John Smith
Working with Email Body
| Scenario | Expression |
|---|---|
| Use plain text body | $json.text |
| Use HTML body | $json.html |
| Prefer text, fallback to HTML | $json.text || $json.html |
| Extract text from HTML | Use 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 Message | Cause | Solution |
|---|---|---|
AUTHENTICATIONFAILED | Wrong username or password | Verify credentials, use App Password for Gmail/Outlook |
Invalid credentials | Password rejected by server | Generate new App Password, check 2FA is enabled |
LOGIN failed | Authentication rejected | Use App Password instead of regular password |
AUTH=PLAIN not supported | Server requires different auth | Enable “Less secure apps” or use App Password |
Connection timeout | Server unreachable | Check host/port, verify firewall allows port 993 |
ETIMEDOUT | Network timeout | Check internet connection, try different network |
ECONNREFUSED | Server rejected connection | Verify IMAP is enabled on mail server |
ENOTFOUND | Invalid hostname | Check IMAP host spelling (e.g., imap.gmail.com) |
Connection closed unexpectedly | IMAP session dropped | Enable Force Reconnect (10-15 min) |
Socket closed unexpectedly | Network interruption | Enable Force Reconnect, check network stability |
certificate has expired | SSL certificate invalid | Update server certificate or disable TLS verification |
self signed certificate | Untrusted certificate | Use proper SSL cert or set Secure to false |
unable to verify the first certificate | Certificate chain issue | Install intermediate certificates on server |
Mailbox doesn't exist | Wrong folder name | Check exact folder name (INBOX, Sent, etc.) |
Mailbox not found | Folder does not exist | Verify folder exists, check case sensitivity |
NO SELECT Mailbox not found | Invalid mailbox path | Use correct path (e.g., INBOX, [Gmail]/Sent Mail) |
Too many simultaneous connections | Provider limit reached | Reduce concurrent Email Trigger workflows |
User is authenticated but not connected | Session state error | Enable Force Reconnect to reset connection |
IMAP connection not available | n8n lost IMAP handle | Restart workflow, enable Force Reconnect |
Gmail-Specific Errors
| Error Message | Cause | Solution |
|---|---|---|
Username and Password not accepted | Regular password used | Create App Password at myaccount.google.com/apppasswords |
Please log in via your web browser | Account security block | Complete security check in Gmail, then retry |
Web login required | Google blocked sign-in | Visit accounts.google.com, verify identity |
Application-specific password required | 2FA enabled, no App Password | Generate 16-character App Password |
IMAP access is disabled | IMAP turned off in Gmail | Enable in Settings > Forwarding and POP/IMAP |
Too many login failures | Rate limited | Wait 1 hour, check credentials are correct |
Outlook and Microsoft 365 Errors
| Error Message | Cause | Solution |
|---|---|---|
Authentication unsuccessful | OAuth or password issue | Use App Password or configure OAuth |
ADALErrorCode: interaction_required | OAuth token expired | Re-authenticate OAuth credentials in n8n |
AUTHENTICATE failed | Modern Auth required | Create App Password in Microsoft account security |
Logon failure: unknown user name or bad password | Invalid credentials | Verify email and App Password |
BasicAuthentication is disabled | Basic auth blocked by admin | Contact admin or use OAuth authentication |
Connection State Errors
| Error Message | Cause | Solution |
|---|---|---|
Not authenticated | Session expired | Enable Force Reconnect (10-15 min) |
Connection ended unexpectedly | Server closed connection | Set Force Reconnect to 5-10 minutes |
read ECONNRESET | Connection reset by server | Check server logs, enable Force Reconnect |
write EPIPE | Broken pipe, connection lost | Enable Force Reconnect, check network |
Timed out while authenticating | Slow network or server | Increase timeout, check network latency |
IDLE not supported | Server lacks IDLE command | n8n uses polling, should still work |
Force Reconnect Best Practices
The Force Reconnect option is critical for production reliability:
- Set to 10-15 minutes for most use cases
- Set to 5 minutes if you notice missed emails
- 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:
- Enable “Continue On Fail” on processing nodes to handle partial failures
- Use the Error Trigger to capture failures and alert your team
- 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-processingorAutomated - 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:
- Send yourself test emails that match your filters
- Verify they trigger the workflow correctly
- Check that all data fields are accessible
- 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
| Setting | Value |
|---|---|
| Host | imap.gmail.com |
| Port | 993 |
| User | Your full Gmail address |
| Password | The 16-character App Password |
| Secure | Yes |
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:
-
Enable Force Reconnect Every Minutes - Set to 10-15 minutes to proactively maintain the connection
-
Use Mark as Read - Creates a clear record of processed emails and prevents reprocessing
-
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:
| Data | Expression |
|---|---|
| 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