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   1242 use feature ':5.10';
  59         101  
  59         4171  
3 59     59   322 use strict;
  59         121  
  59         1172  
4 59     59   322 use warnings;
  59         124  
  59         20613  
5              
6 29     29 1 104 sub text { 'norelaying' }
7 4     4 0 14 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 3311 my $class = shift;
15 2449   50     4542 my $argv1 = shift // return undef;
16              
17 2449         3155 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       5854 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  41633         64927  
37 2420         6293 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 2845 my $class = shift;
48 1784   100     3561 my $argvs = shift // return undef;
49              
50 1783 100       4975 return 0 if $argvs->{'reason'} =~ /\A(?:securityerror|systemerror|undefined)\z/;
51 1742 100       4898 return 0 if $argvs->{'smtpcommand'} =~ /\A(?:CONN|EHLO|HELO)\z/;
52 1702 100       4781 return 1 if __PACKAGE__->match(lc $argvs->{'diagnosticcode'});return 0;
  1678         4350  
53             }
54              
55             1;
56             __END__