If you administer your own mail domain and set up DMARC and SPF policies accordingly, inadvertently you will get a lot of reports in your inbox to sift through. To make your life easier, just save all your xml-reports into a directory and let this script run through and notify you just in case of a failed delivery.
This script defines a function parse_dmarc_report to check if a DMARC report indicates a failed delivery. The process_dmarc_reports function iterates through all XML files in the specified directory, calls the parsing function, and prints a message if a failed delivery is detected.
- Make sure to replace 'your_directory_path' in the script with the actual path to your directory containing the DMARC XML files.
- Run the script:
python parse_DMARC_failed_delivery.PY - Profit!
Sometimes DMARC reports extracted from E-mails will save into subdirectories, which makes it neccessary to move a lot of files from there into the script directory. Just execute this script to move each file from it's subdirectory to where it belongs.
bash move_subdirectory_files.sh