How we built DMARC Management using Cloudflare Workers
Mar 17, 2023André Cruz, Nelson Duarte

Summary
This post details the technical implementation of Cloudflare's DMARC Management feature, which leverages Cloudflare Workers and Email Routing to process incoming DMARC reports. It outlines the architecture involving Email Workers for receiving and parsing emails, Workers KV for domain information storage, Workers Analytics Engine for publishing report details to an analytics platform, and R2 object storage for long-term storage of raw reports. The post provides code snippets demonstrating how to extract RUA IDs, fetch account information, parse email content using postal-mime, and store compressed reports in R2.
More from the Email Infrastructure & Protocols trail
- Cloudflare DMARC Management is now generally available
- Email for agents - Cloudflare Email Service now in public beta
- Announcing Cloudflare Email Service’s private beta
- The role of email security in reducing user risk amid rising threats
- How Cloudflare Cloud Email Security protects against the evolving threat of QR phishing