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   1093 use feature ':5.10';
  59         137  
  59         6227  
3 59     59   286 use strict;
  59         86  
  59         977  
4 59     59   236 use warnings;
  59         92  
  59         14814  
5              
6 28     28 1 57 sub text { 'mesgtoobig' }
7 4     4 0 11 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 2004     2004 1 8351 my $class = shift;
15 2004   50     4064 my $argv1 = shift // return undef;
16              
17 2004         2669 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 2004 100       3062 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  24048         34559  
32 1996         5255 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 1869     1869 0 2766 my $class = shift;
43 1869   100     3599 my $argvs = shift // return undef;
44 1868 50       4615 return 1 if $argvs->reason eq 'mesgtoobig';
45              
46 1868   50     8545 my $statuscode = $argvs->deliverystatus // '';
47 1868   100     9026 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 1868 100       4005 return 1 if $tempreason eq 'mesgtoobig';
53              
54             # 5.2.3 Message length exceeds administrative limit
55 1848 100 66     6640 return 0 if( $tempreason eq 'exceedlimit' || $statuscode eq '5.2.3' );
56 1835 100       3518 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
57 1830         4837 return 0;
58             }
59              
60             1;
61             __END__