File Coverage

lib/Sisimai/Rhost/YahooInc.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::YahooInc;
2 7     7   2207 use v5.26;
  7         24  
3 7     7   29 use strict;
  7         12  
  7         152  
4 7     7   22 use warnings;
  7         11  
  7         2097  
5              
6             sub find {
7             # Detect bounce reason from Yahoo Inc. (*.yahoodns.net)
8             # @param [Sisimai::Fact] argvs Decoded email object
9             # @return [String] The bounce reason for YahooInc
10             # @see https://senders.yahooinc.com/smtp-error-codes
11             # https://smtpfieldmanual.com/provider/yahoo
12             # https://www.postmastery.com/yahoo-postmaster/
13             # @since v5.1.0
14 52     52 0 729 my $class = shift;
15 52 100 100     166 my $argvs = shift // return ""; return "" unless $argvs->{'diagnosticcode'};
  51         196  
16              
17 50         156 state $messagesof = {
18             'authfailure' => [
19             # - 550 5.7.9 This mail has been blocked because the sender is unauthenticated. Yahoo
20             # requires all senders to authenticate with either SPF or DKIM.
21             'yahoo requires all senders to authenticate with either spf or dkim',
22             ],
23             'blocked' => [
24             # - 553 5.7.1 [BL21] Connections will not be accepted from 192.0.2.25,
25             # because the ip is in Spamhaus's list; see http://postmaster.yahoo.com/550-bl23.html
26             # - 553 5.7.1 [BL23] Connections not accepted from IP addresses on Spamhaus XBL;
27             # see http://postmaster.yahoo.com/errors/550-bl23.html [550]",
28             " because the ip is in spamhaus's list;",
29             'not accepted from ip addresses on spamhaus xbl',
30             ],
31             'norelaying' => [
32             # - 550 relaying denied for <***@yahoo.com>
33             'relaying denied for ',
34             ],
35             'notcompliantrfc' => ['headers are not rfc compliant'],
36             'policyviolation' => [
37             # - 554 Message not allowed - [PH01] Email not accepted for policy reasons.
38             # Please visit https://postmaster.yahooinc.com/error-codes
39             # - 554 5.7.9 Message not accepted for policy reasons.
40             # See https://postmaster.yahooinc.com/error-codes
41             'not accepted for policy reasons',
42             ],
43             'ratelimited' => [
44             # - 421 Max message per connection reached, closing transmission channel
45             'max message per connection reached',
46             # - 450 User is receiving mail too quickly
47             'user is receiving mail too quickly',
48             ],
49             'rejected' => [
50             # Observed the following error message since around March 2024:
51             #
52             # - 421 4.7.0 [TSS04] Messages from 192.0.2.25 temporarily deferred due to unexpected
53             # volume or user complaints - 4.16.55.1;
54             # see https://postmaster.yahooinc.com/error-codes (in reply to MAIL FROM command))
55             #
56             # However, the same error message is returned even for domains that are considered to
57             # have a poor reputation without SPF, DKIM, or DMARC settings, or for other reasons.
58             # It seems that the error message is not as granular as Google's.
59             'temporarily deferred due to unexpected volume or user complaints',
60              
61             # - 451 Message temporarily deferred due to unresolvable RFC.5321 from domain.
62             # See https://senders.yahooinc.com/error-codes#unresolvable-from-domain
63             'due to unresolvable rfc.5321 domain',
64              
65             # - 553 5.7.2 [TSS09] All messages from 192.0.2.25 will be permanently deferred;
66             # Retrying will NOT succeed. See https://postmaster.yahooinc.com/error-codes
67             # - 553 5.7.2 [TSS11] All messages from 192.0.2.25 will be permanently deferred;
68             # Retrying will NOT succeed. See https://postmaster.yahooinc.com/error-codes
69             ' will be permanently deferred',
70             ],
71             'suspend' => [
72             # - 554 delivery error: dd ****@yahoo.com is no longer valid.
73             # - 554 30 Sorry, your message to *****@aol.jp cannot be delivered.
74             # This mailbox is disabled (554.30)
75             ' is no longer valid.',
76             'this mailbox is disabled',
77             ],
78             'syntaxerror' => [
79             # - 501 Syntax error in parameters or arguments
80             'syntax error in parameters or arguments',
81             ],
82             'userunknown' => [
83             # - 554 delivery error: dd This user doesn't have a yahoo.com account (***@yahoo.com)
84             # - 552 1 Requested mail action aborted, mailbox not found (in reply to end of DATA command)
85             "dd this user doesn't have a ",
86             'mailbox not found',
87             ],
88             };
89              
90 50         155 my $issuedcode = lc $argvs->{'diagnosticcode'};
91 50         106 my $reasontext = '';
92              
93 50         249 for my $e ( keys %$messagesof ) {
94             # Try to find the error message matches with the given error message string
95 327 100       589 next unless grep { index($issuedcode, $_) > -1 } $messagesof->{ $e }->@*;
  487         1030  
96 48         70 $reasontext = $e;
97 48         106 last;
98             }
99 50         215 return $reasontext;
100             }
101              
102             1;
103             __END__