File Coverage

lib/Sisimai/Reason/RequirePTR.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 1 4 25.0
total 50 53 94.3


line stmt bran cond sub pod time code
1             package Sisimai::Reason::RequirePTR;
2 47     47   3057 use v5.26;
  47         186  
3 47     47   259 use strict;
  47         109  
  47         4291  
4 47     47   250 use warnings;
  47         117  
  47         2992  
5 47     47   322 use Sisimai::String;
  47         110  
  47         20107  
6              
7 87     87 1 299 sub text { 'requireptr' }
8 4     4 0 15 sub description { 'Email rejected due to missing PTR record or having invalid PTR record' }
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 1060     1060 0 3168 my $class = shift;
16 1060   100     2917 my $argv1 = shift // return 0;
17              
18 1059         1885 state $index = [
19             "cannot find your hostname",
20             "cannot resolve your address.",
21             "corresponding forward dns entry does not point to the sending ip", # Google
22             "ip name lookup failed",
23             "no matches to nameserver query",
24             "sender ip reverse lookup rejected",
25             "unresolvable relay host name",
26             ];
27 1059         1959 state $pairs = [
28             ["domain "," mismatches client ip"],
29             ["domain name verification on your ip address ", "failed"],
30             ["dns lookup failure: ", " try again later"],
31             ["ptr", "record"],
32             ["reverse", " dns"],
33             ["server access ", " forbidden by invalid rdns record of your mail server"],
34             ["service permits ", " unverifyable sending ips"],
35             ];
36              
37 1059 100       2723 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  7413         16202  
38 1054 100       2200 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  7378         15314  
39 981         4222 return 0;
40             }
41              
42             sub true {
43             # Rejected due to missing PTR record or having invalid PTR record
44             # @param [Sisimai::Fact] argvs Object to be detected the reason
45             # @return [Integer] 1: is missing PTR or invalid PTR
46             # [Integer] 0: is not blocked due to missing PTR record
47             # @see http://www.ietf.org/rfc/rfc2822.txt
48             # @since v5.0.0
49 1070     1070 0 2497 my $class = shift;
50 1070   100     3213 my $argvs = shift // return 0;
51              
52 1069 100       5829 return 1 if $argvs->{'reason'} eq 'requireptr';
53 1068 100 100     4924 return 1 if (Sisimai::SMTP::Status->name($argvs->{'deliverystatus'}) || '') eq 'requireptr';
54 1058         5595 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
55             }
56              
57             1;
58             __END__