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   1297 use feature ':5.10';
  59         1016  
  59         4250  
3 59     59   321 use strict;
  59         96  
  59         1096  
4 59     59   267 use warnings;
  59         97  
  59         18078  
5              
6 28     28 1 863 sub text { 'mesgtoobig' }
7 4     4 0 15 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 9142 my $class = shift;
15 1972   50     3926 my $argv1 = shift // return undef;
16              
17 1972         2583 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       3331 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  23664         38518  
32 1964         5305 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 2960 my $class = shift;
43 1837   100     4095 my $argvs = shift // return undef;
44 1836 50       3732 return 1 if $argvs->reason eq 'mesgtoobig';
45              
46 1836   50     9703 my $statuscode = $argvs->deliverystatus // '';
47 1836   100     10123 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       4009 return 1 if $tempreason eq 'mesgtoobig';
53              
54             # 5.2.3 Message length exceeds administrative limit
55 1816 100 66     7523 return 0 if( $tempreason eq 'exceedlimit' || $statuscode eq '5.2.3' );
56 1803 100       4472 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
57 1798         5552 return 0;
58             }
59              
60             1;
61             __END__