File Coverage

lib/Sisimai/Reason/Suspend.pm
Criterion Covered Total %
statement 24 24 100.0
branch 8 8 100.0
condition 7 7 100.0
subroutine 7 7 100.0
pod 2 4 50.0
total 48 50 96.0


line stmt bran cond sub pod time code
1             package Sisimai::Reason::Suspend;
2 64     64   2210 use v5.26;
  64         222  
3 64     64   340 use strict;
  64         150  
  64         1866  
4 64     64   669 use warnings;
  64         137  
  64         24785  
5              
6 49     49 1 768 sub text { 'suspend' }
7 4     4 0 17 sub description { 'Email rejected due to a recipient account is being suspended' }
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 2577     2577 1 5613 my $class = shift;
15 2577   100     7940 my $argv1 = shift // return 0;
16              
17 2576         4333 state $index = [
18             " currently suspended",
19             " temporary locked",
20             "address no longer accepts mail",
21             "archived recipient",
22             "boite du destinataire archivee",
23             "email account that you tried to reach is inactive",
24             "inactive account",
25             "inactivity new mail is not currently being accepted for this mailbox",
26             "invalid/inactive user",
27             "is a deactivated mailbox", # http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000742
28             "is unavailable: user is terminated",
29             "mailbox is frozen",
30             "mailbox is inactive",
31             "mailbox unavailable or access denied",
32             "recipient rejected: temporarily inactive",
33             "recipient suspend the service",
34             "user or domain is disabled",
35             "user suspended", # http://mail.163.com/help/help_spam_16.htm
36             "vdelivermail: account is locked email bounced",
37             ];
38 2576         3967 state $pairs = [
39             ["account ", "disabled"],
40             ["has been ", "suspended"],
41             ["mailbox ", "disabled"],
42             ["not ", "active"],
43             ];
44 2576 100       5696 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  48944         89261  
45 2569 100       5346 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  10276         22812  
46 2541         17713 return 0;
47             }
48              
49             sub true {
50             # The envelope recipient's mailbox is suspended or not
51             # @param [Sisimai::Fact] argvs Object to be detected the reason
52             # @return [Integer] 1: is mailbox suspended
53             # 0: is not suspended
54             # @since v4.0.0
55             # @see http://www.ietf.org/rfc/rfc2822.txt
56 2072     2072 0 5944 my $class = shift;
57 2072   100     5935 my $argvs = shift // return 0;
58              
59 2071 100       6650 return 1 if $argvs->{'reason'} eq 'suspend';
60 2070 100 100     11110 return 1 if length $argvs->{'replycode'} && $argvs->{'replycode'} == 525;
61 2055         12684 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
62             }
63              
64             1;
65             __END__