File Coverage

lib/Sisimai/Reason/NoRelaying.pm
Criterion Covered Total %
statement 24 24 100.0
branch 8 8 100.0
condition 14 16 87.5
subroutine 7 7 100.0
pod 2 4 50.0
total 55 59 93.2


line stmt bran cond sub pod time code
1             package Sisimai::Reason::NoRelaying;
2 64     64   2089 use v5.26;
  64         221  
3 64     64   352 use strict;
  64         155  
  64         1747  
4 64     64   334 use warnings;
  64         135  
  64         24294  
5              
6 45     45 1 463 sub text { 'norelaying' }
7 4     4 0 33 sub description { 'Email rejected with error message "Relaying Denied"' }
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 v4.0.0
14 2832     2832 1 5903 my $class = shift;
15 2832   100     10811 my $argv1 = shift // return 0;
16              
17 2831         5152 state $index = [
18             "as a relay",
19             "domain isn't in my list of allowed rcpthost",
20             "email address is not verified.",
21             "insecure mail relay",
22             "no relaying",
23             "not a gateway",
24             "not an open relay, so get lost",
25             "not local host",
26             "relay not permitted",
27             "relaying denied", # Sendmail
28             "relaying mail to ",
29             "send to a non-local e-mail address", # MailEnable
30             "specified domain is not allowed",
31             "unable to relay ",
32             "we don't handle mail for",
33             ];
34 2831         4323 state $pairs = [
35             ["relay ", "denied"],
36             [" not ", " to relay"],
37             ];
38 2831 100       6515 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  42465         75382  
39 2803 100       5705 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  5606         16855  
40 2786         9640 return 0;
41             }
42              
43             sub true {
44             # Whether the message is rejected by 'Relaying denied'
45             # @param [Sisimai::Fact] argvs Object to be detected the reason
46             # @return [Integer] 1: Rejected for "relaying denied"
47             # 0: is not
48             # @since v4.0.0
49             # @see http://www.ietf.org/rfc/rfc2822.txt
50 2024     2024 0 4259 my $class = shift;
51 2024   100     5717 my $argvs = shift // return 0;
52              
53             return 0 if $argvs->{'reason'} eq 'securityerror'
54             || $argvs->{'reason'} eq 'systemerror'
55 2023 100 100     18752 || $argvs->{'reason'} eq 'undefined';
      66        
56             return 0 if $argvs->{'command'} eq 'CONN'
57             || $argvs->{'command'} eq 'EHLO'
58 1998 100 66     14795 || $argvs->{'command'} eq 'HELO';
      100        
59 1957         8736 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
60             }
61              
62             1;
63             __END__