« lib/Mail/DMARC/Report/Send/SMTP.pm
↑ Summary
lib/Mail/DMARC/Report/Aggregate/Record/Auth_Results.pm »
| 1 | package Mail::DMARC::Result; | ||||||||||||||||||||||||||||||||||||||
| 2 | 11 | our $VERSION = '2.20260827'; | |||||||||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use feature 'signatures'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | 11 | ▶ | no warnings 'experimental::args_array_with_signatures'; ## no critic (ProhibitNoWarnings) | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 9 | 11 | require Mail::DMARC::Result::Reason; | |||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | 57 | ▶ | sub new($class) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 12 | 57 | return bless { | |||||||||||||||||||||||||||||||||||||
| 13 | dkim => '', | ||||||||||||||||||||||||||||||||||||||
| 14 | spf => '', | ||||||||||||||||||||||||||||||||||||||
| 15 | reason => [], | ||||||||||||||||||||||||||||||||||||||
| 16 | }, | ||||||||||||||||||||||||||||||||||||||
| 17 | $class; | ||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||
| 20 | 158 | ▶ | sub published( $self, $policy = undef ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
published: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 21 | 158 | ▶ | if ( !$policy ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 22 | 105 | ▶ | if ( !defined $self->{published} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 23 | 1 | croak | |||||||||||||||||||||||||||||||||||||
| 24 | "no policy discovered. Did you validate(), or at least fetch_dmarc_record() first? Or inspected results to detect a 'No Results Found' type error?"; | ||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||
| 26 | 104 | return $self->{published}; | |||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||
| 29 | $policy->{domain} | ||||||||||||||||||||||||||||||||||||||
| 30 | 53 | ▶ | or croak | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 31 | "tag the policy object with a domain indicating where the DMARC record was found!"; | ||||||||||||||||||||||||||||||||||||||
| 32 | 52 | return $self->{published} = $policy; | |||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||
| 35 | 128 | ▶ | sub disposition( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
disposition: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 36 | 128 | ▶ | return $self->{disposition} if @_ == 1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 37 | croak 'invalid disposition: ' . ( $val // '(undef)' ) | ||||||||||||||||||||||||||||||||||||||
| 38 | 101 | ▶ | if !defined $val || 0 == grep {/^$val$/ix} qw/ reject quarantine none /; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
not defined $val or 0 == grep({/^$val$/xi;} "reject", "quarantine", "none")
$val // "(undef)"
MC/DC50%1/2
not defined $val or 0 == grep({/^$val$/xi;} "reject", "quarantine", "none")
not defined $val
0 == grep({/^$val$/xi;} "reject", "quarantine", "none")
MC/DC0%0/1
$val // "(undef)"
$val
Truth table66%2/3
not(A) or B
A= not defined $valB= 0 == grep({/^$val$/xi;} "reject", "quarantine", "none")
Truth table50%1/2
A
A= $val
| |||||||||||||||||||||||||||||||||||||||
| 39 | 95 | return $self->{disposition} = $val; | |||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||
| 42 | 162 | ▶ | sub dkim( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
dkim: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 43 | 162 | ▶ | return $self->{dkim} if @_ == 1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 44 | 74 | ▶ | croak "invalid dkim" if 0 == grep {/^$val$/ix} qw/ pass fail /; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 45 | 70 | return $self->{dkim} = $val; | |||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||
| 48 | 19 | ▶ | sub dkim_align( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
dkim_align: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 49 | 19 | ▶ | return $self->{dkim_align} if @_ == 1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 50 | croak "invalid dkim_align" | ||||||||||||||||||||||||||||||||||||||
| 51 | 18 | ▶ | if 0 == grep {/^$val$/ix} qw/ relaxed strict /; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 52 | 14 | return $self->{dkim_align} = $val; | |||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||
| 55 | 15 | ▶ | sub dkim_meta( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
dkim_meta: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 56 | 15 | ▶ | return $self->{dkim_meta} if @_ == 1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 57 | 13 | return $self->{dkim_meta} = $val; | |||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||
| 60 | 171 | ▶ | sub spf( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
spf: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 61 | 171 | ▶ | return $self->{spf} if @_ == 1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 62 | 71 | ▶ | croak "invalid spf" if 0 == grep {/^$val$/ix} qw/ pass fail /; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 63 | 67 | return $self->{spf} = $val; | |||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||
| 66 | 26 | ▶ | sub spf_align( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
spf_align: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 67 | 26 | ▶ | return $self->{spf_align} if @_ == 1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 68 | 22 | ▶ | croak "invalid spf_align" if 0 == grep {/^$val$/ix} qw/ relaxed strict /; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 69 | 18 | return $self->{spf_align} = $val; | |||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||
| 72 | 95 | ▶ | sub result( $self, $val = undef ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
result: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 73 | 95 | ▶ | return $self->{result} if @_ == 1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 74 | croak "invalid result" | ||||||||||||||||||||||||||||||||||||||
| 75 | 81 | ▶ | if !defined $val || 0 == grep {/^$val$/ix} qw/ pass fail none /; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $val or 0 == grep({/^$val$/xi;} "pass", "fail", "none")
MC/DC100%2/2
not defined $val or 0 == grep({/^$val$/xi;} "pass", "fail", "none")
not defined $val
0 == grep({/^$val$/xi;} "pass", "fail", "none")
Truth table100%3/3
not(A) or B
A= not defined $valB= 0 == grep({/^$val$/xi;} "pass", "fail", "none")
| |||||||||||||||||||||||||||||||||||||||
| 76 | 76 | return $self->{result} = $val; | |||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||
| 79 | 49 | ▶ | sub reason( $self, @args ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
reason: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 80 | 49 | ▶ | return $self->{reason} if !@args; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 81 | 28 | push @{ $self->{reason} }, Mail::DMARC::Result::Reason->new(@args); | |||||||||||||||||||||||||||||||||||||
| 82 | 22 | return $self->{reason}; | |||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||
| 85 | 11 | 1; | |||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||
| 87 | __END__ | ||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||
| 89 | =pod | ||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||
| 91 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||
| 93 | Mail::DMARC::Result - an aggregate report result object | ||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||
| 95 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||
| 97 | version 2.20260827 | ||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||
| 99 | =head1 OVERVIEW | ||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||
| 101 | A L<Result|Mail::DMARC::Result> object is the product of instantiating a L<DMARC::PurePerl|Mail::DMARC::PurePerl> object, populating the variables, and running $dmarc->validate. The results object looks like this: | ||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||
| 103 | result => 'pass', # pass, fail | ||||||||||||||||||||||||||||||||||||||
| 104 | disposition => 'none', # reject, quarantine, none | ||||||||||||||||||||||||||||||||||||||
| 105 | reason => [ # there can be many reasons... | ||||||||||||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||||||||||||
| 107 | type => '', # forwarded, sampled_out, trusted_forwarder, | ||||||||||||||||||||||||||||||||||||||
| 108 | comment => '', # mailing_list, local_policy, other | ||||||||||||||||||||||||||||||||||||||
| 109 | }, | ||||||||||||||||||||||||||||||||||||||
| 110 | ], | ||||||||||||||||||||||||||||||||||||||
| 111 | dkim => 'pass', # pass, fail | ||||||||||||||||||||||||||||||||||||||
| 112 | dkim_align => 'strict', # strict, relaxed | ||||||||||||||||||||||||||||||||||||||
| 113 | spf => 'pass', # pass, fail | ||||||||||||||||||||||||||||||||||||||
| 114 | spf_align => 'strict', # strict, relaxed | ||||||||||||||||||||||||||||||||||||||
| 115 | published => L<Mail::DMARC::Policy>, | ||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||
| 117 | Reasons are optional and may not be present. | ||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||
| 119 | The dkim_align and spf_align fields will only be present if the corresponding test value equals pass. They are additional info not specified by the DMARC spec. | ||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||
| 121 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||
| 123 | =head2 published | ||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||
| 125 | Published is a L<Mail::DMARC::Policy> tagged with a domain. The domain attribute is the DNS domain name where the DMARC record was found. This may not be the same as the header_from domain (ex: bounces.amazon.com -vs- amazon.com). | ||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||
| 127 | =head2 result | ||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||
| 129 | Whether the message passed the DMARC test. Possible values are: pass, fail. | ||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||
| 131 | In order to pass, at least one authentication alignment must pass. The 2013 draft defines two authentication methods: DKIM and SPF. The list is expected to grow. | ||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||
| 133 | =head2 disposition | ||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||
| 135 | When the DMARC result is not I<pass>, disposition is the results of applying DMARC policy to a message. Generally this is the same as the header_from domains published DMARC L<policy|Mail::DMARC::Policy>. When it is not, the reason SHOULD be specified. | ||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||
| 137 | =head2 dkim | ||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||
| 139 | Whether the message passed or failed DKIM alignment. In order to pass the DMARC DKIM alignment test, a DKIM signature that matches the RFC5322.From domain must be present. An unsigned messsage, a message with an invalid signature, or signatures that don't match the RFC5322.From field are all considered failures. | ||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||
| 141 | =head2 dkim_align | ||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||
| 143 | If the message passed the DKIM alignment test, this indicates whether the alignment was strict or relaxed. | ||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||
| 145 | =head2 spf | ||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||
| 147 | Whether the message passed or failed SPF alignment. To pass SPF alignment, the RFC5321.MailFrom domain must match the RFC5322.From field. | ||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||
| 149 | =head2 spf_align | ||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||
| 151 | If the message passed the SPF alignment test, this indicates whether the alignment was strict or relaxed. | ||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||
| 153 | =head2 reason | ||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||
| 155 | If the applied policy differs from the sites published policy, the result policy should contain a reason and optionally a comment. | ||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||
| 157 | A DMARC result reason has two attributes, type, and comment. | ||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||
| 159 | reason => { | ||||||||||||||||||||||||||||||||||||||
| 160 | type => '', | ||||||||||||||||||||||||||||||||||||||
| 161 | comment => '', | ||||||||||||||||||||||||||||||||||||||
| 162 | }, | ||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||
| 164 | =head3 type | ||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||
| 166 | The following reason types are defined and valid: | ||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||
| 168 | forwarded | ||||||||||||||||||||||||||||||||||||||
| 169 | sampled_out | ||||||||||||||||||||||||||||||||||||||
| 170 | trusted_forwarder | ||||||||||||||||||||||||||||||||||||||
| 171 | mailing_list | ||||||||||||||||||||||||||||||||||||||
| 172 | local_policy | ||||||||||||||||||||||||||||||||||||||
| 173 | other | ||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||
| 175 | =head3 comment | ||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||
| 177 | Comment is a free form text field. | ||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||
| 179 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||
| 181 | =over 4 | ||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||
| 183 | =item * | ||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||
| 185 | Matt Simerson <msimerson@cpan.org> | ||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||
| 187 | =item * | ||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||
| 189 | Davide Migliavacca <shari@cpan.org> | ||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||
| 191 | =item * | ||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||
| 193 | Marc Bradshaw <marc@marcbradshaw.net> | ||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||
| 195 | =back | ||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||
| 197 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||
| 199 | This software is copyright (c) 2026 by Matt Simerson. | ||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||
| 201 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||
| 202 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||
| 204 | =cut | ||||||||||||||||||||||||||||||||||||||