-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#288 Implement Sisimai::Rhost::Apple (iCloud Mail)
- Loading branch information
1 parent
99c3f1e
commit 4e7923c
Showing
6 changed files
with
414 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
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 "mail.icloud.com" or "apple.com". | ||
# This class is called only Sisimai::Fact class. | ||
module Apple | ||
class << self | ||
MessagesOf = { | ||
'authfailure' => [ | ||
# - 554 5.7.1 Your message was rejected due to example.jp's DMARC policy. | ||
# See https://support.apple.com/en-us/HT204137 for | ||
# - 554 5.7.1 [HME1] This message was blocked for failing both SPF and DKIM authentication | ||
# checks. See https://support.apple.com/en-us/HT204137 for mailing best practices | ||
's dmarc policy', | ||
'blocked for failing both spf and dkim autentication checks', | ||
], | ||
'blocked' => [ | ||
# - 550 5.7.0 Blocked - see https://support.proofpoint.com/dnsbl-lookup.cgi?ip=192.0.1.2 | ||
# - 550 5.7.1 Your email was rejected due to having a domain present in the Spamhaus | ||
# DBL -- see https://www.spamhaus.org/dbl/ | ||
# - 550 5.7.1 Mail from IP 192.0.2.1 was rejected due to listing in Spamhaus SBL. | ||
# For details please see http://www.spamhaus.org/query/bl?ip=x.x.x.x | ||
# - 554 ****-smtpin001.me.com ESMTP not accepting connections | ||
'rejected due to having a domain present in the spamhaus', | ||
'rejected due to listing in spamhaus', | ||
'blocked - see https://support.proofpoint.com/dnsbl-lookup', | ||
'not accepting connections', | ||
], | ||
'hasmoved' => [ | ||
# - 550 5.1.6 recipient no longer on server: *****@icloud.com | ||
'recipient no longer on server', | ||
], | ||
'mailboxfull' => [ | ||
# - 552 5.2.2 <****@icloud.com>: user is over quota (in reply to RCPT TO command) | ||
'user is over quota', | ||
], | ||
'norelaying' => [ | ||
# - 554 5.7.1 <*****@icloud.com>: Relay access denied | ||
'relay access denied', | ||
], | ||
'notaccept' => ['host/domain does not accept mail'], | ||
'policyviolation' => [ | ||
# - 550 5.7.1 [CS01] Message rejected due to local policy. | ||
# Please visit https://support.apple.com/en-us/HT204137 | ||
'due to local policy', | ||
], | ||
'rejected' => [ | ||
# - 450 4.1.8 <kijitora@example.jp>: Sender address rejected: Domain not found | ||
'sender address rejected', | ||
], | ||
'speeding' => [ | ||
# - 421 4.7.1 Messages to ****@icloud.com deferred due to excessive volume. | ||
# Try again later - https://support.apple.com/en-us/HT204137 | ||
'due to excessive volume', | ||
], | ||
'userunknown' => [ | ||
# - 550 5.1.1 <****@icloud.com>: inactive email address (in reply to RCPT TO command) | ||
# - 550 5.1.1 unknown or illegal alias: ****@icloud.com | ||
'inactive email address', | ||
'user does not exist', | ||
'unknown or illegal alias', | ||
], | ||
}.freeze | ||
|
||
# Detect bounce reason from Apple iCloud Mail | ||
# @param [Sisimai::Fact] argvs Parsed email object | ||
# @return [String] The bounce reason for Apple | ||
# @see https://support.apple.com/en-us/102322 | ||
# https://www.postmastery.com/icloud-postmastery-page/ | ||
# https://smtpfieldmanual.com/provider/apple | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
Return-path: <> | ||
Envelope-to: nekonyaan@example.com | ||
Delivery-date: Thu, 17 Jul 2014 23:34:45 -0500 | ||
Received: from mail-in2.apple.com ([192.0.2.1]:1111) | ||
by neko.example.com with esmtp (Exim 4.80) | ||
id 20000A-00000B-NN | ||
for nekonyaan@example.com; Thu, 17 Jul 2014 23:34:45 -0500 | ||
From: <Mailer-Daemon@mail-in2.apple.com> (Mail Delivery System) | ||
Message-ID: <AA.BB.00000.00000CCC@mail-in2.apple.com> | ||
To: nekonyaan@example.com | ||
Subject: Undelivered Mail Returned to Sender | ||
Date: Thu, 17 Jul 2014 23:34:45 -0700 | ||
MIME-Version: 1.0 | ||
Content-Type: multipart/report; report-type=delivery-status; | ||
boundary="RnJpIEp1bCAxMyAyMjowNzoyMyBKU1QgMjAxOAo=" | ||
|
||
This is a MIME-encapsulated message. | ||
|
||
--RnJpIEp1bCAxMyAyMjowNzoyMyBKU1QgMjAxOAo= | ||
Content-Description: Notification | ||
Content-Type: text/plain | ||
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@example.jp> | ||
If you do so, please include this problem report. You can | ||
delete your own text from the attached returned message. | ||
<kijitora@example.jp>: 550 5.1.6 recipient no longer on server: kijitora@example.jp | ||
--RnJpIEp1bCAxMyAyMjowNzoyMyBKU1QgMjAxOAo= | ||
Content-Description: Delivery report | ||
Content-Type: message/delivery-status | ||
X-Symantec-Messaging-Gateway-Queue-ID: AA/AA-00000-00000000 | ||
X-Symantec-Messaging-Gateway-Sender: rfc822; nekonyaan@example.com | ||
Reporting-MTA: dns; mail-in2.apple.com | ||
Arrival-Date: Thu, 17 Jul 2014 23:34:45 -0700 | ||
Final-Recipient: rfc822; kijitora@example.jp | ||
Status: 5.1.6 | ||
Action: failed | ||
Last-Attempt-Date: Thu, 17 Jul 2014 23:34:45 -0700 | ||
Diagnostic-Code: smtp; 550 5.1.6 recipient no longer on server: kijitora@example.jp | ||
--RnJpIEp1bCAxMyAyMjowNzoyMyBKU1QgMjAxOAo= | ||
Content-Description: Undelivered Message | ||
Content-Type: message/rfc822 | ||
Received: from r1.example.com (r1.example.com [203.0.113.4]) | ||
by mail-in2.apple.com (Apple Secure Mail Relay) with SMTP id AA.AA.00000.00000000; Thu, 17 Jul 2014 23:34:45 -0700 (PDT) | ||
Received: by r1.example.com (Postfix, from userid 2202) | ||
id AAAAAAAACCCCC; Thu, 17 Jul 2014 23:34:45 -0500 (CDT) | ||
Received: from smtp2.example.com (smtp.example.com [192.0.2.225]) | ||
by r1.example.com (Postfix) with ESMTP id BBBBBBBB22222 | ||
for <kijitora@example.jp>; Thu, 17 Jul 2014 23:34:45 -0500 (CDT) | ||
Received: by smtp2.example.com (Postfix, from userid 2220) | ||
id AAAAAAAA00000; Thu, 17 Jul 2014 23:34:45 -0500 (CDT) | ||
Received: from neko.example.com (neko.example.com [198.51.100.198]) | ||
by smtp2.example.com (Postfix) with ESMTP id EEEEEEEE11112 | ||
for <kijitora@example.jp>; Thu, 17 Jul 2014 23:34:45 -0500 (CDT) | ||
Received: from neko22 by neko.example.com with local (Exim 4.80) | ||
(envelope-from <nekonyaan@example.com>) | ||
id 2Aneko-00022X-BB | ||
for kijitora@example.jp; Thu, 17 Jul 2014 23:34:45 -0500 | ||
To: kijitora@example.jp | ||
Subject: Nyaan | ||
Date: Thu, 17 Jul 2014 23:34:45 -0500 | ||
From: "Neko, Nyaan" <nekonyaan@example.com> | ||
Message-ID: <c15e793e1c6acf9fbc39d1547bbd98b4@example.com> | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain | ||
Nyaan | ||
--RnJpIEp1bCAxMyAyMjowNzoyMyBKU1QgMjAxOAo=-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
Return-Path: <> | ||
Received: from mbox.example.jp (mail.example.jp [192.0.2.25]) | ||
by mx.example.jp (V8/cf) with ESMTP id 0AD0lpdN032754 | ||
for <postmaster@example.jp>; Fri, 13 Nov 2020 09:47:51 +0900 | ||
Received: from mbox.example.jp (localhost [127.0.0.1]) | ||
by mbox.example.jp (Postfix) with ESMTP id 4CXKZH4NX1z22xZY | ||
for <postmaster@sisimai.example.com>; Fri, 13 Nov 2020 09:47:51 +0900 (JST) | ||
Received: from smtp.example.jp (smtp.example.jp [203.0.113.127]) | ||
by mbox.example.jp (Postfix) with ESMTP id 4CXKZH3xdDz1yM4D | ||
for <postmaster@sisimai.example.com>; Fri, 13 Nov 2020 09:47:51 +0900 (JST) | ||
Received: by smtp.example.jp (Postfix) | ||
id 7344BD244EC; Fri, 13 Nov 2020 09:47:51 +0900 (JST) | ||
Date: Fri, 13 Nov 2020 09:47:51 +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="3574FC0196A.1605228471/smtp.example.jp" | ||
Message-Id: <20201113004751.7344BD244EC@smtp.example.jp> | ||
X-Virus-Scanned: ClamAV using ClamSMTP | ||
|
||
This is a MIME-encapsulated message. | ||
|
||
--3574FC0196A.1605228471/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 | ||
<kijitora@apple.example.com>: host mx01.mail.icloud.com[17.57.152.9] said: 554 | ||
5.7.1 Your message was rejected due to libsisimai.org's DMARC policy. See | ||
https://support.apple.com/en-us/HT204137 for info (in reply to end of DATA | ||
command) | ||
--3574FC0196A.1605228471/smtp.example.jp | ||
Content-Description: Delivery report | ||
Content-Type: message/delivery-status | ||
Reporting-MTA: dns; smtp.example.jp | ||
X-Postfix-Queue-ID: 3574FC0196A | ||
X-Postfix-Sender: rfc822; postmaster@sisimai.example.com | ||
Arrival-Date: Fri, 13 Nov 2020 09:47:12 +0900 (JST) | ||
Final-Recipient: rfc822; kijitora@apple.example.com | ||
Original-Recipient: rfc822;kijitora@apple.example.com | ||
Action: failed | ||
Status: 5.7.1 | ||
Remote-MTA: dns; mx01.mail.icloud.com | ||
Diagnostic-Code: smtp; 554 5.7.1 Your message was rejected due to | ||
libsisimai.org's DMARC policy. See https://support.apple.com/en-us/HT204137 | ||
for info | ||
--3574FC0196A.1605228471/smtp.example.jp | ||
Content-Description: Undelivered Message | ||
Content-Type: message/rfc822 | ||
Return-Path: <postmaster@sisimai.example.com> | ||
Received: from [127.0.0.1] (localhost [127.0.0.1]) | ||
by smtp.example.jp (Postfix) with ESMTP id 3574FC0196A | ||
for <kijitora@apple.example.com>; Fri, 13 Nov 2020 09:47:12 +0900 (JST) | ||
Subject: TEST FOR DMARC #6 | ||
From: postmaster@libsisimai.org | ||
To: kijitora@apple.example.com | ||
Message-Id: <20201113004724.3574FC0196A@smtp.example.jp> | ||
Date: Fri, 13 Nov 2020 09:47:12 +0900 (JST) | ||
Nyaan | ||
--3574FC0196A.1605228471/smtp.example.jp-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
Return-Path: <> | ||
Delivered-To: neko@example.jp | ||
Received: from smtp1.example.jp (smtp1 [192.0.2.26]) | ||
by mx1.example.jp (Postfix) with ESMTPS id SGXNhJQdfczZsR5q | ||
for <kijitora@example.jp>; Thu, 29 Apr 2022 23:34:45 +0900 (JST) | ||
Received: by smtp1.example.jp (Postfix) | ||
id jGd1g4yXDZz3NtXL; Thu, 29 Apr 2022 23:34:45 +0900 (JST) | ||
Date: Thu, 29 Apr 2022 23:34:45 +0900 (JST) | ||
From: MAILER-DAEMON@smtp1.example.jp (Mail Delivery System) | ||
To: kijitora@example.jp | ||
Message-Id: <jGd1g4yXDZz3NtXL@smtp1.example.jp> | ||
Subject: Undelivered Mail Returned to Sender | ||
Content-Type: multipart/report; report-type=delivery-status; | ||
boundary="8nhz33cQRrzZfKG7.1697834505/smtp1.example.jp" | ||
MIME-Version: 1.0 | ||
|
||
This is a MIME-encapsulated message. | ||
|
||
--8nhz33cQRrzZfKG7.1697834505/smtp1.example.jp | ||
Content-Description: Notification | ||
Content-Type: text/plain; charset=us-ascii | ||
This is the mail system at host smtp1.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 | ||
<pseudo-local-part-of-apple-icloud-mail@icloud.com>: host mx02.mail.icloud.com[17.56.9.31] said: 552 | ||
5.2.2 <pseudo-local-part-of-apple-icloud-mail@icloud.com>: user is over quota (in reply to RCPT TO | ||
command) | ||
--8nhz33cQRrzZfKG7.1697834505/smtp1.example.jp | ||
Content-Description: Delivery report | ||
Content-Type: message/delivery-status | ||
Reporting-MTA: dns; smtp1.example.jp | ||
X-Postfix-Queue-ID: 8nhz33cQRrzZfKG7 | ||
X-Postfix-Sender: rfc822; kijitora@example.jp | ||
Arrival-Date: Thu, 29 Apr 2022 23:34:45 +0900 (JST) | ||
Final-Recipient: rfc822; pseudo-local-part-of-apple-icloud-mail@icloud.com | ||
Original-Recipient: rfc822;pseudo-local-part-of-apple-icloud-mail@icloud.com | ||
Action: failed | ||
Status: 5.2.2 | ||
Remote-MTA: dns; mx02.mail.icloud.com | ||
Diagnostic-Code: smtp; 552 5.2.2 <pseudo-local-part-of-apple-icloud-mail@icloud.com>: user is over | ||
quota | ||
--8nhz33cQRrzZfKG7.1697834505/smtp1.example.jp | ||
Content-Description: Undelivered Message | ||
Content-Type: message/rfc822 | ||
Return-Path: <kijitora@example.jp> | ||
Received: from MAILHUB-1 (unknown [192.0.2.25]) | ||
by smtp1.example.jp (Postfix) with ESMTP id 8nhz33cQRrzZfKG7 | ||
for <pseudo-local-part-of-apple-icloud-mail@icloud.com>; Thu, 29 Apr 2022 23:34:45 +0900 (JST) | ||
MIME-Version: 1.0 | ||
From: <kijitora@example.jp> | ||
To: <pseudo-local-part-of-apple-icloud-mail@icloud.com> | ||
Date: 29 Apr 2022 23:34:45 +0900 | ||
Message-Id: <8nhz33cQRrzZfKG7@smtp1.example.jp> | ||
Content-Type: text/plain; charset=us-ascii | ||
Subject: Nyaan? | ||
Nyaan? | ||
--8nhz33cQRrzZfKG7.1697834505/smtp1.example.jp-- | ||
|
Oops, something went wrong.