← All N8N workflows
Messaging & emailAggregateCodeHTTP RequestIfLimit

Testing Email Header Analysis Workflow

Configured with Aggregate, HTTP Request, Limit, Microsoft Outlook Trigger, and additional nodes. Review the connections and setup before adapting this template.

Workflow preview
TriggerTrigger on New EmailMicrosoft Outlook TriggerWeb / APIRetrieve Headers ofEmailHTTP RequestCodeExtract ReceivedHeadersCodeTransformRemove Extra ReceivedHeadersLimitTransformExtract Original FromIPEdit FieldsWeb / APIQuery IP Quality ScoreAPIHTTP RequestWeb / APIQuery IP APIHTTP RequestRoutingAuthentication-ResultsHeader?IfCodeExtractAuthentication-Results…CodeRoutingReceived-SPF Header?IfRoutingDKIM-Signature Header?IfTransformSet SPF ValueEdit FieldsCodeExtract Received-SPFHeaderCodeTransformDKIM Signature FoundEdit FieldsRoutingDMARC Header?IfTransformNo DMARC HeaderEdit FieldsCodeExtract DMARC HeaderCodeTransformSet DMARC ValueEdit FieldsRoutingOriginal IP Found?IfTransformNo DKIM Signature FoundEdit FieldsTransformDetermine Auth ValuesEdit FieldsTransformNo SPF FoundEdit FieldsTransformMergeMergeTransformAggregateAggregateRoutingNo Operation, donothingNo OpTransformFormat Webhook OutputEdit FieldsTransformFormat Individual AuthOutputsEdit FieldsTransformFormat Combined AuthOutputEdit FieldsWeb / APIRespond to WebhookRespond To WebhookTriggerWebhook1WebhookTransformSet HeadersEdit FieldsTransformAggregate Received-SPFHeadersAggregateTransformSet Headers HereEdit FieldsTransformSet Webhook HeadersHereEdit Fields

Node categories in this workflow

  • Trigger
  • Web / API
  • Code
  • Transform
  • Routing

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
Trigger on New EmailTriggerMicrosoft Outlook TriggerSee node parameters
Retrieve Headers of EmailWeb / APIHTTP RequestSee node parameters
Extract Received HeadersCodeCodeSee node parameters
Remove Extra Received HeadersTransformLimitSee node parameters
Extract Original From IPTransformEdit FieldsSee node parameters
Query IP Quality Score APIWeb / APIHTTP RequestSee node parameters
Query IP APIWeb / APIHTTP RequestSee node parameters
Authentication-Results Header?RoutingIfSee node parameters
Extract Authentication-Results HeaderCodeCodeSee node parameters
Received-SPF Header?RoutingIfSee node parameters
DKIM-Signature Header?RoutingIfSee node parameters
Set SPF ValueTransformEdit FieldsSee node parameters
Extract Received-SPF HeaderCodeCodeSee node parameters
DKIM Signature FoundTransformEdit FieldsSee node parameters
DMARC Header?RoutingIfSee node parameters
No DMARC HeaderTransformEdit FieldsSee node parameters
Extract DMARC HeaderCodeCodeSee node parameters
Set DMARC ValueTransformEdit FieldsSee node parameters
Original IP Found?RoutingIfSee node parameters
No DKIM Signature FoundTransformEdit FieldsSee node parameters
Determine Auth ValuesTransformEdit FieldsSee node parameters
No SPF FoundTransformEdit FieldsSee node parameters
MergeTransformMergeSee node parameters
AggregateTransformAggregateSee node parameters
No Operation, do nothingRoutingNo OpSee node parameters
Format Webhook OutputTransformEdit FieldsSee node parameters
Format Individual Auth OutputsTransformEdit FieldsSee node parameters
Format Combined Auth OutputTransformEdit FieldsSee node parameters
Respond to WebhookWeb / APIRespond To WebhookSee node parameters
Webhook1TriggerWebhookSee node parameters
Set HeadersTransformEdit FieldsSee node parameters
Aggregate Received-SPF HeadersTransformAggregateSee node parameters
Set Headers HereTransformEdit FieldsSee node parameters
Set Webhook Headers HereTransformEdit FieldsSee node parameters

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • microsoftOutlookOAuth2Api

