File Coverage

lib/Sisimai/Reason/NoRelaying.pm
Criterion Covered Total %
statement 25 25 100.0
branch 8 8 100.0
condition 9 10 90.0
subroutine 7 7 100.0
pod 2 4 50.0
total 51 54 94.4


line stmt bran cond sub pod time code
1             package Sisimai::Reason::NoRelaying;
2 68     68   1496 use v5.26;
  68         175  
3 68     68   252 use strict;
  68         337  
  68         1299  
4 68     68   198 use warnings;
  68         355  
  68         20154  
5              
6 35     35 1 77 sub text { 'norelaying' }
7 4     4 0 18 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 2909     2909 1 4515 my $class = shift;
15 2909   100     5828 my $argv1 = shift // return 0;
16              
17 2908         3253 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 local host",
25             "open relay",
26             "relay not permitted",
27             "relay prohibition",
28             "relaying denied", # Sendmail
29             "relaying mail to ",
30             "send to a non-local e-mail address", # MailEnable
31             "specified domain is not allowed",
32             "unable to relay ",
33             "we don't handle mail for",
34             ];
35 2908         2935 state $pairs = [
36             ["relay ", "denied"],
37             ["n", "t ", "to relay"],
38             ];
39 2908 100       4042 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  46528         54954  
40 2885 100       3742 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  5770         17964  
41 2868         5675 return 0;
42             }
43              
44             sub true {
45             # Whether the message is rejected by 'Relaying denied'
46             # @param [Sisimai::Fact] argvs Object to be detected the reason
47             # @return [Integer] 1: Rejected for "relaying denied"
48             # 0: is not
49             # @since v4.0.0
50             # @see http://www.ietf.org/rfc/rfc2822.txt
51 2101     2101 0 2956 my $class = shift;
52 2101   100     3779 my $argvs = shift // return 0;
53              
54 2100 100       4743 return 0 if grep { $argvs->{'command'} eq $_ } Sisimai::SMTP::Command->BeforeRCPT->@*;
  12600         16217  
55             return 0 if $argvs->{'reason'} eq 'securityerror'
56             || $argvs->{'reason'} eq 'systemerror'
57 1904 100 100     10008 || $argvs->{'reason'} eq 'undefined';
      66        
58 1894         5020 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
59             }
60              
61             1;
62             __END__