File Coverage

lib/Sisimai/Reason/NoRelaying.pm
Criterion Covered Total %
statement 23 23 100.0
branch 8 8 100.0
condition 3 4 75.0
subroutine 7 7 100.0
pod 2 4 50.0
total 43 46 93.4


line stmt bran cond sub pod time code
1             package Sisimai::Reason::NoRelaying;
2 59     59   1226 use feature ':5.10';
  59         96  
  59         5673  
3 59     59   318 use strict;
  59         96  
  59         1098  
4 59     59   247 use warnings;
  59         92  
  59         19891  
5              
6 29     29 1 79 sub text { 'norelaying' }
7 4     4 0 15 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 2449     2449 1 3369 my $class = shift;
15 2449   50     4773 my $argv1 = shift // return undef;
16              
17 2449         2863 state $index = [
18             'as a relay',
19             'insecure mail relay',
20             'is not permitted to relay through this server without authentication',
21             'mail server requires authentication when attempting to send to a non-local e-mail address', # MailEnable
22             'not a gateway',
23             'not allowed to relay through this machine',
24             'not an open relay, so get lost',
25             'not local host',
26             'relay access denied',
27             'relay denied',
28             'relaying mail to ',
29             'relay not permitted',
30             'relaying denied', # Sendmail
31             "that domain isn't in my list of allowed rcpthost",
32             'this system is not configured to relay mail',
33             'unable to relay for',
34             "we don't handle mail for",
35             ];
36 2449 100       3780 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  41633         65098  
37 2420         5808 return 0;
38             }
39              
40             sub true {
41             # Whether the message is rejected by 'Relaying denied'
42             # @param [Sisimai::Data] argvs Object to be detected the reason
43             # @return [Integer] 1: Rejected for "relaying denied"
44             # 0: is not
45             # @since v4.0.0
46             # @see http://www.ietf.org/rfc/rfc2822.txt
47 1784     1784 0 3309 my $class = shift;
48 1784   100     4074 my $argvs = shift // return undef;
49              
50 1783 100       5477 return 0 if $argvs->{'reason'} =~ /\A(?:securityerror|systemerror|undefined)\z/;
51 1742 100       5251 return 0 if $argvs->{'smtpcommand'} =~ /\A(?:CONN|EHLO|HELO)\z/;
52 1702 100       5128 return 1 if __PACKAGE__->match(lc $argvs->{'diagnosticcode'});return 0;
  1678         4280  
53             }
54              
55             1;
56             __END__