Workflow notes

**Testing Email Header Analysis Workflow**

Testing Email Header Analysis Workflow

This section of the workflow is designed for testing purposes to ensure that the setup functions correctly with your Outlook email client before deploying it as an API for third-party platforms. The process begins with the Trigger on New Email node, which monitors a specified folder in your Outlook mailbox and triggers the workflow whenever a new email arrives. Configured to poll every minute, it ensures timely detection and processing of incoming emails.

Once an email is detected, the Retrieve Headers of Email node uses the Microsoft Graph API to fetch the detailed headers of the new email. These headers contain critical metadata, such as routing information and authentication results, essential for the analysis of the email's origin and legitimacy.

Finally, the Set Headers Here node extracts and organizes the email headers into a standardized format as an array called headers. This structured format prepares the email data for further processing in the subsequent sections of the workflow. By validating these steps, you can confirm the workflow is functioning correctly before integrating it into broader use cases.

**Webhook Integration for Production**

Webhook Integration for Production

This section transitions the workflow into production, enabling it to function as an API for analyzing email headers received from third-party platforms. To utilize this webhook functionality, it is essential to activate the workflow, as the webhook will only respond when the workflow is live.

The Webhook1 node listens for incoming HTTP POST requests at the specified path. When the webhook is triggered, it receives and processes the payload containing email data, including headers sent by the third-party platform. This enables the workflow to operate dynamically with external systems.

The Set Webhook Headers Here node takes the received email data and extracts the headers array from the payload's body. This ensures the incoming data is formatted correctly and ready for further processing in subsequent steps of the workflow.

By activating the workflow and integrating it with external systems, users can automate the analysis of email headers seamlessly in a production environment.

**Extract and Process Email Headers**

Extract and Process Email Headers

This section processes the headers from incoming email data to extract critical information, particularly focusing on the originating IP address. The workflow begins with the Set Headers node, which takes the headers provided from the previous nodes and prepares them for analysis.

The Extract Received Headers node filters through the headers and isolates those labeled as "Received." These headers document the servers through which the email has passed, providing a traceable path of its journey. Next, the Remove Extra Received Headers node narrows the focus to the most recent "Received" header, which typically contains the originating IP address of the email sender.

Using the Extract Original From IP node, the workflow applies a regular expression to extract the IP address from the retained header, removing any internal or private IP addresses that might be present. This ensures that only the relevant external IP address is identified.

**Analyze IP Address and Check Authentication Results**

Analyze IP Address and Check Authentication Results

This section focuses on analyzing the originating IP address and verifying the presence of essential email authentication headers. The workflow begins with the Original IP Found? node, which evaluates whether the extracted IP address is valid and non-empty. If a valid IP address is found, the workflow proceeds; otherwise, it triggers the No Operation, do nothing node to halt further processing.

The Query IP Quality Score API node interacts with the IP Quality Score service, evaluating the IP’s reputation. This analysis identifies whether the IP is associated with spam, fraud, or other malicious activities. The results help determine the sender's trustworthiness.

Next, the Query IP API node provides additional contextual information about the IP address, including geographical details (e.g., country, city) and the organization associated with the IP. This information enriches the analysis, offering insights into the sender’s origin.

The Authentication-Results Header? node checks for the presence of the "Authentication-Results" header in the email. This header indicates the results of SPF, DKIM, and DMARC checks performed by the receiving email server. If present, the workflow proceeds to analyze the header further in subsequent sections.

By validating the IP address and analyzing its reputation, this section ensures a comprehensive understanding of the email's legitimacy before moving forward in the workflow.

