File Coverage

lib/Sisimai/Reason/MesgTooBig.pm
Criterion Covered Total %
statement 26 26 100.0
branch 9 10 90.0
condition 8 11 72.7
subroutine 7 7 100.0
pod 2 4 50.0
total 52 58 89.6


line stmt bran cond sub pod time code
1             package Sisimai::Reason::MesgTooBig;
2 59     59   1287 use feature ':5.10';
  59         103  
  59         5181  
3 59     59   329 use strict;
  59         109  
  59         1237  
4 59     59   281 use warnings;
  59         146  
  59         17793  
5              
6 28     28 1 71 sub text { 'mesgtoobig' }
7 4     4 0 16 sub description { 'Email rejected due to an email size is too big for a destination mail server' }
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 1972     1972 1 9449 my $class = shift;
15 1972   50     3787 my $argv1 = shift // return undef;
16              
17 1972         2957 state $index = [
18             'exceeded maximum inbound message size',
19             'line limit exceeded',
20             'max message size exceeded',
21             'message file too big',
22             'message length exceeds administrative limit',
23             'message size exceeds fixed limit',
24             'message size exceeds fixed maximum message size',
25             'message size exceeds maximum value',
26             'message too big',
27             'message too large for this ',
28             'size limit',
29             'taille limite du message atteinte',
30             ];
31 1972 100       3605 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  23664         39191  
32 1964         5224 return 0;
33             }
34              
35             sub true {
36             # The message size is too big for the remote host
37             # @param [Sisimai::Data] argvs Object to be detected the reason
38             # @return [Integer] 1: is too big message size
39             # 0: is not big
40             # @since v4.0.0
41             # @see http://www.ietf.org/rfc/rfc2822.txt
42 1837     1837 0 2744 my $class = shift;
43 1837   100     3855 my $argvs = shift // return undef;
44 1836 50       4441 return 1 if $argvs->reason eq 'mesgtoobig';
45              
46 1836   50     9003 my $statuscode = $argvs->deliverystatus // '';
47 1836   100     9831 my $tempreason = Sisimai::SMTP::Status->name($statuscode) || '';
48              
49             # Delivery status code points "mesgtoobig".
50             # Status: 5.3.4
51             # Diagnostic-Code: SMTP; 552 5.3.4 Error: message file too big
52 1836 100       4872 return 1 if $tempreason eq 'mesgtoobig';
53              
54             # 5.2.3 Message length exceeds administrative limit
55 1816 100 66     6411 return 0 if( $tempreason eq 'exceedlimit' || $statuscode eq '5.2.3' );
56 1803 100       4618 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
57 1798         6255 return 0;
58             }
59              
60             1;
61             __END__