cbowofrivia/dmarc-record-builder

A lean package that makes creating DMARC records user friendly

2.0.0 2024-04-20 07:22 UTC

README

Latest Version on Packagist Tests Total Downloads

Installation

You can install the package via composer:

composer require cbowofrivia/dmarc-record-builder

Usage

$record = new DmarcRecord();

$record->policy('none')
    ->subdomainPolicy('none')
    ->pct(100)
    ->rua('mailto:charlesrbowen93@gmail.com')
    ->ruf('mailto:charlesrbowen93@gmail.com')
    ->adkim('relaxed')
    ->aspf('relaxed')
    ->reporting('any')
    ->interval(604800);

$record = (string) $record;
// v=DMARC1; p=none; sp=none; pct=100; rua=mailto:charlesrbowen93@gmail.com; ruf=mailto:charlesrbowen93@gmail.com; fo=1; adkim=r; aspf=r; ri=604800;

You can also build the record in the constructor

$record = new DmarcRecord(
    version: 'DMARC1'
    policy: 'none'
    subdomain_policy: 'none'
    pct: 100
    rua: 'mailto:charlesrbowen93@gmail.com'
    ruf: 'mailto:charlesrbowen93@gmail.com'
    adkim: 'relaxed'
    aspf: 'relaxed' 
    reporting: 'any'
    interval: 604800
);

$record = (string) $record;
// v=DMARC1; p=none; sp=none; pct=100; rua=mailto:charlesrbowen93@gmail.com; ruf=mailto:charlesrbowen93@gmail.com; fo=1; adkim=r; aspf=r; ri=604800;

Testing

composer test

If you're using WSL2 + Docker, you can install and test with the provided docker-compose.yaml file.

docker-compose run --rm php composer install && \
docker-compose run --rm php composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.