File Coverage

lib/Sisimai/Rhost/Cox.pm
Criterion Covered Total %
statement 18 24 75.0
branch 2 6 33.3
condition 3 4 75.0
subroutine 4 4 100.0
pod 0 1 0.0
total 27 39 69.2


line stmt bran cond sub pod time code
1             package Sisimai::Rhost::Cox;
2 4     4   2119 use feature ':5.10';
  4         7  
  4         1207  
3 4     4   23 use strict;
  4         8  
  4         71  
4 4     4   15 use warnings;
  4         5  
  4         1229  
5              
6             sub get {
7             # Detect bounce reason from https://cox.com/
8             # @param [Sisimai::Data] argvs Parsed email object
9             # @return [String] The bounce reason at Cox
10             # @since v4.25.8
11 9     9 0 741 my $class = shift;
12 9   100     31 my $argvs = shift // return undef;
13              
14 8         48 state $errorcodes = {
15             # https://www.cox.com/residential/support/email-error-codes.html
16             'CXBL' => 'blocked', # The sending IP address has been blocked by Cox due to exhibiting spam-like behavior.
17             'CXTHRT' => 'securityerror', # Email sending limited due to suspicious account activity.
18             'CXMJ' => 'securityerror', # Email sending blocked due to suspicious account activity on primary Cox account.
19             'CXDNS' => 'blocked', # There was an issue with the connecting IP address Domain Name System (DNS).
20             'CXSNDR' => 'rejected', # There was a problem with the sender's domain.
21             'CXSMTP' => 'rejected', # Your email wasn't delivered because Cox was unable to verify that it came from a legitimate email sender.
22             'CXCNCT' => 'toomanyconn', # There is a limit to the number of concurrent SMTP connections per IP address
23             'CXMXRT' => 'toomanyconn', # The email sender has exceeded the maximum number of sent email allowed.
24             'CDRBL' => 'blocked', # The sending IP address has been temporarily blocked by Cox due to exhibiting spam-like behavior.
25             'IPBL0001' => 'blocked', # The sending IP address is listed in the Spamhaus Zen DNSBL.
26             'IPBL0010' => 'blocked', # The sending IP is listed in the Return Path DNSBL.
27             'IPBL0100' => 'blocked', # The sending IP is listed in the Invaluement ivmSIP DNSBL.
28             'IPBL0011' => 'blocked', # The sending IP is in the Spamhaus Zen and Return Path DNSBLs.
29             'IPBL0101' => 'blocked', # The sending IP is in the Spamhaus Zen and Invaluement ivmSIP DNSBLs.
30             'IPBL0110' => 'blocked', # The sending IP is in the Return Path and Invaluement ivmSIP DNSBLs.
31             'IPBL0111' => 'blocked', # The sending IP is in the Spamhaus Zen, Return Path and Invaluement ivmSIP DNSBLs.
32             'IPBL1000' => 'blocked', # The sending IP address is listed on a CSI blacklist. You can check your status on the CSI website.
33             'IPBL1001' => 'blocked', # The sending IP is listed in the Cloudmark CSI and Spamhaus Zen DNSBLs.
34             'IPBL1010' => 'blocked', # The sending IP is listed in the Cloudmark CSI and Return Path DNSBLs.
35             'IPBL1011' => 'blocked', # The sending IP is in the Cloudmark CSI, Spamhaus Zen and Return Path DNSBLs.
36             'IPBL1100' => 'blocked', # The sending IP is listed in the Cloudmark CSI and Invaluement ivmSIP DNSBLs.
37             'IPBL1101' => 'blocked', # The sending IP is in the Cloudmark CSI, Spamhaus Zen and Invaluement IVMsip DNSBLs.
38             'IPBL1110' => 'blocked', # The sending IP is in the Cloudmark CSI, Return Path and Invaluement ivmSIP DNSBLs.
39             'IPBL1111' => 'blocked', # The sending IP is in the Cloudmark CSI, Spamhaus Zen, Return Path and Invaluement ivmSIP DNSBLs.
40             'IPBL00001' => 'blocked', # The sending IP address is listed on a Spamhaus blacklist. Check your status at Spamhaus.
41             'URLBL011' => 'spamdetected', # A URL within the body of the message was found on blocklists SURBL and Spamhaus DBL.
42             'URLBL101' => 'spamdetected', # A URL within the body of the message was found on blocklists SURBL and ivmURI.
43             'URLBL110' => 'spamdetected', # A URL within the body of the message was found on blocklists Spamhaus DBL and ivmURI.
44             'URLBL1001' => 'spamdetected', # The URL is listed on a Spamhaus blacklist. Check your status at Spamhaus.
45             };
46 8         24 state $messagesof = {
47             'blocked' => [
48             # Cox requires that all connecting email servers contain valid reverse DNS PTR records.
49             'rejected - no rDNS',
50             # An email client has repeatedly sent bad commands or invalid passwords resulting in a three-hour block of the client's IP address.
51             'cox too many bad commands from',
52             # The reverse DNS check of the sending server IP address has failed.
53             'DNS check failure - try again later',
54             # The sending IP address has exceeded the threshold of invalid recipients and has been blocked.
55             'Too many invalid recipients',
56             ],
57             'notaccept' => [
58             # Our systems are experiencing an issue which is causing a temporary inability to accept new email.
59             'ESMTP server temporarily not available',
60             ],
61             'policyviolation' => [
62             # The sending server has attempted to communicate too soon within the SMTP transaction
63             'ESMTP no data before greeting',
64             # The message has been rejected because it contains an attachment with one of the following prohibited
65             # file types, which commonly contain viruses: .shb, .shs, .vbe, .vbs, .wsc, .wsf, .wsh, .pif, .msc,
66             # .msi, .msp, .reg, .sct, .bat, .chm, .isp, .cpl, .js, .jse, .scr, .exe.
67             'attachment extension is forbidden',
68             ],
69             'rejected' => [
70             # Cox requires that all sender domains resolve to a valid MX or A-record within DNS.
71             'sender rejected',
72             ],
73             'toomanyconn' => [
74             # The sending IP address has exceeded the five maximum concurrent connection limit.
75             'too many sessions from',
76             # The SMTP connection has exceeded the 100 email message threshold and was disconnected.
77             'requested action aborted: try again later',
78             # The sending IP address has exceeded one of these rate limits and has been temporarily blocked.
79             'Message threshold exceeded',
80             ],
81             'userunknown' => [
82             'recipient rejected', # The intended recipient is not a valid Cox Email account.
83             ],
84             };
85 8         30 my $statusmesg = $argvs->diagnosticcode;
86 8 50       81 my $codenumber = $statusmesg =~ m/AUP#([0-9A-Z]+)/ ? $1 : 0;
87 8   50     26 my $reasontext = $errorcodes->{ $codenumber } || '';
88              
89 8 50       19 unless( $reasontext ) {
90             # The error code was not found in $errorcodes
91 0         0 REASON: for my $e ( keys %$messagesof ) {
92             # Try to find with each error message defined in $messagesof
93 0         0 for my $f ( @{ $messagesof->{ $e } } ) {
  0         0  
94             # Find an error reason
95 0 0       0 next unless index($statusmesg, $f) > -1;
96 0         0 $reasontext = $e;
97 0         0 last REASON;
98             }
99             }
100             }
101 8         35 return $reasontext;
102             }
103              
104             1;
105             __END__