**Extract and Evaluate Authentication Results**

Extract and Evaluate Authentication Results

If the header is found, the workflow proceeds to the Extract Authentication-Results Header node, which isolates the relevant header and extracts its contents. This allows the workflow to parse the authentication results systematically.

Next, the Determine Auth Values node processes the extracted data, determining the status of SPF, DKIM, and DMARC. It categorizes each result as pass, fail, neutral, error, or unknown based on the information present in the header. This step ensures a clear understanding of the email's adherence to authentication protocols.

Finally, the Format Combined Auth Output node aggregates the authentication results with other relevant metadata, such as the originating IP, sender's organization, and geographical location, obtained from previous steps. Additionally, it evaluates the IP's reputation and recent spam activity using the data from the IP Quality Score API. This structured output provides a comprehensive overview of the email's security and legitimacy, making it ready for integration with external systems or reporting tools.

**Combine Results and Respond to Webhook**

Combine Results and Respond to Webhook

This final section consolidates the results from previous nodes and prepares the data for delivery via a webhook response. It ensures all authentication checks and metadata are aggregated into a cohesive output.

The process begins with the Merge node, which combines data streams from SPF, DKIM, and DMARC evaluations. The aggregated data is then processed by the Aggregate node, which organizes the results into a unified dataset.

Next, the Format Individual Auth Outputs node formats the consolidated data into a structured JSON object. This output includes the SPF, DKIM, and DMARC results, as well as additional metadata such as the originating IP address, sender’s organization, geographical location, IP reputation, and recent spam activity. Each field is clearly labeled to ensure compatibility with external systems.

The formatted output is passed to the Format Webhook Output node, which finalizes the response structure for the webhook. The Respond to Webhook node then sends this structured response back to the calling system. This enables seamless integration with third-party platforms, allowing them to use the results for further analysis or automation.

By combining and formatting all authentication data, this section ensures that the workflow delivers clear, actionable insights to the consuming system, completing the email analysis pipeline.

**Evaluate SPF, DKIM, and DMARC Compliance**

Evaluate SPF, DKIM, and DMARC Compliance

This section focuses on detailed analysis and validation of SPF, DKIM, and DMARC headers. Each authentication mechanism is evaluated to determine its status, providing critical insights into the email’s legitimacy and adherence to security protocols.

The workflow begins with the Received-SPF Header? node, which checks if the "Received-SPF" header exists. If found, the workflow proceeds to the Extract Received-SPF Header node to isolate the SPF validation results. These results are aggregated and analyzed using the Aggregate Received-SPF Headers node, with the final outcome recorded by the Set SPF Value node. If no SPF header is found, the workflow instead records this absence using the No SPF Found node.

The DKIM-Signature Header? node performs a similar function for DKIM validation, checking for the presence of a DKIM signature. If the header is found, the DKIM Signature Found node confirms its presence, while the No DKIM Signature Found node handles its absence.

The DMARC Header? node checks for the presence of a DMARC header, indicating compliance with the domain’s published DMARC policy. If present, the workflow extracts and evaluates it via the Extract DMARC Header and Set DMARC Value nodes. If the header is missing, the No DMARC Header node records this information.

By systematically evaluating these headers, the workflow provides a comprehensive understanding of the email's authentication status. This granular analysis strengthens email security by detecting potential spoofing or misconfigurations in the sender’s authentication setup.

Testing Email Header Analysis Workflow

Testing Email Header Analysis Workflow

Purpose and structure

This folder contains the Testing Email Header Analysis Workflow workflow. Its executable nodes use aggregate, code, httpRequest, if, limit, merge, microsoftOutlookTrigger, noOp, respondToWebhook, set, webhook. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

Trigger on New Email, Webhook1

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Limit/0673_Limit_Code_Create_Webhook.json MIT; preserve source notices.

More in Messaging & email