JMAP Email Polling and Unread Message Retrieval - n8n Workflow

Use this powerful n8n workflow to poll unread emails from JMAP compliant providers like Fastmail. Learn how to construct complex JMAP queries using the n8n HTTP Request node.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Users needing custom email polling solutions outside of standard IMAP/POP3.

  • Fastmail users looking to automate actions based on new emails.

  • n8n developers seeking advanced examples of chained HTTP Request nodes and complex JSON pathing.

  • Automation specialists building custom email parsers using the n8n platform.

Overview

While many email providers rely on standard protocols, modern services like Fastmail utilize the robust JMAP (JSON Mail Access Protocol) standard. This advanced n8n workflow provides a blueprint for integrating directly with JMAP APIs. By chaining multiple HTTP requests, this specific n8n workflow first retrieves necessary session and account IDs, then dynamically finds the Inbox ID, and finally executes a combined query/get operation to fetch the details of the top 3 unread messages. This highly customizable approach ensures that you can implement sophisticated email filtering and processing within any n8n automation.

How it Works

This n8n automation uses a manual n8n trigger for immediate execution, suitable for scheduled polling or testing.


  1. Session Setup: The process begins by using the first n8n node, an HTTP Request, to fetch the JMAP session details, obtaining crucial primary account IDs.

  2. Mailbox Identification: The subsequent HTTP Request n8n node uses the account ID to call the Mailbox/get method, identifying the unique mailboxid for the Inbox.

  3. Data Preparation: A Set n8n node processes the results, isolating the required accountid and mailbox_id for the final step.

  4. Email Polling: The final HTTP Request n8n node executes a compound JMAP request. It first performs an Email/query to find the IDs of the top 3 unread emails in the Inbox (notKeyword: "$seen"). It then uses those IDs in a subsequent Email/get call within the same request to retrieve the full details (sender, subject, date) of those messages. This detailed setup showcases powerful logic within a single n8n node, making this a useful n8n template for complex API interactions.

Installation Guide

To use this n8n template, follow these steps:


  1. Import: Copy the provided n8n workflow JSON and import it into your n8n instance.

  2. Credentials Setup: This n8n workflow requires HTTP Header Authentication for JMAP access (e.g., Fastmail).

Create new credentials of type 'HTTP Header Auth'.
Set the Header Name to Authorization.
Set the Header Value to Bearer $apiToken (replacing $apiToken with your actual token from the service provider).
Ensure all three HTTP Request n8n nodes (Fetch API details, Get mailboxes, Get unread messages) are linked to these new credentials.

  1. Execution: Once credentials are set, click 'Execute Workflow' to test the n8n trigger and retrieve the latest unread messages.

Node Details

When clicking "Execute Workflow" (n8n trigger): A manual n8n trigger used for immediate execution or for testing the workflow logic before setting up a Schedule trigger.
Fetch API details (HTTP Request n8n node): Fetches the primary JMAP session details from /jmap/session. Key function: Retrieves the required accountId for mail operations.
Get mailboxes (HTTP Request n8n node): Uses the JMAP /api/ endpoint to execute the Mailbox/get method call. Key Configuration: Dynamic pathing using expressions to pull the account ID from the previous n8n node output.
Format results (Set n8n node): Essential n8n node for data preparation. Key Configuration: Uses expressions to extract the specific Mail account ID and searches the mailbox list to find the ID of the 'inbox' role, ensuring the subsequent query targets the correct mailbox.


  • Get unread messages (HTTP Request n8n node): The core polling n8n node. Key Configuration: Executes a chained method call (Email/query followed by Email/get) to efficiently locate and fetch the top 3 unread emails based on the provided accountid and mailboxid.

Related n8n Workflows

Free

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by

Featured*