File Coverage

lib/Sisimai/Rhost/GoDaddy.pm
Criterion Covered Total %
statement 26 26 100.0
branch 7 8 87.5
condition 2 2 100.0
subroutine 4 4 100.0
pod 0 1 0.0
total 39 41 95.1


line stmt bran cond sub pod time code
1             package Sisimai::Rhost::GoDaddy;
2 4     4   1555 use feature ':5.10';
  4         12  
  4         393  
3 4     4   23 use strict;
  4         8  
  4         148  
4 4     4   23 use warnings;
  4         6  
  4         1449  
5              
6             # https://www.godaddy.com/help/what-does-my-email-bounceback-mean-3568
7             sub get {
8             # Detect bounce reason from GoDaddy (smtp.secureserver.net)
9             # @param [Sisimai::Data] argvs Parsed email object
10             # @return [String] The bounce reason for GoDaddy
11             # @see https://www.godaddy.com/help/what-does-my-email-bounceback-mean-3568
12 13     13 0 1574 my $class = shift;
13 13   100     46 my $argvs = shift // return undef;
14 12 50       38 return $argvs->reason if $argvs->reason;
15              
16 12         119 state $errorcodes = {
17             'IB103' => 'blocked', # 554 Connection refused. This IP has a poor reputation on Cloudmark Sender Intelligence (CSI). IB103
18             'IB104' => 'blocked', # 554 Connection refused. This IP is listed on the Spamhaus Block List (SBL). IB104
19             'IB105' => 'blocked', # 554 Connection refused. This IP is listed on the Exploits Block List (XBL). IB105
20             'IB106' => 'blocked', # 554 Connection refused. This IP is listed on the Policy Block List (PBL). IB106
21             'IB007' => 'toomanyconn', # 421 Connection refused, too many sessions from This IP. Please lower the number of concurrent sessions. IB007
22             'IB101' => 'expired', # 421 Server temporarily unavailable. Try again later. IB101
23             'IB108' => 'blocked', # 421 Temporarily rejected. Reverse DNS for this IP failed. IB108
24             'IB110' => 'blocked', # 554 This IP has been temporarily blocked for attempting to send too many messages containing content judged to be spam by the Internet community. IB110
25             'IB111' => 'blocked', # 554 This IP has been blocked for the day, for attempting to send too many messages containing content judged to be spam by the Internet community. IB111
26             'IB112' => 'blocked', # 554 This IP has been temporarily blocked for attempting to mail too many invalid recipients. IB112
27             'IB113' => 'blocked', # 554 This IP has been blocked for the day, for attempting to mail too many invalid recipients. IB113
28             'IB212' => 'spamdetected', # 552 This message has been rejected due to content judged to be spam by the Internet community. IB212
29             'IB401' => 'securityerror', # 535 Authentication not allowed on IBSMTP Servers. IB401
30             'IB501' => 'rejected', # 550 holly@coolexample.com Blank From: addresses are not allowed. Please provide a valid From. IB501
31             'IB502' => 'rejected', # 550 holly@coolexample.com IP addresses are not allowed as a From: Address. Please provide a valid From. IB502
32             'IB504' => 'toomanyconn', # 550 This IP has sent too many messages this hour. IB504
33             'IB506' => 'rejected', # 550 coolexample.com From: Domain is invalid. Please provide a valid From: IB506
34             'IB508' => 'rejected', # 550 holly@coolexample.com Invalid SPF record. Please inspect your SPF settings, and try again. IB508
35             'IB510' => 'toomanyconn', # 550 This message has exceeded the max number of messages per session. Please open a new session and try again. IB510
36             'IB607' => 'toomanyconn', # 550 This IP has sent too many to too many recipients this hour. IB607
37             'IB705' => 'virusdetected', # 552 Virus infected message rejected. IB705
38              
39             };
40 12         38 state $messagesof = {
41             'blocked' => ['www.spamhaus.org/query/bl?ip=', '554 RBL Reject.'],
42             'expired' => ['Delivery timeout', "451 Sorry, I wasn't able to establish an SMTP connection."],
43             'suspend' => ['Account disabled'],
44             'mailboxfull' => ['Account storage limit'],
45             'userunknown' => ['Account does not exist', '550 Recipient not found.'],
46             };
47              
48 12         40 my $statusmesg = $argvs->diagnosticcode;
49 12         54 my $reasontext = '';
50              
51 12 100       68 if( $statusmesg =~ /\s(IB\d{3})\b/ ) {
52             # 192.0.2.22 has sent to too many recipients this hour. IB607 ...
53 6         25 $reasontext = $errorcodes->{ $1 };
54             } else {
55             # 553 http://www.spamhaus.org/query/bl?ip=192.0.0.222
56 6         27 for my $e ( keys %$messagesof ) {
57 28         33 for my $f ( @{ $messagesof->{ $e } } ) {
  28         54  
58 39 100       100 next if index($statusmesg, $f) == -1;
59 6         22 $reasontext = $e;
60             last
61 6         8 }
62 28 100       52 last if $reasontext;
63             }
64             }
65 12         43 return $reasontext;
66             }
67              
68             1;
69             __END__