File Coverage

lib/Sisimai/Reason/FailedSTARTTLS.pm
Criterion Covered Total %
statement 22 22 100.0
branch 5 6 83.3
condition 9 15 60.0
subroutine 7 7 100.0
pod 2 4 50.0
total 45 54 83.3


line stmt bran cond sub pod time code
1             package Sisimai::Reason::FailedSTARTTLS;
2 21     21   4887 use v5.26;
  21         77  
3 21     21   130 use strict;
  21         46  
  21         564  
4 21     21   147 use warnings;
  21         67  
  21         6180  
5              
6 1     1 1 22 sub text { "failedstarttls" }
7 4     4 0 17 sub description { "Email delivery failed due to STARTTLS related problem" }
8             sub match {
9             # Try to match that the given text and regular expressions
10             # @param [String] argv1 String to be matched with regular expressions
11             # @return [Integer] 0: Did not match
12             # 1: Matched
13             # @since v5.2.0
14 269     269 1 1971 my $class = shift;
15 269   100     954 my $argv1 = shift // return 0;
16              
17 268         441 state $index = [
18             "starttls is required to send mail",
19             "tls required but not supported", # SendGrid:the recipient mailserver does not support TLS or have a valid certificate
20             ];
21 268 100       546 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  536         1435  
22 266         877 return 0;
23             }
24              
25             sub true {
26             # The bounce reason is "FailedSTARTTLS" or not
27             # @param [Sisimai::Fact] argvs Object to be detected the reason
28             # @return [Integer] 1: is FailedSTARTTLS
29             # 0: is not FailedSTARTTLS
30             # @see http://www.ietf.org/rfc/rfc2822.txt
31             # @since v5.2.0
32 4     4 0 14 my $class = shift;
33 4   100     12 my $argvs = shift // return 0;
34 3   50     10 my $reply = int $argvs->{'replycode'} || 0;
35              
36 3 100 66     17 return 1 if $argvs->{"reason"} eq "failedstarttls" || $argvs->{"command"} eq "STARTTLS";
37 2 50 33     10 return 1 if $reply == 523 || $reply == 524 || $reply == 538;
      33        
38 2         6 return __PACKAGE__->match(lc $argvs->{"diagnosticcode"});
39             }
40              
41             1;
42             __END__