File Coverage

lib/Sisimai/Rhost/GoDaddy.pm
Criterion Covered Total %
statement 25 25 100.0
branch 8 8 100.0
condition 3 4 75.0
subroutine 4 4 100.0
pod 0 1 0.0
total 40 42 95.2


line stmt bran cond sub pod time code
1             package Sisimai::Rhost::GoDaddy;
2 5     5   6323 use v5.26;
  5         22  
3 5     5   31 use strict;
  5         12  
  5         181  
4 5     5   25 use warnings;
  5         11  
  5         3234  
5              
6             # https://www.godaddy.com/help/what-does-my-email-bounceback-mean-3568
7             sub find {
8             # Detect bounce reason from GoDaddy (smtp.secureserver.net)
9             # @param [Sisimai::Fact] argvs Decoded email object
10             # @return [String] The bounce reason for GoDaddy
11             # @see https://ca.godaddy.com/help/fix-rejected-email-with-a-bounce-error-40685
12             # @since v4.22.2
13 21     21 0 1157 my $class = shift;
14 21 100 100     85 my $argvs = shift // return ""; return "" unless $argvs->{'diagnosticcode'};
  20         80  
15              
16 19         152 state $errorcodes = {
17             # Sender bounces
18             # -----------------------------------------------------------------------------------------
19             # - 535 Authentication not allowed on IBSMTP Servers. IB401
20             # - Authentication is not allowed on inbound mail. This happens when you have incorrect
21             # outgoing SMTP server settings set up in your email client, like Outlook or Gmail.
22             # - Set up your email client using the SMTP server setting smtpout.secureserver.net.
23             'IB401' => 'securityerror',
24              
25             # - 550 jane@coolexample.com Blank From: addresses are not allowed. Provide a valid From.
26             # IB501
27             # - The email message "from" field is blank.
28             # - Add a valid "from" address and try to send the email again.
29             'IB501' => 'notcompliantrfc',
30              
31             # - 550 jane@coolexample.com IP addresses are not allowed as a From: Address. Provide a
32             # valid From. IB502
33             # - Email messages can't be sent "from" an IP address.
34             # - Add a valid "from" address and try to send the email again.
35             'IB502' => 'notcompliantrfc',
36              
37             # - 550 coolexample.com From: Domain is invalid. Provide a valid From: IB506
38             # - The domain doesn't have valid MX Records, an IP address, or there were issues during
39             # the DNS lookup when the email was sent.
40             # - Verify that you're sending from a valid domain. Then verify that the domain has valid
41             # DNS records by checking your zone file. If the DNS isn't valid, it must be fixed before
42             # you resend the email.
43             'IB506' => 'rejected',
44              
45             # - 550 jane@coolexample.com Invalid SPF record. Inspect your SPF settings, and try again.
46             # IB508
47             # - The sending email address's domain has an SPF record that does not authorize the sending
48             # email server to send email from the domain.
49             # - Modify the SPF record to include the server you're trying to send from or remove the SPF
50             # record from the domain.
51             'IB508' => 'authfailure',
52              
53             # - 421 Temporarily rejected. Reverse DNS for this IP failed. IB108
54             # - The IP address attempting to send mail does not have reverse DNS setup, or the DNS
55             # lookup failed.
56             # - Verify the sending IP address has reverse DNS set up before resending the email.
57             # GoDaddy manages reverse DNS when using our email services. We do not support custom
58             # reverse DNS.
59             'IB108' => 'requireptr',
60              
61             # Content bounces
62             # -----------------------------------------------------------------------------------------
63             # - 552 This message has been rejected due to content judged to be spam by the internet
64             # community. IB212
65             # - The email message contains a link, attachment or pattern caught by our filters as spam.
66             'IB212' => 'spamdetected',
67              
68             # - 552 Virus infected message rejected. IB705
69             # - The email message containing a link, attachment or pattern caught by our filters as a
70             # possible virus.
71             'IB705' => 'virusdetected',
72              
73             # Rate limiting bounces
74             # -----------------------------------------------------------------------------------------
75             # - 452 This message contains too many recipients. Reduce the number of recipients and
76             # retry. IB605
77             # - The message has attempted to mail too many recipients.
78             # - Reduce the number of recipients and try again.
79             'IB605' => 'ratelimited',
80              
81             # - 421 Connection refused, too many sessions from This IP. Lower the number of concurrent
82             # sessions. IB007
83             # - This IP address currently has too many sessions open.
84             # - Check with your email provider to reduce the number of open sessions on your IP address
85             # and then try again.
86             'IB007' => 'ratelimited',
87              
88             # - 421 Server temporarily unavailable. Try again later. IB101
89             # - The email queue is experiencing higher than normal email volume.
90             # - Try again later.
91             'IB101' => 'ratelimited',
92              
93             # - 554 This IP has been temporarily blocked for attempting to send too many messages
94             # containing content judged to be spam by the Internet community. IB110
95             # - This IP address has attempted to send too many messages containing content judged to be
96             # spam and has been blocked for an hour.
97             # - If you're not sending spam, you'll need to contact your Internet Service Provider (ISP)
98             # to see why your IP address is sending so many emails. Something in your system is
99             # causing the issue, and you'll need to troubleshoot.
100             'IB110' => 'blocked',
101              
102             # - 554 This IP has been blocked for the day, for attempting to send too many messages
103             # containing content judged to be spam by the Internet community. IB111
104             # - This IP address has attempted to send too many messages containing content judged to be
105             # spam and has been blocked for the remainder of the day.
106             'IB111' => 'blocked',
107              
108             # - 554 This IP has been temporarily blocked for attempting to mail too many invalid
109             # recipients. IB112
110             # - This IP address has attempted to email too many invalid recipients and has been blocked
111             # for an hour.
112             'IB112' => 'blocked',
113              
114             # - 554 This IP has been blocked for the day, for attempting to mail too many invalid
115             # recipients. IB113
116             # - This IP address has attempted to email too many invalid recipients and has been blocked
117             # for the remainder of the day.
118             'IB113' => 'blocked',
119              
120             # - 550 This IP has sent too many messages this hour. IB504
121             # - This IP address has reached the maximum allowed messages for that hour.
122             'IB504' => 'ratelimited',
123              
124             # - 550 This message has exceeded the max number of messages per session. Open a new session
125             # and try again. IB510
126             # - This IP address has reached the maximum allowed messages for that session.
127             'IB510' => 'ratelimited',
128              
129             # - 550 This IP has sent too many to too many recipients this hour. IB607
130             # - This IP address has reached the maximum allowed recipients for that hour.
131             'IB607' => 'ratelimited',
132              
133             # Remote block list (RBL) bounces
134             # -----------------------------------------------------------------------------------------
135             # - 554 Connection refused. This IP has a poor reputation on Cloudmark Sender Intelligence
136             # (CSI). IB103
137             # - This IP address has a poor reputation on Cloudmark Sender Intelligence (CSI).
138             'IB103' => 'badreputation',
139              
140             # - 554 Connection refused. This IP address is listed on the Spamhaus Block List (SBL). IB104
141             # - This IP address is listed on the Spamhaus Block List.
142             'IB104' => 'blocked',
143              
144             # - 554 Connection refused. This IP address is listed on the Exploits Block List (XBL). IB105
145             # - This IP address is listed on the Spamhaus Exploits Block List.
146             'IB105' => 'blocked',
147              
148             # - 554 Connection refused. This IP address is listed on the Policy Block List (PBL). IB106
149             # - This IP address is listed on the Spamhaus Policy Block List.
150             'IB106' => 'blocked',
151             };
152 19         97 state $messagesof = {
153             'authfailure' => [
154             # - 550 SPF Sender Invalid - envelope rejected
155             # - 550 5.7.9: This mail has been blocked because the sender is unauthenticated
156             # - 550-5.7.26 DKIM = did not pass
157             "spf sender invalid - envelope rejected",
158             "this mail has been blocked because the sender is unauthenticated",
159             "dkim = did not pass",
160             ],
161             'blocked' => [
162             # - 554 RBL Reject.
163             # - This IP address was blocked from our internal RBL.
164             # - Use the link provided in the bounceback to submit a request to remove this IP address.
165             'rbl reject',
166             'www.spamhaus.org/query/bl?ip='
167             ],
168             'expired' => [
169             # - 451 Sorry, I wasn't able to establish an SMTP connection. I'm not going to try again;
170             # this message has been in the queue too long.
171             # - The recipient's email address has been misspelled or the recipient's email provider
172             # has blocked sending from your address.
173             'has been in the queue too long',
174              
175             # - Delivery timeout
176             # - This could happen for several reasons.
177             'delivery timeout',
178             ],
179             'mailboxfull' => [
180             # - Account storage limit
181             # - The recipient's account has reached its storage limit and can't receive email right
182             # now.
183             # - The recipient needs to delete messages from their inbox or the receiving folder to
184             # make space for more email.
185             'account storage limit',
186             ],
187             'norelaying' => [
188             # - 550 5.7.1: Relay access denied
189             "relay access denied",
190             ],
191             'ratelimited' => [
192             # - 550 5.7.232 Your message can't be sent because your trial tenant has exceeded
193             # its daily limit for sending email to external recipients (tenant external recipient rate limit)
194             # - 550 5.7.233 - Your message can't be sent because your tenant exceeded its daily
195             # limit for sending email to external recipients (tenant external recipient rate limit)
196             "exceeded its daily limit",
197             ],
198             'rejected' => [
199             # - 550 5.1.8 Access denied, bad outbound sender AS (42004)
200             "bad outbound sender as (42004)",
201             ],
202             'securityerror' => [
203             # - 550 Please turn on SMTP Authentication in your mail client
204             "turn on smtp authentication in your mail client",
205             ],
206             'spamdetected' => [
207             # - 552 Message rejected for spam or virus content
208             # - The email message contains a link, attachment, or pattern caught by our filters as spam.
209             'message rejected for spam or virus content',
210             ],
211             'suspend' => [
212             # - Account disabled
213             # - The recipient account exists but its ability to receive mail was disabled.
214             # - Typically, these accounts remain permanently disabled, but you can try sending the
215             # email again later.
216             'account disabled',
217             ],
218             'systemerror' => [
219             # - This message is looping: it already has my Delivered-To line. (#5.4.6)
220             # - The recipient account is forwarding the message in a loop.
221             # - This is oftentimes because the receiver has two addresses that forward to each
222             # other. They need to correct their forwarding settings.
223             'message is looping',
224             ],
225             'userunknown' => [
226             # - 550 Recipient not found
227             # - The recipient is not a valid email address.
228             # - Remove the invalid recipient from your email.
229             'recipient not found',
230              
231             # - Account does not exist
232             # - The email address that you sent to does not exist.
233             # - Verify that the recipient email address was entered correctly.
234             'account does not exist'
235             ],
236             };
237              
238 19         46 my $issuedcode = $argvs->{'diagnosticcode'};
239 19         60 my $positionib = index($issuedcode, ' IB');
240 19         33 my $reasontext = '';
241              
242             # 192.0.2.22 has sent to too many recipients this hour. IB607 ...
243 19 100 50     127 $reasontext = $errorcodes->{ substr($issuedcode, $positionib + 1, 5) } || '' if $positionib > 1;
244 19 100       99 return $reasontext if length $reasontext;
245              
246 8         24 $issuedcode = lc $issuedcode;
247 8         47 for my $e ( keys %$messagesof ) {
248             # Try to find the error message matches with the given error message string
249 55 100       90 next unless grep { index($issuedcode, $_) > -1 } $messagesof->{ $e }->@*;
  83         174  
250 6         43 $reasontext = $e;
251 6         13 last;
252             }
253 8         65 return $reasontext;
254             }
255              
256             1;
257             __END__