Sisimai/Rhost/Spectrum.pm

filter: Statementstmt 92.5% 25 / 27 Branchbran 91.6% 11 / 12 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 91.4% 43 / 47 CC 9 SCAR 19.5
CC
9
Cov
93%
find
9.1
BEGIN
1.0
BEGIN
1.0
CRAP 7.1
« Sisimai/Reason/UserUnknown.pm ↑ Summary Sisimai/Rhost/Cox.pm »
1 package Sisimai::Rhost::Spectrum;
2 4 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 10 ▶sub find {
Subroutine find: called CC=9 SCAR=22.0
Pod undocumented
7 # Detect bounce reason from https://www.spectrum.com/
8 # @param [Sisimai::Fact] argvs Decoded email object
9 # @return [String] The bounce reason at Spectrum
10 # @since v4.25.8
11 10 my $class = shift;
12 10 ▶ my $argvs = shift // return ""; return "" unless $argvs->{'diagnosticcode'};
Branch: 1 branch
BranchTrueFalseTotal
unless $argvs->{"diagnosticcode"} 1 8 9
Condition100%2/2
shift() // (return "")
l!l
91
MC/DC100%1/1
shift() // (return "")
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
13  
14 8 require Sisimai::Eb;
15 8 state $errorcodes = [
16 # https://www.spectrumbusiness.net/support/internet/understanding-email-error-codes
17 # Error codes are placed in one of two categories: incoming or outgoing.
18 # 1. If you're trying to send an email to a Charter email address from
19 # a non-Charter email address (such as Gmail, Yahoo, Hotmail, etc.),
20 # you may receive an error that begins with AUP#I, followed by four numbers.
21 #
22 # 2. If you are trying to send an email from a Charter email address
23 # to an outgoing recipient, you may get an error code beginning with
24 # AUP#O, also followed by four numbers.
25 #
26 # 1000 Your IP address has been blocked due to suspicious activity. If you're a Spectrum
27 # customer using a Spectrum-issued IP, contact us. If you're using an IP address other
28 # than one provided by Spectrum, blocks will remain in place until they expire.
29 [1000, 0, $Sisimai::Eb::ReBLOC],
30  
31 # 1010 This email account has been blocked from sending emails due to suspicious activity.
32 # Blocks will expire based on the nature of the activity. If you're a Spectrum customer,
33 # change all of your Spectrum passwords to secure your account and then contact us.
34 [1010, 0, $Sisimai::Eb::ReFROM],
35  
36 # 1020 This email account has limited access to send emails based on suspicious activity.
37 # 1080 Blocks will expire based on the nature of the activity.
38 # If you're a Spectrum customer, contact us to remove the block.
39 [1020, 1080, $Sisimai::Eb::ReFROM],
40  
41 # 1090 The email you're trying to send can't be processed. Try sending again at a later time.
42 [1090, 0, $Sisimai::Eb::RePROC],
43  
44 # 1100 The IP address you're trying to connect from has an issue with the Domain Name System.
45 # 1150 Spectrum requires a full circle DNS for emails to be allowed through. Verify the IP
46 # you're connecting from, and check the IP address to ensure a reverse DNS entry exists
47 # for the IP. If the IP address is a Spectrum-provided email address, contact us.
48 [1100, 1150, $Sisimai::Eb::ReQPTR],
49  
50 # 1160 The email you tried to send goes against your domain's security policies.
51 # 1190 Please contact the email administrators of your domain.
52 [1160, 1190, $Sisimai::Eb::ReWONT],
53  
54 # 1200 The IP address you're trying to send from has been flagged by Cloudmark CSI as
55 # 1210 potential spam. Have your IP administrator request a reset.
56 # Note: Cloudmark has sole discretion whether to remove the sending IP address from
57 # their lists.
58 [1200, 1210, $Sisimai::Eb::ReBLOC],
59  
60 # 1220 Your IP address has been blacklisted by Spamhaus. The owner of the IP address must
61 # 1250 contact Spamhaus to be removed from the list.
62 # Note: Spamhaus has sole discretion whether to remove the sending IP address from
63 # their lists.
64 [1220, 1250, $Sisimai::Eb::ReBLOC],
65  
66 # 1260 Spectrum doesn't process IPV6 addresses. Connect with an IPv4 address and try again.
67 [1260, 0, $Sisimai::Eb::ReINET],
68  
69 # 1300 Spectrum limits the number of concurrent connections from a sender, as well as the
70 # 1340 total number of connections allowed. Limits vary based on the reputation of the IP
71 # address. Reduce your number of connections and try again later.
72 [1300, 1340, $Sisimai::Eb::ReRATE],
73  
74 # 1350 Spectrum limits emails by the number of messages sent, amount of recipients,
75 # 1490 potential for spam and invalid recipients.
76 [1350, 1490, $Sisimai::Eb::ReRATE],
77  
78 # 1500 Your email was rejected for attempting to send as a different email address than you
79 # signed in under. Check that you're sending emails from the address you signed in with.
80 [1500, 0, $Sisimai::Eb::ReFROM],
81  
82 # 1520 Your email was rejected for attempting to send as a different email address than a
83 # domain that we host. Check the outgoing email address and try again.
84 [1520, 0, $Sisimai::Eb::ReFROM],
85  
86 # 1530 Your email was rejected because it's larger than the maximum size of 20MB.
87 [1530, 0, $Sisimai::Eb::ReSIZE],
88  
89 # 1540 Your emails were deferred for attempting to send too many in a single session.
90 # Reconnect and try reducing the number of emails you send at one time.
91 [1540, 0, $Sisimai::Eb::ReRATE],
92  
93 # 1550 Your email was rejected for having too many recipients in one message. Reduce the
94 # number of recipients and try again later.
95 [1550, 0, $Sisimai::Eb::ReRATE],
96  
97 # 1560 Your email was rejected for having too many invalid recipients. Check your outgoing
98 # email addresses and try again later.
99 [1560, 0, $Sisimai::Eb::ReRATE],
100  
101 # 1580 You've tried to send messages to too many recipients in a short period of time.
102 # Wait a little while and try again later.
103 [1580, 0, $Sisimai::Eb::ReRATE],
104 ];
105 8 my $issuedcode = $argvs->{'diagnosticcode'};
106 8 ▶ my $codenumber = $issuedcode =~ m/AUP#[-A-Za-z]*(\d{4})/ ? int $1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$issuedcode =~ /AUP#[-A-Za-z]*(\d{4})/u ? : 6 2 8
107 8 my $reasontext = '';
108  
109 8 for my $e ( @$errorcodes ) {
110 # Try to find an error code matches with the code in the value of $diagnosticcode
111 96 ▶ if( $codenumber == $e->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($codenumber == $e->[0]) { } 0 96 96
112 # [1500, 0, 'reason'] or [1500, 1550, 'reason']
113 0 $reasontext = $e->[2];
114 0 last;
115  
116 } else {
117 # Check the code number is inlcuded the range like [1500, 1550, 'reason']
118 96 ▶ next if $e->[1] == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $e->[1] == 0 46 50 96
119 50 ▶ next if $codenumber < $e->[0];
Branch: 1 branch
BranchTrueFalseTotal
if $codenumber < $e->[0] 14 36 50
120 36 ▶ next if $codenumber > $e->[1];
Branch: 1 branch
BranchTrueFalseTotal
if $codenumber > $e->[1] 30 6 36
121  
122 6 $reasontext = $e->[2];
123 6 last;
124 }
125 }
126 8 return $reasontext;
127 }
128  
129 4 1;
130 __END__
« Sisimai/Reason/UserUnknown.pm ↑ Summary Sisimai/Rhost/Cox.pm »