File Coverage

lib/Sisimai/Reason/PolicyViolation.pm
Criterion Covered Total %
statement 21 21 100.0
branch 5 6 83.3
condition 7 7 100.0
subroutine 7 7 100.0
pod 2 4 50.0
total 42 45 93.3


line stmt bran cond sub pod time code
1             package Sisimai::Reason::PolicyViolation;
2 44     44   2279 use v5.26;
  44         124  
3 44     44   178 use strict;
  44         76  
  44         978  
4 44     44   240 use warnings;
  44         76  
  44         10839  
5              
6 16     16 1 51 sub text { 'policyviolation' }
7 4     4 0 13 sub description { 'Email rejected due to policy violation on a destination host' }
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.22.0
14 832     832 1 2047 my $class = shift;
15 832   100     2033 my $argv1 = shift // return 0;
16              
17 831         2601 state $index = [
18             "because the recipient is not accepting mail with ", # AOL Phoenix
19             "closed mailing list",
20             "delivery not authorized, message refused",
21             "denied by policy",
22             # http://kb.mimecast.com/Mimecast_Knowledge_Base/Administration_Console/Monitoring/Mimecast_SMTP_Error_Codes#554
23             "email rejected due to security policies",
24             "for policy reasons",
25             "local policy violation",
26             "message bounced due to organizational settings",
27             "message given low priority",
28             "message was rejected by organization policy",
29             "protocol violation",
30             "support.google.com/a/answer/172179",
31             "you're using a mass mailer",
32             ];
33 831 100       1197 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  10803         13398  
34 805         1893 return 0;
35             }
36              
37             sub true {
38             # The bounce reason is "policyviolation" or not
39             # @param [Sisimai::Fact] argvs Object to be detected the reason
40             # @return [Integer] 1: is policy violation
41             # 0: is not policyviolation
42             # @since v4.22.0
43             # @see http://www.ietf.org/rfc/rfc2822.txt
44 604     604 0 937 my $class = shift;
45 604   100     1302 my $argvs = shift // return 0;
46              
47 603 50       1368 return 1 if $argvs->{'reason'} eq 'policyviolation';
48 603 100 100     2356 return 0 if $argvs->{'command'} ne '' && $argvs->{'command'} ne 'DATA';
49 467         1466 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
50             }
51              
52             1;
53             __END__