File Coverage

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


line stmt bran cond sub pod time code
1             package Sisimai::Reason::FailedSTARTTLS;
2 43     43   4086 use v5.26;
  43         123  
3 43     43   189 use strict;
  43         84  
  43         1041  
4 43     43   164 use warnings;
  43         66  
  43         10415  
5              
6 1     1 1 5 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 709     709 1 2552 my $class = shift;
15 709   100     1237 my $argv1 = shift // return 0;
16              
17 708         824 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 708 100       1148 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  1416         2831  
22 706         1633 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 636     636 0 1090 my $class = shift;
33 636   100     1434 my $argvs = shift // return 0;
34 635   100     2323 my $reply = $argvs->{'replycode'} || 0;
35              
36 635 100 66     3992 return 1 if $argvs->{"reason"} eq "failedstarttls" || $argvs->{"command"} eq "STARTTLS";
37 634 50 33     4500 return 1 if $reply == 523 || $reply == 524 || $reply == 538;
      33        
38 634         2385 return __PACKAGE__->match(lc $argvs->{"diagnosticcode"});
39             }
40              
41             1;
42             __END__