NAME

Mail::STS::Policy - class to parse and generate RFC8461 policies

VERSION

version 0.05

SYNOPSIS

# generate a policy
my $policy = Mail::STS::Policy->new(
  mode => 'enforce',
  max_age => 604800,
  mx => [ 'mail.example.com' ],
);
# setters
$policy->mode('testing');
$policy->add_mx('mail.example.com');
print $policy->as_string;

# parse existing policy
my $policy = Mail::STS::Policy->new_from_string($string);
# access values
$policy->mode;
# 'enforce'
$policy->mx;
# [ 'mail.example.com' ]

# check if a host is in there
$policy->match_mx('mail.blablub.de') or die;

ATTRIBUTES

version (default: 'STSv1')

Currently always version 'STSv1'.

mode (default: 'none')

Get/set mode of policy.

max_age (default: undef)

Get/set max_age for policy caching.

mx (default: [])

Array reference to array of mx hosts.

METHODS

new_from_string($string)

Constructor for creating a new policy object from a policy string.

Internally creates objects by calling new() and execute parse() on it.

parse($string)

Parses values from $string to values in the object overwriting and clearing all existing values.

Will die() on parsing error.

as_hash

Returns a hash reference containing policy data.

$policy->as_hash
# {
#   'version' => 'STSv1',
#   'mode' => 'enforce',
#   'max_age' => 3600,
#   'mx' => [ 'mx.example.com', ... ],
# }

as_string

Outputs the object as a RFC8461 policy document.

match_mx($host)

Returns if the policy matches $host.

$policy->match_mx('mail.example.com') or die;

AUTHOR

Markus Benning <ich@markusbenning.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2018 by Markus Benning <ich@markusbenning.de>.

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