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 68     68   1503 use v5.26;
  68         211  
3 68     68   234 use strict;
  68         110  
  68         1358  
4 68     68   209 use warnings;
  68         112  
  68         20424  
5              
6 49     49 1 152 sub text { 'suspend' }
7 4     4 0 19 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 2764     2764 1 5794 my $class = shift;
15 2764   100     5766 my $argv1 = shift // return 0;
16              
17 2763         3148 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             "temporarily unavailable user",
35             "user is no longer with ",
36             "user or domain is disabled",
37             "user suspended", # http://mail.163.com/help/help_spam_16.htm
38             "vdelivermail: account is locked email bounced",
39             ];
40 2763         2816 state $pairs = [
41             ["account ", "disabled"],
42             ["account ", "limited"],
43             ["has been ", "suspended"],
44             ["mailaddress ", "disabled"],
45             ["mailbox ", "disabled"],
46             ["not ", "active"],
47             ];
48 2763 100       3983 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  58023         66768  
49 2756 100       3617 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  16536         21718  
50 2728         6056 return 0;
51             }
52              
53             sub true {
54             # The envelope recipient's mailbox is suspended or not
55             # @param [Sisimai::Fact] argvs Object to be detected the reason
56             # @return [Integer] 1: is mailbox suspended
57             # 0: is not suspended
58             # @since v4.0.0
59             # @see http://www.ietf.org/rfc/rfc2822.txt
60 2149     2149 0 3352 my $class = shift;
61 2149   100     4940 my $argvs = shift // return 0;
62              
63 2148 100       4799 return 1 if $argvs->{'reason'} eq 'suspend';
64 2147 100 100     7764 return 1 if length $argvs->{'replycode'} && $argvs->{'replycode'} == 525;
65 2132         5889 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
66             }
67              
68             1;
69             __END__