8
n8n 中文网amn8n.com

DMARC

中级

这是一个自动化工作流,包含 11 个节点。主要使用 Set, Xml, Gmail, Compression, ExtractFromFile 等节点。 通过Gmail自动化将DMARC报告转换为可读表格

前置要求
  • Google 账号和 Gmail API 凭证

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "ChyUpdqplMMK9goy",
  "meta": {
    "instanceId": "406735dbfbf26e97ce8cf19138586c11b62ae90e41ae49e03d25818ac92174c0",
    "templateCredsSetupCompleted": true
  },
  "name": "dmarc",
  "tags": [],
  "nodes": [
    {
      "id": "20c68419-20da-4d03-bdbb-ef724420814d",
      "name": "解压缩",
      "type": "n8n-nodes-base.compression",
      "position": [
        32,
        -768
      ],
      "parameters": {
        "binaryPropertyName": "attachment_0"
      },
      "typeVersion": 1.1
    },
    {
      "id": "279e9ea7-0c62-41dd-8275-4db569b5e30d",
      "name": "xml",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        256,
        -768
      ],
      "parameters": {
        "options": {},
        "operation": "xml",
        "binaryPropertyName": "file_0"
      },
      "typeVersion": 1
    },
    {
      "id": "01b3cacd-ea7d-4a83-9514-6dc885e58f61",
      "name": "xml2json",
      "type": "n8n-nodes-base.xml",
      "position": [
        480,
        -768
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "132c9c80-b18b-4b25-9b17-0c1bbfdd3df4",
      "name": "设置",
      "type": "n8n-nodes-base.set",
      "position": [
        704,
        -768
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "3c2dc439-7fb0-4329-b911-d10d279c9595",
              "name": "table",
              "type": "string",
              "value": "=<table border=\"1\" cellpadding=\"4\" cellspacing=\"0\" style=\"width:100%; max-width:760px; border-collapse:collapse; margin:12px 0;\">\n<tr>\n    <th colspan=\"4\" align=\"left\" style=\"text-align:left; padding:6px 8px;\">\n      <strong>{{$json[\"feedback\"][\"report_metadata\"][\"org_name\"]}}</strong> → \n      {{$json[\"feedback\"][\"policy_published\"][\"domain\"]}}\n      <code style=\"white-space:normal; word-break:break-all; font-family:Courier, monospace; margin-left:4px;\">\n        [v=DMARC1; p={{$json[\"feedback\"][\"policy_published\"][\"p\"]}};]\n      </code>\n    </th>\n  </tr>\n  \n  <!-- Records header -->\n<tr>\n  <th align=\"left\" style=\"text-align:left;\">IP</th>\n  <th align=\"left\" style=\"text-align:left;\">Count</th>\n  <th align=\"left\" style=\"text-align:left;\">DKIM</th>\n  <th align=\"left\" style=\"text-align:left;\">SPF</th>\n</tr>\n\n  <!-- Records rows -->\n  {{\n    Array.isArray($json[\"feedback\"][\"record\"])\n      ? $json[\"feedback\"][\"record\"].map(r => `\n        <tr>\n          <td><code>${r.row.source_ip}</code></td>\n          <td style=\"text-align:right;\">${r.row.count}</td>\n          <td style=\"text-align:left;\">${r.row.policy_evaluated.dkim}</td>\n          <td style=\"text-align:left;\">${r.row.policy_evaluated.spf}</td>\n        </tr>\n      `).join('')\n      : `<tr>\n          <td><code>${$json[\"feedback\"][\"record\"][\"row\"][\"source_ip\"]}</code></td>\n          <td style=\"text-align:left;\">${$json[\"feedback\"][\"record\"][\"row\"][\"count\"]}</td>\n          <td style=\"text-align:left;\">${$json[\"feedback\"][\"record\"][\"row\"][\"policy_evaluated\"][\"dkim\"]}</td>\n          <td style=\"text-align:left;\">${$json[\"feedback\"][\"record\"][\"row\"][\"policy_evaluated\"][\"spf\"]}</td>\n        </tr>`\n  }}\n</table>\n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1d46956f-93c6-402d-9ae1-df4636920b18",
      "name": "发送",
      "type": "n8n-nodes-base.gmail",
      "position": [
        928,
        -768
      ],
      "webhookId": "c228f548-2582-4586-b2df-160eb90e73ff",
      "parameters": {
        "sendTo": "cooper@shownotes.io",
        "message": "={{ $json.table }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $('xml2json').item.json.feedback.report_metadata.org_name }} DMARC Report for {{ $('xml2json').item.json.feedback.policy_published.domain }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "11",
          "name": "shownotes"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "d4e0902d-a50f-46aa-a800-e342aabe3358",
      "name": "cron",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -416,
        -768
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 13
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8f154531-edde-43fd-8547-94ece2527a2b",
      "name": "dmarc",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -192,
        -768
      ],
      "webhookId": "67ccf0cf-780c-4365-bb67-71c740c42425",
      "parameters": {
        "limit": 5,
        "simple": false,
        "filters": {
          "q": "from:(noreply@dmarc.yahoo.com OR noreply-dmarc-support@google.com) in:anywhere",
          "receivedAfter": "={{ $now - 24 * 60 * 60 * 1000 }}"
        },
        "options": {
          "downloadAttachments": true
        },
        "operation": "getAll"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "11",
          "name": "shownotes"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "4a12a76b-3924-43d6-ab5b-c602a9fb4fe0",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        -864
      ],
      "parameters": {
        "width": 288,
        "content": "通过邮件发送报告。"
      },
      "typeVersion": 1
    },
    {
      "id": "219325bb-86f9-44d7-be9a-a25ddca52775",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        -864
      ],
      "parameters": {
        "width": 544,
        "content": "将 XML 转换为 JSON。"
      },
      "typeVersion": 1
    },
    {
      "id": "d8218575-9846-436c-b429-4a33a6f3d721",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        -864
      ],
      "parameters": {
        "width": 368,
        "content": "获取 DMARC 报告并下载附件报告。"
      },
      "typeVersion": 1
    },
    {
      "id": "9b8f2ae9-f804-4d02-bc33-1a9e43611e06",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -592,
        -864
      ],
      "parameters": {
        "width": 368,
        "height": 112,
        "content": "Gmail 和 Yahoo 发送的 DMARC 报告是难以阅读的 zip/gz xml 文件。此工作流会解压它们,将数据转换为简单表格,并通过邮件发送易于阅读的报告"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "60cd2143-f4a7-46a8-8e96-3a3cb13eaedd",
  "connections": {
    "set": {
      "main": [
        [
          {
            "node": "send",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "xml": {
      "main": [
        [
          {
            "node": "xml2json",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cron": {
      "main": [
        [
          {
            "node": "dmarc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "dmarc": {
      "main": [
        [
          {
            "node": "unzip",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "unzip": {
      "main": [
        [
          {
            "node": "xml",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "xml2json": {
      "main": [
        [
          {
            "node": "set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量11
分类-
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流