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 64     64   2280 use v5.26;
  64         229  
3 64     64   334 use strict;
  64         260  
  64         2185  
4 64     64   305 use warnings;
  64         102  
  64         37755  
5              
6 213     213 1 1337 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 2766     2766 1 8153 my $class = shift;
15 2766   100     7307 my $argv1 = shift // return 0;
16              
17 2765         4652 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 size limit exceeded",
24             "mailbox would exceed maximum allowed storage",
25             "mailfolder is full",
26             "no space left on device",
27             "not sufficient disk space",
28             "quota violation for",
29             "too much mail data", # @docomo.ne.jp
30             "user has exceeded quota, bouncing mail",
31             "user has too many messages on the server",
32             "user's space has been used up",
33             ];
34 2765         4655 state $pairs = [
35             ["account is ", " quota"],
36             ["disk", "quota"],
37             ["enough ", " space"],
38             ["mailbox ", "exceeded", " limit"],
39             ["mailbox ", "full"],
40             ["mailbox ", "quota"],
41             ["maildir ", "quota"],
42             ["over ", "quota"],
43             ["quota ", "exceeded"],
44             ];
45 2765 100       6192 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  41475         81580  
46 2759 100       5463 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  24831         51276  
47 2711         12912 return 0;
48             }
49              
50             sub true {
51             # The envelope recipient's mailbox is full or not
52             # @param [Sisimai::Fact] argvs Object to be detected the reason
53             # @return [Integer] 1: is mailbox full
54             # 0: is not mailbox full
55             # @since v4.0.0
56             # @see http://www.ietf.org/rfc/rfc2822.txt
57 2333     2333 0 5373 my $class = shift;
58 2333 100 100     7468 my $argvs = shift // return 0; return 0 unless $argvs->{'deliverystatus'};
  2332         9366  
59              
60             # Delivery status code points "mailboxfull".
61             # Status: 4.2.2
62             # Diagnostic-Code: SMTP; 450 4.2.2 <***@example.jp>... Mailbox Full
63 1872 100       6646 return 1 if $argvs->{'reason'} eq 'mailboxfull';
64 1871 100 100     14361 return 1 if (Sisimai::SMTP::Status->name($argvs->{'deliverystatus'}) || '') eq 'mailboxfull';
65 1685         9331 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
66             }
67              
68             1;
69             __END__