File Coverage

lib/Sisimai/Reason/MailboxFull.pm
Criterion Covered Total %
statement 25 25 100.0
branch 10 10 100.0
condition 6 6 100.0
subroutine 7 7 100.0
pod 2 4 50.0
total 50 52 96.1


line stmt bran cond sub pod time code
1             package Sisimai::Reason::MailboxFull;
2 69     69   1596 use v5.26;
  69         184  
3 69     69   290 use strict;
  69         212  
  69         1905  
4 69     69   218 use warnings;
  69         90  
  69         22577  
5              
6 223     223 1 1394 sub text { 'mailboxfull' }
7 4     4 0 16 sub description { "Email rejected due to a recipient's mailbox is full" }
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 2918     2918 1 5434 my $class = shift;
15 2918   100     5162 my $argv1 = shift // return 0;
16              
17 2917         3421 state $index = [
18             "452 insufficient disk space",
19             "account disabled temporarly for exceeding receiving limits",
20             "boite du destinataire pleine",
21             "exceeded storage allocation",
22             "full mailbox",
23             "mailbox exceeds allowed size",
24             "mailbox size limit exceeded",
25             "mailbox would exceed maximum allowed storage",
26             "mailfolder is full",
27             "no space left on device",
28             "not sufficient disk space",
29             "quota violation for",
30             "too much mail data", # @docomo.ne.jp
31             "user has exceeded quota, bouncing mail",
32             "user has too many messages on the server",
33             "user's space has been used up",
34             ];
35 2917         3855 state $pairs = [
36             ["account is ", " quota"],
37             ["disk", "quota"],
38             ["enough ", " space"],
39             ["mailbox ", "exceeded", " limit"],
40             ["mailbox ", "full"], # Exim/transports/appendfile.c:2567
41             ["mailbox ", "quota"],
42             ["maildir ", "quota"],
43             ["over ", "quota"],
44             ["quota ", "exceeded"], # Exim/transports/appendfile.c:3050
45             ];
46 2917 100       5243 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  46672         62884  
47 2906 100       3852 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  26154         36903  
48 2821         7662 return 0;
49             }
50              
51             sub true {
52             # The envelope recipient's mailbox is full or not
53             # @param [Sisimai::Fact] argvs Object to be detected the reason
54             # @return [Integer] 1: is mailbox full
55             # 0: is not mailbox full
56             # @since v4.0.0
57             # @see http://www.ietf.org/rfc/rfc2822.txt
58 2426     2426 0 4285 my $class = shift;
59 2426 100 100     6086 my $argvs = shift // return 0; return 0 unless $argvs->{'deliverystatus'};
  2425         6856  
60              
61             # Delivery status code points "mailboxfull".
62             # Status: 4.2.2
63             # Diagnostic-Code: SMTP; 450 4.2.2 <***@example.jp>... Mailbox Full
64 1877 100       3940 return 1 if $argvs->{'reason'} eq 'mailboxfull';
65 1876 100 100     6802 return 1 if (Sisimai::SMTP::Status->name($argvs->{'deliverystatus'}) || '') eq 'mailboxfull';
66 1680         5562 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
67             }
68              
69             1;
70             __END__