diff --git a/lib/sisimai/rhost/yahooinc.rb b/lib/sisimai/rhost/yahooinc.rb new file mode 100644 index 00000000..305b1914 --- /dev/null +++ b/lib/sisimai/rhost/yahooinc.rb @@ -0,0 +1,102 @@ +module Sisimai + module Rhost + # Sisimai::Rhost detects the bounce reason from the content of Sisimai::Fact object as an argument + # of get() method when the value of "destination" of the object is "*.yahoodns.net". + # This class is called only Sisimai::Fact class. + module YahooInc + class << self + MessagesOf = { + 'authfailure' => [ + # - 550 5.7.9 This mail has been blocked because the sender is unauthenticated. Yahoo + # requires all senders to authenticate with either SPF or DKIM. + 'yahoo requires all senders to authenticate with either spf or dkim', + ], + 'badreputation' => [ + # - 421 4.7.0 [TSS04] Messages from 192.0.2.25 temporarily deferred due to unexpected + # volume or user complaints - 4.16.55.1; + # see https://postmaster.yahooinc.com/error-codes (in reply to MAIL FROM command)) + 'temporarily deferred due to unexpected volume or user complaints', + ], + 'blocked' => [ + # - 553 5.7.1 [BL21] Connections will not be accepted from 192.0.2.25, + # because the ip is in Spamhaus's list; see http://postmaster.yahoo.com/550-bl23.html + # - 553 5.7.1 [BL23] Connections not accepted from IP addresses on Spamhaus XBL; + # see http://postmaster.yahoo.com/errors/550-bl23.html [550]", + " because the ip is in spamhaus's list;", + 'not accepted from ip addresses on spamhaus xbl', + ], + 'norelaying' => [ + # - 550 relaying denied for <***@yahoo.com> + 'relaying denied for ', + ], + 'notcomplaintrfc' => ['headers are not rfc compliant'], + 'policyviolation' => [ + # - 554 Message not allowed - [PH01] Email not accepted for policy reasons. + # Please visit https://postmaster.yahooinc.com/error-codes + # - 554 5.7.9 Message not accepted for policy reasons. + # See https://postmaster.yahooinc.com/error-codes + 'not accepted for policy reasons', + ], + 'rejected' => [ + # - 553 5.7.2 [TSS09] All messages from 192.0.2.25 will be permanently deferred; + # Retrying will NOT succeed. See https://postmaster.yahooinc.com/error-codes + # - 553 5.7.2 [TSS11] All messages from 192.0.2.25 will be permanently deferred; + # Retrying will NOT succeed. See https://postmaster.yahooinc.com/error-codes + ' will be permanently deferred', + ], + 'speeding' => [ + # - 450 User is receiving mail too quickly + 'User is receiving mail too quickly', + ], + 'suspend' => [ + # - 554 delivery error: dd ****@yahoo.com is no longer valid. + # - 554 30 Sorry, your message to *****@aol.jp cannot be delivered. + # This mailbox is disabled (554.30) + ' is no longer valid.', + 'This mailbox is disabled', + ], + 'syntaxerror' => [ + # - 501 Syntax error in parameters or arguments + 'syntax error in parameters or arguments', + ], + 'toomanyconn' => [ + # - 421 Max message per connection reached, closing transmission channel + 'max message per connection reached', + ], + 'userunknown' => [ + # - 554 delivery error: dd This user doesn't have a yahoo.com account (***@yahoo.com) + # - 552 1 Requested mail action aborted, mailbox not found (in reply to end of DATA command) + "dd this user doesn't have a ", + 'mailbox not found', + ], + }.freeze + + # Detect bounce reason from Yahoo Inc. (*.yahoodns.net) + # @param [Sisimai::Fact] argvs Parsed email object + # @return [String] The bounce reason for YahooInc + # @see https://senders.yahooinc.com/smtp-error-codes + # https://smtpfieldmanual.com/provider/yahoo + # https://www.postmastery.com/yahoo-postmaster/ + def get(argvs) + return argvs['reason'] unless argvs['reason'].empty? + + issuedcode = argvs['diagnosticcode'].downcase + reasontext = '' + + MessagesOf.each_key do |e| + MessagesOf[e].each do |f| + next unless issuedcode.include?(f) + reasontext = e + break + end + break if reasontext.size > 0 + end + + return reasontext + end + + end + end + end +end + diff --git a/set-of-emails/maildir/bsd/rhost-yahooinc-01.eml b/set-of-emails/maildir/bsd/rhost-yahooinc-01.eml new file mode 100644 index 00000000..96c3099b --- /dev/null +++ b/set-of-emails/maildir/bsd/rhost-yahooinc-01.eml @@ -0,0 +1,80 @@ +Return-Path: <> +Received: from mbox.example.jp (mail.example.jp [192.0.2.48]) + by mx.example.jp (V8/cf) with ESMTP id 0AD0mYaG000334 + for ; Fri, 13 Nov 2020 09:48:34 +0900 +Received: from mbox.example.jp (localhost [127.0.0.1]) + by mbox.example.jp (Postfix) with ESMTP id 4CXKb61hkLz22xZY + for ; Fri, 13 Nov 2020 09:48:34 +0900 (JST) +Received: from smtp.example.jp (smtp.example.jp [203.0.113.113]) + by mbox.example.jp (Postfix) with ESMTP id 4CXKb61FPyz1yM4D + for ; Fri, 13 Nov 2020 09:48:34 +0900 (JST) +Received: by smtp.example.jp (Postfix) + id 056C3D244EC; Fri, 13 Nov 2020 09:48:34 +0900 (JST) +Date: Fri, 13 Nov 2020 09:48:34 +0900 (JST) +From: MAILER-DAEMON@smtp.example.jp (Mail Delivery System) +Subject: Undelivered Mail Returned to Sender +To: postmaster@sisimai.example.com +Auto-Submitted: auto-replied +MIME-Version: 1.0 +Content-Type: multipart/report; report-type=delivery-status; + boundary="08513C0196A.1605228514/smtp.example.jp" +Message-Id: <20201113004834.056C3D244EC@smtp.example.jp> +X-Virus-Scanned: ClamAV using ClamSMTP + +This is a MIME-encapsulated message. + +--08513C0196A.1605228514/smtp.example.jp +Content-Description: Notification +Content-Type: text/plain; charset=us-ascii + +This is the mail system at host smtp.example.jp. + +I'm sorry to have to inform you that your message could not +be delivered to one or more recipients. It's attached below. + +For further assistance, please send mail to postmaster. + +If you do so, please include this problem report. You can +delete your own text from the attached returned message. + + The mail system + + : host mx-aol.mail.gm0.yahoodns.net[67.195.204.80] said: + 554 5.7.9 Message not accepted for policy reasons. See + https://postmaster.verizonmedia.com/error-codes (in reply to end of DATA + command) + +--08513C0196A.1605228514/smtp.example.jp +Content-Description: Delivery report +Content-Type: message/delivery-status + +Reporting-MTA: dns; smtp.example.jp +X-Postfix-Queue-ID: 08513C0196A +X-Postfix-Sender: rfc822; postmaster@sisimai.example.com +Arrival-Date: Fri, 13 Nov 2020 09:47:59 +0900 (JST) + +Final-Recipient: rfc822; kijitora@aol.example.jp +Original-Recipient: rfc822;kijitora@aol.example.jp +Action: failed +Status: 5.7.9 +Remote-MTA: dns; mx-aol.mail.gm0.yahoodns.net +Diagnostic-Code: smtp; 554 5.7.9 Message not accepted for policy reasons. See + https://postmaster.verizonmedia.com/error-codes + +--08513C0196A.1605228514/smtp.example.jp +Content-Description: Undelivered Message +Content-Type: message/rfc822 + +Return-Path: +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by smtp.example.jp (Postfix) with ESMTP id 08513C0196A + for ; Fri, 13 Nov 2020 09:47:59 +0900 (JST) +From: postmaster@libsisimai.org +Subject: TEST FOR DMARC #7 +To: kijitora@aol.example.jp +Message-Id: <20201113004812.08513C0196A@smtp.example.jp> +Date: Fri, 13 Nov 2020 09:47:59 +0900 (JST) + +Nyaan + +--08513C0196A.1605228514/smtp.example.jp-- diff --git a/set-of-emails/maildir/bsd/rhost-yahooinc-02.eml b/set-of-emails/maildir/bsd/rhost-yahooinc-02.eml new file mode 100644 index 00000000..84121a15 --- /dev/null +++ b/set-of-emails/maildir/bsd/rhost-yahooinc-02.eml @@ -0,0 +1,83 @@ +Return-Path: <> +Delivered-To: deadbeef@mailmagazine.example.com +Received: from u1.em.example.jp + by mbox3.em.example.jp with LMTP id pRi6D904298QQXvAukD22R + for ; Tue, 17 Nov 2020 23:34:45 +0900 +Received: by u1.em.example.jp (Postfix) + id 9UKnCx1J50z3ZQ2; Tue, 17 Nov 2020 23:34:45 +0900 (JST) +Date: Tue, 17 Nov 2020 23:34:45 +0900 (JST) +From: MAILER-DAEMON@u1.em.example.jp (Mail Delivery System) +Subject: Undelivered Mail Returned to Sender +To: deadbeef@mailmagazine.example.com +Auto-Submitted: auto-replied +MIME-Version: 1.0 +Content-Type: multipart/report; report-type=delivery-status; + boundary="9UK8Prr4eZzSPQR.1605555025/u1.em.example.jp" +Message-Id: <9UKnCx1J50z3ZQ2@u1.em.example.jp> + +This is a MIME-encapsulated message. + +--9UK8Prr4eZzSPQR.1605555025/u1.em.example.jp +Content-Description: Notification +Content-Type: text/plain; charset=us-ascii + +This is the mail system at host u1.em.example.jp. + +I'm sorry to have to inform you that your message could not +be delivered to one or more recipients. It's attached below. + +For further assistance, please send mail to postmaster. + +If you do so, please include this problem report. You can +delete your own text from the attached returned message. + + The mail system + +: host mta6.am0.yahoodns.net[67.195.204.72] said: 421 + 4.7.0 [TSS04] Messages from 192.0.2.192 temporarily deferred due to + unexpected volume or user complaints - 4.16.55.1; see + https://postmaster.verizonmedia.com/error-codes (in reply to MAIL FROM + command) + +--9UK8Prr4eZzSPQR.1605555025/u1.em.example.jp +Content-Description: Delivery report +Content-Type: message/delivery-status + +Reporting-MTA: dns; u1.em.example.jp +X-Postfix-Queue-ID: 9UK8Prr4eZzSPQR +X-Postfix-Sender: rfc822; deadbeef@mailmagazine.example.com +Arrival-Date: Mon, 16 Nov 2020 23:34:45 +0900 (JST) + +Final-Recipient: rfc822; kijitora@y.example.ca +Original-Recipient: rfc822;kijitora@y.example.ca +Action: failed +Status: 4.7.0 +Remote-MTA: dns; mta6.am0.yahoodns.net +Diagnostic-Code: smtp; 421 4.7.0 [TSS04] Messages from 192.0.2.192 + temporarily deferred due to unexpected volume or user complaints - + 4.16.55.1; see https://postmaster.verizonmedia.com/error-codes + +--9UK8Prr4eZzSPQR.1605555025/u1.em.example.jp +Content-Description: Undelivered Message +Content-Type: message/rfc822 + +Return-Path: +Received: from u1.em.example.jp (localhost [127.0.0.1]) + by u1.em.example.jp (Postfix) with ESMTP id 9UK8Prr4eZzSPQR + for ; Mon, 16 Nov 2020 23:34:45 +0900 (JST) +Received: from localhost (localhost [127.0.0.1]) + by u1.em.example.jp (Postfix) with ESMTP id 9UK8P757b8z3ZQM + for ; Mon, 16 Nov 2020 23:34:45 +0900 (JST) +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-2022-JP +Content-Transfer-Encoding: quoted-printable +From: +To: "Kijitora" +Subject: Nyaan +Message-Id: <9UK8P757b8z3ZQM@u1.em.example.jp> +Date: Mon, 16 Nov 2020 23:34:45 +0900 (JST) +X-Virus-Scanned: ClamAV using ClamSMTP + +Nyaan + +--9UK8Prr4eZzSPQR.1605555025/u1.em.example.jp-- diff --git a/set-of-emails/maildir/bsd/rhost-yahooinc-03.eml b/set-of-emails/maildir/bsd/rhost-yahooinc-03.eml new file mode 100644 index 00000000..12028d8e --- /dev/null +++ b/set-of-emails/maildir/bsd/rhost-yahooinc-03.eml @@ -0,0 +1,125 @@ +Return-Path: <> +Received: from mx2.example.jp (mx2.example.jp [192.0.2.222]) + by aneyakoji.example.co.jp (V8/cf) with ESMTP id u8CJoVRB027731 + for ; Tue, 13 Sep 2016 04:50:33 +0900 +X-SenderID: Sendmail Sender-ID Filter v1.0.0 aneyakoji.example.co.jp u8CJoVRB027731 +Authentication-Results: aneyakoji.example.co.jp; sender-id=none header.from=MAILER-DAEMON@mx2.example.jp +Received: from localhost (localhost) + by mx2.example.jp (V8/cf) id u8CJoQN4016081; + Tue, 13 Sep 2016 04:50:33 +0900 +Date: Tue, 13 Sep 2016 04:50:33 +0900 +From: Mail Delivery Subsystem +Message-Id: <201609121950.u8CJoQN4016081@mx2.example.jp> +To: postmaster@mx2.example.jp +MIME-Version: 1.0 +Content-Type: multipart/report; report-type=delivery-status; + boundary="u8CJoQN4016081.1473709833/mx2.example.jp" +Subject: Postmaster notify: see transcript for details +Auto-Submitted: auto-generated (postmaster-notification) + +This is a MIME-encapsulated message + +--u8CJoQN4016081.1473709833/mx2.example.jp + +The original message was received at Tue, 13 Sep 2016 04:50:26 +0900 +from localhost +with id u8CJoQN3016081 + + ----- The following addresses had permanent fatal errors ----- + + (reason: 554 delivery error: dd This user doesn't have a yahoo.com account (this-local-part-does-not-exist@yahoo.com) [0] - mta1061.mail.ne1.yahoo.com) + + ----- Transcript of session follows ----- +... while talking to mta6.am0.yahoodns.net.: +>>> DATA +<<< 554 delivery error: dd This user doesn't have a yahoo.com account (this-local-part-does-not-exist@yahoo.com) [0] - mta1061.mail.ne1.yahoo.com +554 5.0.0 Service unavailable + +--u8CJoQN4016081.1473709833/mx2.example.jp +Content-Type: message/delivery-status + +Reporting-MTA: dns; mx2.example.jp +Received-From-MTA: DNS; FF00FFFF.static.example.org +Arrival-Date: Tue, 13 Sep 2016 04:50:26 +0900 + +Final-Recipient: RFC822; this-local-part-does-not-exist@yahoo.com +Action: failed +Status: 5.0.0 +Remote-MTA: DNS; mta6.am0.yahoodns.net +Diagnostic-Code: SMTP; 554 delivery error: dd This user doesn't have a yahoo.com account (this-local-part-does-not-exist@yahoo.com) [0] - mta1061.mail.ne1.yahoo.com +Last-Attempt-Date: Tue, 13 Sep 2016 04:50:30 +0900 + +--u8CJoQN4016081.1473709833/mx2.example.jp +Content-Type: message/rfc822 + +Return-Path: +Received: from localhost (localhost) + by mx2.example.jp (V8/cf) id u8CJoQN3016081; + Tue, 13 Sep 2016 04:50:26 +0900 +Date: Tue, 13 Sep 2016 04:50:26 +0900 +From: Mail Delivery Subsystem +Message-Id: <201609121950.u8CJoQN3016081@mx2.example.jp> +To: +To: postmaster +MIME-Version: 1.0 +Content-Type: multipart/report; report-type=delivery-status; + boundary="u8CJoQN3016081.1473709826/mx2.example.jp" +Subject: Returned mail: see transcript for details +Auto-Submitted: auto-generated (failure) + +This is a MIME-encapsulated message + +--u8CJoQN3016081.1473709826/mx2.example.jp + +... + +--u8CJoQN3016081.1473709826/mx2.example.jp +Content-Type: message/delivery-status + +Reporting-MTA: dns; mx2.example.jp +Received-From-MTA: DNS; FF00FFFF.static.example.org +Arrival-Date: Tue, 13 Sep 2016 04:50:25 +0900 + +Original-Recipient: rfc822;kijitora@neko.example.com +Final-Recipient: RFC822; kijitora@neko.example.com +Action: failed +Status: 5.3.5 +Diagnostic-Code: SMTP; 553 5.3.5 system config error +Last-Attempt-Date: Tue, 13 Sep 2016 04:50:26 +0900 + +--u8CJoQN3016081.1473709826/mx2.example.jp +Content-Type: message/rfc822 + +Return-Path: +Received: from mx.smtp.example.net (FF00FFFF.static.example.org [198.51.100.22]) + by mx2.example.jp (V8/cf) with ESMTP id u8CJoPN3016079 + for ; Tue, 13 Sep 2016 04:50:25 +0900 +Message-Id: <201609121950.u8CJoPN3016079@mx2.example.jp> +Received: from User (unknown [203.0.113.2]) + (Authenticated sender: server) + by mx.smtp.example.net (Postfix) with ESMTPA id 23EC336A7E; + Mon, 12 Sep 2016 13:35:38 +0200 (CEST) +Reply-To: +From: "NON-EXISTENT" +Subject: Nyaan +Date: Mon, 12 Sep 2016 13:35:46 +0200 +MIME-Version: 1.0 +Content-Type: text/html; + charset="Windows-1251" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2600.0000 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 +To: undisclosed-recipients:; + + + + + + +--u8CJoQN3016081.1473709826/mx2.example.jp-- + + +--u8CJoQN4016081.1473709833/mx2.example.jp-- + diff --git a/test/public/rhost-yahooinc.rb b/test/public/rhost-yahooinc.rb new file mode 100644 index 00000000..c3522819 --- /dev/null +++ b/test/public/rhost-yahooinc.rb @@ -0,0 +1,11 @@ +module RhostEngineTest::Public + module YahooInc + IsExpected = { + # INDEX => [['D.S.N.', 'replycode', 'REASON', 'hardbounce'], [...]] + '01' => [['5.7.9', '554', 'policyviolation', false]], + '02' => [['4.7.0', '421', 'badreputation', false]], + '03' => [['5.0.0', '554', 'userunknown', true]], + } + end +end +