File Coverage

lib/Sisimai/Reason/EmailTooLarge.pm
Criterion Covered Total %
statement 26 26 100.0
branch 8 8 100.0
condition 7 8 87.5
subroutine 7 7 100.0
pod 2 4 50.0
total 50 53 94.3


line stmt bran cond sub pod time code
1             package Sisimai::Reason::EmailTooLarge;
2 64     64   2154 use v5.26;
  64         235  
3 64     64   454 use strict;
  64         119  
  64         2129  
4 64     64   366 use warnings;
  64         154  
  64         23737  
5              
6 68     68 1 782 sub text { 'emailtoolarge' }
7 4     4 0 18 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 2249     2249 1 5020 my $class = shift;
15 2249   100     9706 my $argv1 = shift // return 0;
16              
17 2248         3960 state $index = [
18             "line limit exceeded",
19             "mail file size exceeds the maximum size allowed for mail delivery",
20             "message too large",
21             "size limit",
22             "taille limite du message atteinte",
23             ];
24 2248         3683 state $pairs = [
25             ["exceeded", "message size"],
26             ["message ", "exceeds ", "limit"],
27             ["message ", "size", "exceed"],
28             ["message ", "too", "big"],
29             ];
30 2248 100       5820 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  11240         27507  
31 2241 100       4883 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  8964         22512  
32 2239         9593 return 0;
33             }
34              
35             sub true {
36             # The message size is too big for the remote host
37             # @param [Sisimai::Fact] 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 2137     2137 0 4878 my $class = shift;
43 2137 100 100     6398 my $argvs = shift // return 0; return 1 if $argvs->{'reason'} eq 'emailtoolarge';
  2136         7772  
44              
45 2135   50     6860 my $statuscode = $argvs->{'deliverystatus'} // '';
46 2135   100     8675 my $tempreason = Sisimai::SMTP::Status->name($statuscode) || '';
47              
48             # Delivery status code points "emailtoolarge".
49             # Status: 5.3.4
50             # Diagnostic-Code: SMTP; 552 5.3.4 Error: message file too big
51             #
52             # Status: 5.2.3
53             # Diagnostic-Code: Message length exceeds administrative limit
54 2135 100       6638 return 1 if $tempreason eq 'emailtoolarge';
55 2075         10789 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
56             }
57              
58             1;
59             __END__