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   1094 use feature ':5.10';
  59         91  
  59         3666  
3 59     59   285 use strict;
  59         88  
  59         2905  
4 59     59   230 use warnings;
  59         84  
  59         17892  
5              
6 29     29 1 74 sub text { 'norelaying' }
7 4     4 0 12 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 2421     2421 1 3134 my $class = shift;
15 2421   50     4319 my $argv1 = shift // return undef;
16              
17 2421         3088 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 2421 100       3785 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  41157         54983  
37 2392         4827 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 1816     1816 0 2808 my $class = shift;
48 1816   100     3694 my $argvs = shift // return undef;
49              
50 1815 100       4721 return 0 if $argvs->{'reason'} =~ /\A(?:securityerror|systemerror|undefined)\z/;
51 1774 100       4633 return 0 if $argvs->{'smtpcommand'} =~ /\A(?:CONN|EHLO|HELO)\z/;
52 1730 100       5407 return 1 if __PACKAGE__->match(lc $argvs->{'diagnosticcode'});return 0;
  1706         3801  
53             }
54              
55             1;
56             __END__