Skip to main content

Parse DMARC reports, save them in database and notify on DKIM or SPF error

Workflow preview

Workflow preview
100%
Parse DMARC reports, save them in database and notify on DKIM or SPF error preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Who is it for If you are a postmaster or you manage email server, you can set up DKIM and SPF records to ensure that spoofing your email address is hard. On your domain you can also set up DMARC re...

Best for

  • SecOps automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.emailreadimap, n8n-nodes-base.datetime, n8n-nodes-base.if, n8n-nodes-base.set, n8n-nodes-base.mysql, n8n-nodes-base.renamekeys, n8n-nodes-base.stickynote, n8n-nodes-base.compression

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Łukasz.

Original n8n.io source

1.1 Workflow description

Title
Parse DMARC reports, save them in database and notify on DKIM or SPF error
Workflow name
Parse DMARC reports, save them in database and notify on DKIM or SPF error

Who is it for

If you are a postmaster or you manage email server, you can set up DKIM and SPF records to ensure that spoofing your email address is hard. On your domain you can also set up DMARC record to receive XML reports from email providers (rua tag). Those reports contain data if email they received passed DKIM and SPF verifications.

Since DMARC email is public, you will receive a lot of emails from email providers, not only if DKIM/SPF fail. There is no need for it - you probably only need to know if SPF/DKIM failed.

So this script is intended to automatically parse all DMARC reports that come from email providers, but ONLY send you notification if SPF or DKIM failed - meaning that either someone tries to spoof your email or your DKIM/SPF is improperly set up.

How it works

  • script monitors postmaster email for DMARC reprots (rua)
  • unpacks report and parses XML into JSON
  • maps JSON and formats fields for MySQL/MariaDB input
    • inputs into database
    • sends notification on DKIM or SPF failure

Remember to set up

  • email input mailbox
  • notification channels
    • for slack
    • for email

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Email Trigger (IMAP)

Type / Role
n8n-nodes-base.emailReadImap - emailReadImap
Config choices
Version 2

Block 2 - End date format

Type / Role
n8n-nodes-base.dateTime - dateTime
Config choices
Version 2

Block 3 - If multiple records to parse

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 4 - Map fields for DB input and parse

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 5 - Begin format date

Type / Role
n8n-nodes-base.dateTime - dateTime
Config choices
Version 2

Block 6 - Input into database

Type / Role
n8n-nodes-base.mySql - mySql
Config choices
Version 2.4

Block 7 - If issue with DKIM or SPF

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 8 - Rename Keys

Type / Role
n8n-nodes-base.renameKeys - renameKeys
Config choices
Version 1

Block 9 - Rename column for consistency

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 10 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Unzip File

Type / Role
n8n-nodes-base.compression - compression
Config choices
Version 1.1

Block 12 - Extract XML data

Type / Role
n8n-nodes-base.extractFromFile - extractFromFile
Config choices
Version 1

Block 13 - Parse XML data to JSON

Type / Role
n8n-nodes-base.xml - xml
Config choices
Version 1

Block 14 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Split Out For Separate Entries

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 17 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 19 - Slack Post Message On Channel

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.2

Block 20 - Send Error Notification Email

Type / Role
n8n-nodes-base.emailSend - emailSend
Config choices
Version 2.1

3. Summary Table

Workflow Parse DMARC reports, save them in database and notify on DKIM or SPF error
Complexity advanced
Nodes 20
Categories SecOps
Author Łukasz
Published 29 Jul 2024

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/2369/2369.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Parse DMARC reports, save them in database and notify on DKIM or SPF error do?

Who is it for If you are a postmaster or you manage email server, you can set up DKIM and SPF records to ensure that spoofing your email address is hard. On your domain you can also set up DMARC re...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your SecOps use case.