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 67     67   3291 use v5.26;
  67         183  
3 67     67   279 use strict;
  67         97  
  67         1428  
4 67     67   274 use warnings;
  67         137  
  67         2661  
5 67     67   672 use Sisimai::String;
  67         115  
  67         16599  
6              
7 43     43 1 983 sub text { 'authfailure' }
8 4     4 0 19 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 2128     2128 1 5364 my $class = shift;
16 2128   100     4190 my $argv1 = shift // return 0;
17              
18 2127         2213 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 2127         3005 state $pairs = [
29             ["spf: ", " is not allowed to send "],
30             ["is not allowed to send ", " spf "],
31             ];
32              
33 2127 100       3292 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  17016         21234  
34 2105 100       2903 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  4210         7014  
35 2103         4429 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 2073     2073 0 3150 my $class = shift;
46 2073   100     4353 my $argvs = shift // return 0;
47              
48 2072 100       4238 return 1 if $argvs->{'reason'} eq 'authfailure';
49 2071 100 100     5574 return 1 if (Sisimai::SMTP::Status->name($argvs->{'deliverystatus'}) || '') eq 'authfailure';
50 2051         5930 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
51             }
52              
53             1;
54             __END__