Mail::...eceive(3pm)

πŸ’Œ NAME πŸ’Œ

Mail::DMARC::Report::Receive β€” okay so bestie, this module's whole main character energy is to process incoming DMARC reports. It lives under User Contributed Perl Documentation, and the page title is Mail::...eceive(3pm) (yes, the dramatic ellipsis is real, iykyk).

🌈 VERSION 🌈

version 1.20260306 β€” that's the version, periodt. Slay.

πŸ¦‹ DESCRIPTION πŸ¦‹

Receive DMARC reports and save them to the report store/database. Highkey short, iconic, and literally the whole point.

πŸ’… METHODS πŸ’…

πŸŽ€ from_imap, from_file, from_mbox πŸŽ€

These methods are called by dmarc_receive program, which has its own documentation and usage instructions. No cap.

from_file accepts a file path and auto-detects the file type:

  • gzip (magic bytes \x1f\x8b) β€” decompresses with IO::Uncompress::Gunzip and parses as XML
  • zip (magic bytes PK\x03\x04) β€” decompresses with IO::Uncompress::Unzip and parses as XML
  • XML (content starting with <) β€” parses directly
  • email message β€” falls back to passing the file to from_email_simple

Ngl, that auto-detect list is a flex. from_imap and from_mbox accept a message (or list of messages) and create an Email::Simple object from each, passing that object to from_email_simple. Obsessed with the delegation.

πŸ’Œ from_email_simple πŸ’Œ

Accepts an Email::Simple message object. Returns the type of DMARC report detected or undef if no DMARC report was detected.

When forensic reports are detected, no further processing is done. Not me expecting more β€” it's literally no further processing.

When an aggregate report is detected, the report details are extracted from the message body as well as the Subject field/header and attachment metadata.

Parsing of the Subject and MIME metadata is necessary because the 2013 draft DMARC specification does not REQUIRE the envelope_to domain name to be included in the XML report. For example, the only way to know that the email which generated this particular report was sent to hotmail.com is to extract the envelope_to domain from the message metadata (Org Name=Microsoft, hotmail.com is not in the XML). So far, every messsage I have seen has had the envelope_to domain in one location or the other. The way that metadata does the heavy lifting β€” fr fr, it ate.

To extract messages from the message body, the MIME attachments are decompressed and passed to handle_body.

🧚 handle_body 🧚

Accepts a XML message, parsing it with XML::LibXML and XPath expressions. The parsed data is stored in a Mail::DMARC::Report object. When the parsing is complete, the report object is saved to the report store. Lowkey satisfying: parse, store, slay.

πŸ‘‘ AUTHORS πŸ‘‘

  • Matt Simerson <msimerson@cpan.org>
  • Davide Migliavacca <shari@cpan.org>
  • Marc Bradshaw <marc@marcbradshaw.net>

Iconic trio, honestly.

This software is copyright (c) 2026 by Matt Simerson.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


Cute footer sign-off: this page comes from perl v5.40.1, dated 2026-07-07, and the footer still says Mail::...eceive(3pm). Bye bestie, go process those reports 🫢✨

πŸ“¦ where this page comes from