https://github.com/avvertix/dmarc-report-parser
Parse DMARC reports
https://github.com/avvertix/dmarc-report-parser
dmarc dmarc-parser dmarc-reports
Last synced: 5 months ago
JSON representation
Parse DMARC reports
- Host: GitHub
- URL: https://github.com/avvertix/dmarc-report-parser
- Owner: avvertix
- License: mit
- Created: 2024-12-27T20:24:38.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-01-12T15:26:59.000Z (6 months ago)
- Last Synced: 2026-01-12T21:36:32.440Z (6 months ago)
- Topics: dmarc, dmarc-parser, dmarc-reports
- Language: PHP
- Homepage:
- Size: 49.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# DMARC Report Parser
[](https://packagist.org/packages/avvertix/dmarc-report-parser)
[](https://github.com/avvertix/dmarc-report-parser/actions/workflows/run-tests.yml)
[](https://packagist.org/packages/avvertix/dmarc-report-parser)
DMARC Report Parser is designed to simplify the analysis of [DMARC](https://dmarc.org/) (Domain-based Message Authentication, Reporting & Conformance) reports:
- Parse the XML-based report into fully typed classes
- Read reports from GZip files without decompressing first (coming soon)
## Installation
You can install the package via composer:
```bash
composer require avvertix/dmarc-report-parser
```
Require PHP 8.3 with `xsl` and `sodium` extensions.
## Usage
It is possible to parse reports from XML files or strings. The output is fully typed instance of `DmarcReport`.
**from file**
```php
$dmarc = new Avvertix\DmarcReportParser\DmarcReportParser();
/**
* @var Avvertix\DmarcReportParser\Data\DmarcReport
*/
$report = $dmarc->fromFile('path/to/report.xml');
```
**from string**
```php
$dmarc = new Avvertix\DmarcReportParser\DmarcReportParser();
$xml = <<<'DMARC'
1.0
DMARC;
/**
* @var Avvertix\DmarcReportParser\Data\DmarcReport
*/
$report = $dmarc->fromString($xml);
```
**DmarcReport class**
The [`DmarcReport`](./src/Data/DmarcReport.php) class represent the report in a fully typed manner.
A few differences with respect to the spec:
- Report generator metadata are directly accessible from the `DmarcReport` class and not encapsulated in an object
- Records are exposed using the `records` (array) property
- In AuthResult both dkim and spf properties are represented as arrays
- In general when the spec report an element to be available multiple times we represent it as an array property
## Testing
DMARC Report Parser is covered in unit test. The [PestPHP](https://pestphp.com/) framework is used. To run the whole test suite execute the `test` script.
```bash
composer test
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Alessio Vertemati](https://github.com/avvertix)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.