File Coverage

lib/Sisimai/Rhost/Apple.pm
Criterion Covered Total %
statement 20 20 100.0
branch 4 4 100.0
condition 2 2 100.0
subroutine 4 4 100.0
pod 0 1 0.0
total 30 31 96.7


line stmt bran cond sub pod time code
1             package Sisimai::Rhost::Apple;
2 9     9   2250 use v5.26;
  9         34  
3 9     9   50 use strict;
  9         15  
  9         230  
4 9     9   50 use warnings;
  9         33  
  9         3002  
5              
6             sub find {
7             # Detect bounce reason from Apple iCloud Mail
8             # @param [Sisimai::Fact] argvs Decoded email object
9             # @return [String] The bounce reason for Apple
10             # @see
11             # @since v5.1.0
12             # - Postmaster information for iCloud Mail: https://support.apple.com/en-us/102322
13             # - https://www.postmastery.com/icloud-postmastery-page/
14             # - https://smtpfieldmanual.com/provider/apple
15 64     64 0 1301 my $class = shift;
16 64 100 100     251 my $argvs = shift // return ""; return '' unless length $argvs->{'diagnosticcode'};
  63         301  
17              
18 62         339 state $messagesof = {
19             'authfailure' => [
20             # - 554 5.7.1 Your message was rejected due to example.jp's DMARC policy.
21             # See https://support.apple.com/en-us/HT204137 for
22             # - 554 5.7.1 [HME1] This message was blocked for failing both SPF and DKIM authentication
23             # checks. See https://support.apple.com/en-us/HT204137 for mailing best practices
24             's dmarc policy',
25             'blocked for failing both spf and dkim autentication checks',
26             ],
27             'blocked' => [
28             # - 550 5.7.0 Blocked - see https://support.proofpoint.com/dnsbl-lookup.cgi?ip=192.0.1.2
29             # - 550 5.7.1 Your email was rejected due to having a domain present in the Spamhaus
30             # DBL -- see https://www.spamhaus.org/dbl/
31             # - 550 5.7.1 Mail from IP 192.0.2.1 was rejected due to listing in Spamhaus SBL.
32             # For details please see http://www.spamhaus.org/query/bl?ip=x.x.x.x
33             # - 554 ****-smtpin001.me.com ESMTP not accepting connections
34             'rejected due to having a domain present in the spamhaus',
35             'rejected due to listing in spamhaus',
36             'blocked - see https://support.proofpoint.com/dnsbl-lookup',
37             'not accepting connections',
38             ],
39             'hasmoved' => [
40             # - 550 5.1.6 recipient no longer on server: *****@icloud.com
41             'recipient no longer on server',
42             ],
43             'mailboxfull' => [
44             # - 552 5.2.2 <****@icloud.com>: user is over quota (in reply to RCPT TO command)
45             'user is over quota',
46             ],
47             'norelaying' => [
48             # - 554 5.7.1 <*****@icloud.com>: Relay access denied
49             'relay access denied',
50             ],
51             'notaccept' => ['host/domain does not accept mail'],
52             'policyviolation' => [
53             # - 550 5.7.1 [CS01] Message rejected due to local policy.
54             # Please visit https://support.apple.com/en-us/HT204137
55             'due to local policy',
56             ],
57             'ratelimited' => [
58             # - 421 4.7.1 Messages to ****@icloud.com deferred due to excessive volume.
59             # Try again later - https://support.apple.com/en-us/HT204137
60             'due to excessive volume',
61             ],
62             'rejected' => [
63             # - 450 4.1.8 : Sender address rejected: Domain not found
64             'sender address rejected',
65             ],
66             'suspend' => [
67             # - https://support.apple.com/guide/icloud/stop-using-or-reactivate-addresses-mm3adb030cbf/icloud
68             # - 550 5.1.1 <****@icloud.com>: inactive email address (in reply to RCPT TO command)
69             "inactive email address",
70             ],
71             'userunknown' => [
72             # - 550 5.1.1 <****@icloud.com>: inactive email address (in reply to RCPT TO command)
73             # - 550 5.1.1 unknown or illegal alias: ****@icloud.com
74             'user does not exist',
75             'unknown or illegal alias',
76             ],
77             };
78 62         233 my $issuedcode = lc $argvs->{'diagnosticcode'};
79 62         139 my $reasontext = '';
80              
81 62         408 for my $e ( keys %$messagesof ) {
82             # Try to find the error message matches with the given error message string
83 385 100       697 next unless grep { index($issuedcode, $_) > -1 } $messagesof->{ $e }->@*;
  600         1395  
84 54         95 $reasontext = $e;
85 54         103 last;
86             }
87 62         333 return $reasontext;
88             }
89              
90             1;
91             __END__