File Coverage

lib/Sisimai/Reason/AuthFailure.pm
Criterion Covered Total %
statement 27 27 100.0
branch 8 8 100.0
condition 6 6 100.0
subroutine 8 8 100.0
pod 2 4 50.0
total 51 53 96.2


line stmt bran cond sub pod time code
1             package Sisimai::Reason::AuthFailure;
2 63     63   4804 use v5.26;
  63         244  
3 63     63   364 use strict;
  63         112  
  63         1743  
4 63     63   282 use warnings;
  63         122  
  63         3211  
5 63     63   681 use Sisimai::String;
  63         131  
  63         21481  
6              
7 43     43 1 725 sub text { 'authfailure' }
8 4     4 0 17 sub description { 'Email rejected due to SPF, DKIM, DMARC failure' }
9             sub match {
10             # Try to match that the given text and regular expressions
11             # @param [String] argv1 String to be matched with regular expressions
12             # @return [Integer] 0: Did not match
13             # 1: Matched
14             # @since v5.0.0
15 2456     2456 1 6051 my $class = shift;
16 2456   100     7042 my $argv1 = shift // return 0;
17              
18 2455         4031 state $index = [
19             "//spf.pobox.com",
20             "5322.From address doesn't meet the authentication requirements",
21             "bad spf records for",
22             "dmarc policy",
23             "doesn't meet the required authentication level",
24             "please inspect your spf settings",
25             "sender policy framework",
26             "spf check: fail",
27             ];
28 2455         4730 state $pairs = [
29             [" is not allowed to send mail.", "_401"],
30             ["is not allowed to send from <", " per it's spf record"],
31             ];
32              
33 2455 100       5844 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  19640         36663  
34 2433 100       5722 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  4866         13194  
35 2431         9306 return 0;
36             }
37              
38             sub true {
39             # The bounce reason is "authfailure" or not
40             # @param [Sisimai::Fact] argvs Object to be detected the reason
41             # @return [Integer] 1: is authfailure
42             # 0: is not authfailure
43             # @see http://www.ietf.org/rfc/rfc2822.txt
44             # @since v5.0.0
45 1986     1986 0 4377 my $class = shift;
46 1986   100     7582 my $argvs = shift // return 0;
47              
48 1985 100       6649 return 1 if $argvs->{'reason'} eq 'authfailure';
49 1984 100 100     9718 return 1 if (Sisimai::SMTP::Status->name($argvs->{'deliverystatus'}) || '') eq 'authfailure';
50 1964         10208 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
51             }
52              
53             1;
54             __END__