sisimai 4.25.15 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -3
  3. data/ANALYTICAL-PRECISION +2 -2
  4. data/Benchmarks.mk +3 -3
  5. data/CONTRIBUTING +1 -1
  6. data/ChangeLog.md +419 -388
  7. data/Developers.mk +5 -6
  8. data/Gemfile +1 -1
  9. data/Makefile +15 -15
  10. data/README-JA.md +140 -78
  11. data/README.md +290 -143
  12. data/Rakefile +9 -3
  13. data/Repository.mk +2 -3
  14. data/lib/sisimai/address.rb +118 -74
  15. data/lib/sisimai/arf.rb +84 -82
  16. data/lib/sisimai/datetime.rb +5 -52
  17. data/lib/sisimai/{data → fact}/json.rb +7 -9
  18. data/lib/sisimai/fact/yaml.rb +31 -0
  19. data/lib/sisimai/fact.rb +468 -0
  20. data/lib/sisimai/lhost/activehunter.rb +12 -14
  21. data/lib/sisimai/lhost/amavis.rb +11 -14
  22. data/lib/sisimai/lhost/amazonses.rb +37 -41
  23. data/lib/sisimai/lhost/amazonworkmail.rb +15 -18
  24. data/lib/sisimai/lhost/aol.rb +12 -14
  25. data/lib/sisimai/lhost/apachejames.rb +19 -21
  26. data/lib/sisimai/lhost/barracuda.rb +10 -12
  27. data/lib/sisimai/lhost/bigfoot.rb +21 -21
  28. data/lib/sisimai/lhost/biglobe.rb +15 -16
  29. data/lib/sisimai/lhost/courier.rb +20 -20
  30. data/lib/sisimai/lhost/domino.rb +23 -19
  31. data/lib/sisimai/lhost/einsundeins.rb +23 -18
  32. data/lib/sisimai/lhost/exchange2003.rb +30 -29
  33. data/lib/sisimai/lhost/exchange2007.rb +70 -58
  34. data/lib/sisimai/lhost/exim.rb +175 -161
  35. data/lib/sisimai/lhost/ezweb.rb +31 -56
  36. data/lib/sisimai/lhost/facebook.rb +21 -33
  37. data/lib/sisimai/lhost/fml.rb +43 -48
  38. data/lib/sisimai/lhost/gmail.rb +29 -29
  39. data/lib/sisimai/lhost/gmx.rb +18 -17
  40. data/lib/sisimai/lhost/googlegroups.rb +9 -10
  41. data/lib/sisimai/lhost/gsuite.rb +21 -27
  42. data/lib/sisimai/lhost/imailserver.rb +25 -39
  43. data/lib/sisimai/lhost/interscanmss.rb +28 -31
  44. data/lib/sisimai/lhost/kddi.rb +22 -28
  45. data/lib/sisimai/lhost/mailfoundry.rb +11 -12
  46. data/lib/sisimai/lhost/mailmarshalsmtp.rb +25 -29
  47. data/lib/sisimai/lhost/mailru.rb +33 -27
  48. data/lib/sisimai/lhost/mcafee.rb +21 -31
  49. data/lib/sisimai/lhost/messagelabs.rb +17 -20
  50. data/lib/sisimai/lhost/messagingserver.rb +40 -37
  51. data/lib/sisimai/lhost/mfilter.rb +15 -16
  52. data/lib/sisimai/lhost/mxlogic.rb +24 -23
  53. data/lib/sisimai/lhost/notes.rb +17 -17
  54. data/lib/sisimai/lhost/office365.rb +63 -27
  55. data/lib/sisimai/lhost/opensmtpd.rb +12 -13
  56. data/lib/sisimai/lhost/outlook.rb +12 -15
  57. data/lib/sisimai/lhost/postfix.rb +179 -129
  58. data/lib/sisimai/lhost/powermta.rb +12 -14
  59. data/lib/sisimai/lhost/qmail.rb +44 -47
  60. data/lib/sisimai/lhost/receivingses.rb +15 -20
  61. data/lib/sisimai/lhost/sendgrid.rb +34 -32
  62. data/lib/sisimai/lhost/sendmail.rb +66 -53
  63. data/lib/sisimai/lhost/surfcontrol.rb +19 -19
  64. data/lib/sisimai/lhost/v5sendmail.rb +45 -39
  65. data/lib/sisimai/lhost/verizon.rb +35 -39
  66. data/lib/sisimai/lhost/x1.rb +18 -17
  67. data/lib/sisimai/lhost/x2.rb +17 -14
  68. data/lib/sisimai/lhost/x3.rb +19 -19
  69. data/lib/sisimai/lhost/x4.rb +72 -57
  70. data/lib/sisimai/lhost/x5.rb +17 -19
  71. data/lib/sisimai/lhost/x6.rb +41 -17
  72. data/lib/sisimai/lhost/yahoo.rb +17 -16
  73. data/lib/sisimai/lhost/yandex.rb +16 -20
  74. data/lib/sisimai/lhost/zoho.rb +16 -15
  75. data/lib/sisimai/lhost.rb +8 -10
  76. data/lib/sisimai/mail/maildir.rb +1 -3
  77. data/lib/sisimai/mail/mbox.rb +3 -4
  78. data/lib/sisimai/mail/memory.rb +0 -1
  79. data/lib/sisimai/mail/stdin.rb +1 -3
  80. data/lib/sisimai/mail.rb +3 -7
  81. data/lib/sisimai/mda.rb +28 -42
  82. data/lib/sisimai/message.rb +435 -313
  83. data/lib/sisimai/order.rb +5 -5
  84. data/lib/sisimai/reason/authfailure.rb +64 -0
  85. data/lib/sisimai/reason/badreputation.rb +53 -0
  86. data/lib/sisimai/reason/blocked.rb +94 -160
  87. data/lib/sisimai/reason/contenterror.rb +8 -9
  88. data/lib/sisimai/reason/delivered.rb +4 -6
  89. data/lib/sisimai/reason/exceedlimit.rb +10 -12
  90. data/lib/sisimai/reason/expired.rb +6 -8
  91. data/lib/sisimai/reason/feedback.rb +2 -3
  92. data/lib/sisimai/reason/filtered.rb +17 -19
  93. data/lib/sisimai/reason/hasmoved.rb +9 -10
  94. data/lib/sisimai/reason/hostunknown.rb +15 -15
  95. data/lib/sisimai/reason/mailboxfull.rb +10 -12
  96. data/lib/sisimai/reason/mailererror.rb +18 -20
  97. data/lib/sisimai/reason/mesgtoobig.rb +9 -11
  98. data/lib/sisimai/reason/networkerror.rb +5 -8
  99. data/lib/sisimai/reason/norelaying.rb +8 -11
  100. data/lib/sisimai/reason/notaccept.rb +13 -14
  101. data/lib/sisimai/reason/notcompliantrfc.rb +43 -0
  102. data/lib/sisimai/reason/onhold.rb +6 -9
  103. data/lib/sisimai/reason/policyviolation.rb +14 -12
  104. data/lib/sisimai/reason/rejected.rb +26 -24
  105. data/lib/sisimai/reason/requireptr.rb +69 -0
  106. data/lib/sisimai/reason/securityerror.rb +33 -36
  107. data/lib/sisimai/reason/spamdetected.rb +114 -147
  108. data/lib/sisimai/reason/speeding.rb +49 -0
  109. data/lib/sisimai/reason/suspend.rb +11 -11
  110. data/lib/sisimai/reason/syntaxerror.rb +11 -10
  111. data/lib/sisimai/reason/systemerror.rb +7 -9
  112. data/lib/sisimai/reason/systemfull.rb +7 -8
  113. data/lib/sisimai/reason/toomanyconn.rb +9 -11
  114. data/lib/sisimai/reason/undefined.rb +2 -3
  115. data/lib/sisimai/reason/userunknown.rb +129 -146
  116. data/lib/sisimai/reason/vacation.rb +3 -4
  117. data/lib/sisimai/reason/virusdetected.rb +10 -11
  118. data/lib/sisimai/reason.rb +59 -64
  119. data/lib/sisimai/rfc1894.rb +55 -28
  120. data/lib/sisimai/rfc2045.rb +373 -0
  121. data/lib/sisimai/rfc3464.rb +250 -308
  122. data/lib/sisimai/rfc3834.rb +42 -47
  123. data/lib/sisimai/rfc5322.rb +75 -100
  124. data/lib/sisimai/rfc5965.rb +31 -0
  125. data/lib/sisimai/rhost/cox.rb +5 -6
  126. data/lib/sisimai/rhost/franceptt.rb +6 -8
  127. data/lib/sisimai/rhost/godaddy.rb +12 -12
  128. data/lib/sisimai/rhost/{googleapps.rb → google.rb} +80 -72
  129. data/lib/sisimai/rhost/iua.rb +9 -10
  130. data/lib/sisimai/rhost/kddi.rb +6 -8
  131. data/lib/sisimai/rhost/{exchangeonline.rb → microsoft.rb} +115 -114
  132. data/lib/sisimai/rhost/mimecast.rb +42 -40
  133. data/lib/sisimai/rhost/nttdocomo.rb +12 -12
  134. data/lib/sisimai/rhost/spectrum.rb +10 -12
  135. data/lib/sisimai/rhost/{tencentqq.rb → tencent.rb} +7 -8
  136. data/lib/sisimai/rhost.rb +23 -31
  137. data/lib/sisimai/smtp/command.rb +59 -0
  138. data/lib/sisimai/smtp/error.rb +4 -7
  139. data/lib/sisimai/smtp/reply.rb +161 -74
  140. data/lib/sisimai/smtp/status.rb +504 -393
  141. data/lib/sisimai/smtp/transcript.rb +124 -0
  142. data/lib/sisimai/smtp.rb +0 -1
  143. data/lib/sisimai/string.rb +74 -5
  144. data/lib/sisimai/time.rb +1 -2
  145. data/lib/sisimai/version.rb +1 -1
  146. data/lib/sisimai.rb +35 -21
  147. data/set-of-emails/maildir/bsd/lhost-domino-02.eml +6 -3
  148. data/set-of-emails/maildir/bsd/lhost-googlegroups-15.eml +174 -0
  149. data/set-of-emails/maildir/bsd/lhost-gsuite-15.eml +229 -0
  150. data/set-of-emails/maildir/bsd/lhost-postfix-75.eml +51 -0
  151. data/set-of-emails/maildir/bsd/lhost-postfix-76.eml +101 -0
  152. data/set-of-emails/maildir/bsd/lhost-postfix-77.eml +74 -0
  153. data/set-of-emails/maildir/bsd/lhost-postfix-78.eml +91 -0
  154. data/set-of-emails/maildir/bsd/lhost-receivingses-08.eml +88 -0
  155. data/set-of-emails/maildir/bsd/rfc3464-43.eml +88 -0
  156. data/set-of-emails/maildir/bsd/rhost-google-03.eml +101 -0
  157. data/set-of-emails/maildir/bsd/rhost-google-04.eml +102 -0
  158. data/set-of-emails/maildir/bsd/rhost-google-05.eml +82 -0
  159. data/set-of-emails/maildir/bsd/rhost-google-06.eml +102 -0
  160. data/set-of-emails/maildir/bsd/rhost-google-07.eml +69 -0
  161. data/set-of-emails/maildir/bsd/rhost-google-08.eml +99 -0
  162. data/sisimai-java.gemspec +1 -1
  163. data/sisimai.gemspec +1 -1
  164. metadata +41 -20
  165. data/.rspec +0 -2
  166. data/lib/sisimai/data/yaml.rb +0 -33
  167. data/lib/sisimai/data.rb +0 -411
  168. data/lib/sisimai/mime.rb +0 -456
  169. /data/set-of-emails/maildir/bsd/{rfc3464-41.eml → rfc3834-05.eml} +0 -0
  170. /data/set-of-emails/maildir/bsd/{rhost-googleapps-01.eml → rhost-google-01.eml} +0 -0
  171. /data/set-of-emails/maildir/bsd/{rhost-googleapps-02.eml → rhost-google-02.eml} +0 -0
  172. /data/set-of-emails/maildir/bsd/{rhost-exchangeonline-01.eml → rhost-microsoft-01.eml} +0 -0
  173. /data/set-of-emails/maildir/bsd/{rhost-exchangeonline-02.eml → rhost-microsoft-02.eml} +0 -0
  174. /data/set-of-emails/maildir/bsd/{rhost-exchangeonline-03.eml → rhost-microsoft-03.eml} +0 -0
  175. /data/set-of-emails/maildir/bsd/{rhost-tencentqq-01.eml → rhost-tencent-01.eml} +0 -0
  176. /data/set-of-emails/maildir/bsd/{rhost-tencentqq-02.eml → rhost-tencent-02.eml} +0 -0
  177. /data/set-of-emails/maildir/bsd/{rhost-tencentqq-03.eml → rhost-tencent-03.eml} +0 -0
@@ -1,11 +1,40 @@
1
1
  module Sisimai
2
2
  module Rhost
3
- # Sisimai::Rhost detects the bounce reason from the content of Sisimai::Data
4
- # object as an argument of get() method when the value of "rhost" of the object
5
- # is "aspmx.l.google.com". This class is called only Sisimai::Data class.
6
- module GoogleApps
3
+ # Sisimai::Rhost detects the bounce reason from the content of Sisimai::Fact object as an argument
4
+ # of get() method when the value of "rhost" of the object is "aspmx.l.google.com". This class is
5
+ # called only Sisimai::Fact class.
6
+ module Google
7
7
  class << self
8
8
  MessagesOf = {
9
+ 'authfailure' => [
10
+ # - 550 5.7.26 Unauthenticated email from domain-name is not accepted due to domain's
11
+ # DMARC policy. Please contact the administrator of domain-name domain. If this was
12
+ # a legitimate mail please visit [Control unauthenticated mail from your domain] to
13
+ # learn about the DMARC initiative. If the messages are valid and aren't spam, con-
14
+ # tact the administrator of the receiving mail server to determine why your outgoing
15
+ # messages don't pass authentication checks.
16
+ ['550', '5.7.26', "is not accepted due to domain's dmarc policy"],
17
+
18
+ # - 550 5.7.26 This message does not have authentication information or fails to pass
19
+ # authentication checks (SPF or DKIM). To best protect our users from spam, the mes-
20
+ # sage has been blocked. Please visit https://support.google.com/mail/answer/81126
21
+ # for more information.
22
+ ['550', '5.7.1', 'fails to pass authentication checks'],
23
+ ['550', '5.7.26', 'fails to pass authentication checks'],
24
+
25
+ # - 550 5.7.26 This message fails to pass SPF checks for an SPF record with a hard fail
26
+ # policy (-all). To best protect our users from spam and phishing, the message has
27
+ # been blocked. Please visit https://support.google.com/mail/answer/81126 for more
28
+ # information.
29
+ ['550', '5.7.26', 'this message fails to pass spf checks for an spf record with a hard fail'],
30
+ ],
31
+ 'badreputation' => [
32
+ # - 550 5.7.1 Our system has detected that this message is likely suspicious due to the
33
+ # very low reputation of the sending IP address. To best protect our users from spam,
34
+ # the message has been blocked.
35
+ # Please visit https://support.google.com/mail/answer/188131 for more information.
36
+ ['550', '5.7.1', 'this message is likely suspicious due to the very low reputation of the sending ip address'],
37
+ ],
9
38
  'blocked' => [
10
39
  ['421', '4.7.0', 'ip not in whitelist for rcpt domain, closing connection.'],
11
40
 
@@ -32,37 +61,6 @@ module Sisimai
32
61
  # to our servers. Please use the SMTP relay at your service provider instead. For
33
62
  # more information, visit https://support.google.com/mail/answer/10336
34
63
  ['550', '5.7.1', "the ip you're using to send mail is not authorized to send email directly to our servers"],
35
-
36
- # - 550 5.7.25 The IP address sending this message does not have a PTR record setup, or
37
- # the corresponding forward DNS entry does not point to the sending IP. As a policy,
38
- # Gmail does not accept messages from IPs with missing PTR records.
39
- ['550', '5.7.25', 'the ip address sending this message does not have a ptr record setup'],
40
-
41
- # - 550 5.7.26 Unauthenticated email from domain-name is not accepted due to domain's
42
- # DMARC policy. Please contact the administrator of domain-name domain. If this was
43
- # a legitimate mail please visit [Control unauthenticated mail from your domain] to
44
- # learn about the DMARC initiative. If the messages are valid and aren't spam, con-
45
- # tact the administrator of the receiving mail server to determine why your outgoing
46
- # messages don't pass authentication checks.
47
- ['550', '5.7.26', "is not accepted due to domain's dmarc policy"],
48
-
49
- # - 550 5.7.26 This message does not have authentication information or fails to pass
50
- # authentication checks (SPF or DKIM). To best protect our users from spam, the mes-
51
- # sage has been blocked. Please visit https://support.google.com/mail/answer/81126
52
- # for more information.
53
- ['550', '5.7.1', 'fails to pass authentication checks'],
54
- ['550', '5.7.26', 'fails to pass authentication checks'],
55
-
56
- # - 550 5.7.26 This message fails to pass SPF checks for an SPF record with a hard fail
57
- # policy (-all). To best protect our users from spam and phishing, the message has
58
- # been blocked. Please visit https://support.google.com/mail/answer/81126 for more
59
- # information.
60
- ['550', '5.7.26', 'this message fails to pass spf checks for an spf record with a hard fail'],
61
- # - 550 5.7.1 Our system has detected that this message is likely suspicious due to the
62
- # very low reputation of the sending IP address. To best protect our users from spam,
63
- # the message has been blocked.
64
- # Please visit https://support.google.com/mail/answer/188131 for more information.
65
- ['550', '5.7.1', 'this message is likely suspicious due to the very low reputation of the sending ip address'],
66
64
  ],
67
65
  'contenterror' => [
68
66
  ['554', '5.6.0', 'mail message is malformed. Not accepted'],
@@ -88,6 +86,9 @@ module Sisimai
88
86
  'norelaying' => [
89
87
  ['550', '5.7.0', 'mail relay denied'],
90
88
  ],
89
+ 'notcompliantrfc' => [
90
+ ['550', '5.7.1', 'this message is not rfc 5322 compliant'],
91
+ ],
91
92
  'policyviolation' => [
92
93
  ['550', '5.7.1', 'messages with multiple addresses in from: header are not accepted'],
93
94
 
@@ -114,6 +115,12 @@ module Sisimai
114
115
 
115
116
  ['550', '5.7.1', 'unauthenticated email is not accepted from this domain'],
116
117
  ],
118
+ 'requireptr' => [
119
+ # - 550 5.7.25 The IP address sending this message does not have a PTR record setup, or
120
+ # the corresponding forward DNS entry does not point to the sending IP. As a policy,
121
+ # Gmail does not accept messages from IPs with missing PTR records.
122
+ ['550', '5.7.25', 'the ip address sending this message does not have a ptr record setup'],
123
+ ],
117
124
  'securityerror' => [
118
125
  ['421', '4.7.0', 'tls required for rcpt domain, closing connection'],
119
126
  ['501', '5.5.2', 'cannot decode response'], # 2FA related error, maybe.
@@ -142,8 +149,39 @@ module Sisimai
142
149
  # For more information, visit https://support.google.com/mail/answer/188131
143
150
  ['550', '5.7.1', 'our system has detected that this message is likely unsolicited mail'],
144
151
  ],
152
+ 'speeding' => [
153
+ # - 450 4.2.1 The user you are trying to contact is receiving mail too quickly. Please
154
+ # resend your message at a later time. If the user is able to receive mail at that
155
+ # time, your message will be delivered.
156
+ # For more information, visit https://support.google.com/mail/answer/22839
157
+ ['450', '4.2.1', 'is receiving mail too quickly'],
158
+
159
+ # - 450 4.2.1 The user you are trying to contact is receiving mail at a rate that pre-
160
+ # vents additional messages from being delivered. Please resend your message at a
161
+ # later time. If the user is able to receive mail at that time, your message will be
162
+ # delivered. For more information, visit https://support.google.com/mail/answer/6592
163
+ ['450', '4.2.1', 'is receiving mail at a rate that prevents additional messages from being delivered'],
164
+ ['550', '5.2.1', 'is receiving mail at a rate that prevents additional messages from being delivered'],
165
+
166
+ # - 450 4.2.1 Peak SMTP relay limit exceeded for customer. This is a temporary error.
167
+ # For more information on SMTP relay limits, please contact your administrator or
168
+ # visit https://support.google.com/a/answer/6140680
169
+ ['450', '4.2.1', 'peak smtp relay limit exceeded for customer'],
170
+
171
+ # - 550 5.4.5 Daily SMTP relay limit exceeded for user. For more information on SMTP
172
+ # relay sending limits please contact your administrator or visit SMTP relay service
173
+ # error messages.
174
+ ['550', '5.4.5', 'daily smtp relay limit exceeded for user'],
175
+ ['550', '5.4.5', 'daily sending quota exceeded'],
176
+
177
+ # - 550 5.7.1 Daily SMTP relay limit exceeded for customer. For more information on
178
+ # SMTP relay sending limits please contact your administrator or visit
179
+ # https://support.google.com/a/answer/6140680
180
+ ['550', '5.7.1', 'daily smtp relay limit exceeded for customer'],
181
+ ],
145
182
  'suspend' => [
146
183
  ['550', '5.2.1', 'the email account that you tried to reach is disabled'],
184
+ ['550', '5.2.1', 'the email account that you tried to reach is inactive'],
147
185
  ],
148
186
  'syntaxerror' => [
149
187
  ['451', '4.5.0', 'smtp protocol violation, visit rfc 2821'],
@@ -180,35 +218,6 @@ module Sisimai
180
218
  # - 452 4.5.3 Your message has too many recipients. For more information regarding
181
219
  # Google's sending limits, visit https://support.google.com/mail/answer/6592
182
220
  ['452', '4.5.3', 'your message has too many recipients'],
183
-
184
- # - 450 4.2.1 The user you are trying to contact is receiving mail too quickly. Please
185
- # resend your message at a later time. If the user is able to receive mail at that
186
- # time, your message will be delivered.
187
- # For more information, visit https://support.google.com/mail/answer/22839
188
- ['450', '4.2.1', 'is receiving mail too quickly'],
189
-
190
- # - 450 4.2.1 The user you are trying to contact is receiving mail at a rate that pre-
191
- # vents additional messages from being delivered. Please resend your message at a
192
- # later time. If the user is able to receive mail at that time, your message will be
193
- # delivered. For more information, visit https://support.google.com/mail/answer/6592
194
- ['450', '4.2.1', 'is receiving mail at a rate that prevents additional messages from being delivered'],
195
- ['550', '5.2.1', 'is receiving mail at a rate that prevents additional messages from being delivered'],
196
-
197
- # - 450 4.2.1 Peak SMTP relay limit exceeded for customer. This is a temporary error.
198
- # For more information on SMTP relay limits, please contact your administrator or
199
- # visit https://support.google.com/a/answer/6140680
200
- ['450', '4.2.1', 'peak smtp relay limit exceeded for customer'],
201
-
202
- # - 550 5.4.5 Daily SMTP relay limit exceeded for user. For more information on SMTP
203
- # relay sending limits please contact your administrator or visit SMTP relay service
204
- # error messages.
205
- ['550', '5.4.5', 'daily smtp relay limit exceeded for user'],
206
- ['550', '5.4.5', 'daily sending quota exceeded'],
207
-
208
- # - 550 5.7.1 Daily SMTP relay limit exceeded for customer. For more information on
209
- # SMTP relay sending limits please contact your administrator or visit
210
- # https://support.google.com/a/answer/6140680
211
- ['550', '5.7.1', 'daily smtp relay limit exceeded for customer'],
212
221
  ],
213
222
  'userunknown' => [
214
223
  # - 550 5.1.1 The email account that you tried to reach does not exist. Please try dou-
@@ -228,15 +237,14 @@ module Sisimai
228
237
  # @return [String] The bounce reason for Google Workspace
229
238
  # @see https://support.google.com/a/answer/3726730?hl=en
230
239
  def get(argvs)
231
- return argvs.reason unless argvs.reason.empty?
232
- return '' if argvs.diagnosticcode.empty?
233
- return '' if argvs.replycode.empty?
234
- return '' if argvs.deliverystatus.empty?
235
- return '' unless argvs.deliverystatus =~ /\A[245][.]\d[.]\d+\z/
240
+ return argvs['reason'] unless argvs['reason'].empty?
241
+ return '' if argvs['diagnosticcode'].empty?
242
+ return '' unless Sisimai::SMTP::Reply.test(argvs['replycode'])
243
+ return '' unless Sisimai::SMTP::Status.test(argvs['deliverystatus'])
236
244
 
237
- statuscode = argvs.deliverystatus[2,6]
238
- esmtpreply = argvs.replycode[1,2]
239
- esmtperror = argvs.diagnosticcode.downcase
245
+ statuscode = argvs['deliverystatus'][2,6]
246
+ esmtpreply = argvs['replycode'][1,2]
247
+ esmtperror = argvs['diagnosticcode'].downcase
240
248
  reasontext = ''
241
249
 
242
250
  MessagesOf.each_key do |e|
@@ -1,11 +1,10 @@
1
1
  module Sisimai
2
2
  module Rhost
3
- # Sisimai::Rhost detects the bounce reason from the content of Sisimai::Data
4
- # object as an argument of get() method when the value of "rhost" of the object
5
- # is "*.email.ua". This class is called only Sisimai::Data class.
3
+ # Sisimai::Rhost detects the bounce reason from the content of Sisimai::Fact object as an argument
4
+ # of get() method when the value of "rhost" of the object is "*.email.ua". This class is called
5
+ # only Sisimai::Fact class.
6
6
  module IUA
7
7
  class << self
8
- # Imported from p5-Sisimail/lib/Sisimai/Rhost/IUA.pm
9
8
  ErrorCodes = {
10
9
  # http://mail.i.ua/err/$(CODE)
11
10
  '1' => 'norelaying', # The use of SMTP as mail gate is forbidden.
@@ -21,15 +20,15 @@ module Sisimai
21
20
  }.freeze
22
21
 
23
22
  # Detect bounce reason from https://www.i.ua/
24
- # @param [Sisimai::Data] argvs Parsed email object
23
+ # @param [Sisimai::Fact] argvs Parsed email object
25
24
  # @return [String] The bounce reason at https://www.i.ua/
26
25
  def get(argvs)
27
- return argvs.reason unless argvs.reason.empty?
26
+ return argvs['reason'] unless argvs['reason'].empty?
27
+ issuedcode = argvs['diagnosticcode'].downcase
28
+ codenumber = issuedcode.index('.i.ua/err/') > 0 ? issuedcode[issuedcode.index('/err/') + 5, 2] : 0
29
+ codenumber = codenumber[0, 1] if codenumber.index('/') == 1
28
30
 
29
- if cv = argvs.diagnosticcode.downcase.match(%r|[.]i[.]ua/err/(\d+)|)
30
- return ErrorCodes[cv[1]] || ''
31
- end
32
- return ''
31
+ return ErrorCodes[codenumber] || ''
33
32
  end
34
33
 
35
34
  end
@@ -1,27 +1,25 @@
1
1
  module Sisimai
2
2
  module Rhost
3
- # Sisimai::Rhost detects the bounce reason from the content of Sisimai::Data
4
- # object as an argument of get() method when the value of "rhost" of the object
5
- # is "lsean.ezweb.ne.jp" or "msmx.au.com".
6
- # This class is called only Sisimai::Data class.
3
+ # Sisimai::Rhost detects the bounce reason from the content of Sisimai::Fact object as an argument
4
+ # of get() method when the value of "rhost" of the object is "lsean.ezweb.ne.jp" or "msmx.au.com".
5
+ # This class is called only Sisimai::Fact class.
7
6
  module KDDI
8
7
  class << self
9
- # Imported from p5-Sisimail/lib/Sisimai/Rhost/KDDI.pm
10
8
  MessagesOf = {
11
9
  'filtered' => '550 : User unknown', # The response was: 550 : User unknown
12
10
  'userunknown' => '>: User unknown', # The response was: 550 <...>: User unknown
13
11
  }.freeze
14
12
 
15
13
  # Detect bounce reason from au (KDDI)
16
- # @param [Sisimai::Data] argvs Parsed email object
14
+ # @param [Sisimai::Fact] argvs Parsed email object
17
15
  # @return [String] The bounce reason for au.com or ezweb.ne.jp
18
16
  def get(argvs)
19
- statusmesg = argvs.diagnosticcode
17
+ statusmesg = argvs['diagnosticcode']
20
18
  reasontext = ''
21
19
 
22
20
  MessagesOf.each_key do |e|
23
21
  # Try to match the error message with message patterns defined in $MessagesOf
24
- next unless statusmesg.end_with?(MessagesOf[e])
22
+ next unless statusmesg.include?(MessagesOf[e])
25
23
  reasontext = e
26
24
  break
27
25
  end
@@ -1,15 +1,70 @@
1
1
  module Sisimai
2
2
  module Rhost
3
- # Sisimai::Rhost detects the bounce reason from the content of Sisimai::Data
4
- # object as an argument of get() method when the value of "rhost" of the object
5
- # is "*.protection.outlook.com". This class is called only Sisimai::Data class.
6
- #
3
+ # Sisimai::Rhost detects the bounce reason from the content of Sisimai::Fact object as an argument
4
+ # of get() method when the value of "rhost" of the object is *.protection.outlook.com. This class
5
+ # is called only Sisimai::Fact class.
6
+ #
7
7
  # https://technet.microsoft.com/en-us/library/bb232118
8
8
  # https://learn.microsoft.com/en-us/Exchange/mail-flow-best-practices/non-delivery-reports-in-exchange-online/non-delivery-reports-in-exchange-online
9
9
  # https://learn.microsoft.com/en-us/Exchange/mail-flow/non-delivery-reports-and-bounce-messages/non-delivery-reports-and-bounce-messages
10
- module ExchangeOnline
10
+ module Microsoft
11
11
  class << self
12
12
  MessagesOf = {
13
+ 'authfailure' => [
14
+ # - Access denied, a message sent over IPv6 [2a01:111:f200:2004::240] must pass either
15
+ # SPF or DKIM validation, this message is not signed
16
+ # - The sending message sent over IPv6 must pass either SPF or DKIM.
17
+ ['4.7.26', 0, 0, 'must pass either spf or dkim validation, this message is not signed'],
18
+
19
+ # - Records are DNSSEC authentic, but one or multiple of these scenarios occurred:
20
+ # - The destination mail server's certificate doesn't match with what is expected per
21
+ # the authentic TLSA record.
22
+ # - Authentic TLSA record is misconfigured.
23
+ # - Destination domain is being attacked.
24
+ # - Any other DANE failure.
25
+ # - This message usually indicates an issue on the destination email server. Check the
26
+ # validity of recipient address and determine if the destination server is configured
27
+ # correctly to receive messages.
28
+ # - For more information about DANE, see: https://datatracker.ietf.org/doc/html/rfc7671
29
+ ['4.7.323', 0, 0, 'tlsa-invalid: The domain failed dane validation'],
30
+ ['5.7.323', 0, 0, 'tlsa-invalid: The domain failed dane validation'],
31
+
32
+ # - The destination domain indicated it was DNSSEC-authentic, but Exchange Online was
33
+ # not able to verify it as DNSSEC-authentic.
34
+ ['4.7.324', 0, 0, 'dnssec-invalid: destination domain returned invalid dnssec records'],
35
+ ['5.7.324', 0, 0, 'dnssec-invalid: destination domain returned invalid dnssec records'],
36
+
37
+ # - This happens when the presented certificate identities (CN and SAN) of a destina-
38
+ # tion SMTP target host don't match any of the domains or MX host.
39
+ # - This message usually indicates an issue on the destination email server. Check the
40
+ # validity of recipient address and determine if the destination server is configured
41
+ # correctly to receive messages. For more information, see How SMTP DNS-based Authen-
42
+ # tication of Named Entities (DANE) works to secure email communications.
43
+ ['4.7.325', 0, 0, 'certificate-host-mismatch: remote certificate must have a common name or subject alternative name matching the hostname (dane)'],
44
+ ['5.7.325', 0, 0, 'certificate-host-mismatch: remote certificate must have a common name or subject alternative name matching the hostname (dane)'],
45
+
46
+ # - The destination email system uses SPF to validate inbound mail, and there's a prob-
47
+ # lem with your SPF configuration.
48
+ ['5.7.23', 0, 0, 'the message was rejected because of sender policy framework violation'],
49
+
50
+ # - DNSSEC checks have passed, yet upon establishing the connection the destination
51
+ # mail server provides a certificate that is expired.
52
+ # - A valid X.509 certificate that isn't expired must be presented. X.509 certificates
53
+ # must be renewed after their expiration, commonly annually.
54
+ ['5.7.322', 0, 0, "certificate-expired: destination mail server's certificate is expired"],
55
+
56
+ # - Access denied, sending domain [$SenderDomain] does not pass DMARC verification
57
+ # - The sender's domain in the 5322.From address doesn't pass DMARC.
58
+ ['5.7.509', 0, 0, 'does not pass dmarc verification'],
59
+ ],
60
+ 'badreputation' => [
61
+ # Undocumented error messages ---------------------------------------------------------
62
+ # - status=deferred (host outlook-com.olc.protection.outlook.com[192.0.2.255] said:
63
+ # 451 4.7.650 The mail server [192.0.2.5] has been temporarily rate limited due to IP
64
+ # reputation. For e-mail delivery information, see https://postmaster.live.com (S775)
65
+ # [***.prod.protection.outlook.com] (in reply to MAIL FROM command))
66
+ ['4.7.650', 0, 0, 'has been temporarily rate limited due to ip reputation'],
67
+ ],
13
68
  'blocked' => [
14
69
  # Exchange Server 2019 ----------------------------------------------------------------
15
70
  # - Transient network issues or server problems that might eventually correct them-
@@ -87,58 +142,6 @@ module Sisimai
87
142
  # - 550 5.7.1 Unfortunately, messages from [10.0.2.5] weren't sent. Please contact your
88
143
  # Internet service provider since part of their network is on our block list (S3150).
89
144
  ['5.7.1', 0, 0, 'part of their network is on our block list (s3150)'],
90
-
91
- # - Access denied, a message sent over IPv6 [2a01:111:f200:2004::240] must pass either
92
- # SPF or DKIM validation, this message is not signed
93
- # - The sending message sent over IPv6 must pass either SPF or DKIM.
94
- ['4.7.26', 0, 0, 'must pass either spf or dkim validation, this message is not signed'],
95
-
96
- # - Records are DNSSEC authentic, but one or multiple of these scenarios occurred:
97
- # - The destination mail server's certificate doesn't match with what is expected per
98
- # the authentic TLSA record.
99
- # - Authentic TLSA record is misconfigured.
100
- # - Destination domain is being attacked.
101
- # - Any other DANE failure.
102
- # - This message usually indicates an issue on the destination email server. Check the
103
- # validity of recipient address and determine if the destination server is configured
104
- # correctly to receive messages.
105
- # - For more information about DANE, see: https://datatracker.ietf.org/doc/html/rfc7671
106
- ['4.7.323', 0, 0, 'tlsa-invalid: The domain failed dane validation'],
107
- ['5.7.323', 0, 0, 'tlsa-invalid: The domain failed dane validation'],
108
-
109
- # - The destination domain indicated it was DNSSEC-authentic, but Exchange Online was
110
- # not able to verify it as DNSSEC-authentic.
111
- ['4.7.324', 0, 0, 'dnssec-invalid: destination domain returned invalid dnssec records'],
112
- ['5.7.324', 0, 0, 'dnssec-invalid: destination domain returned invalid dnssec records'],
113
-
114
- # - This happens when the presented certificate identities (CN and SAN) of a destina-
115
- # tion SMTP target host don't match any of the domains or MX host.
116
- # - This message usually indicates an issue on the destination email server. Check the
117
- # validity of recipient address and determine if the destination server is configured
118
- # correctly to receive messages. For more information, see How SMTP DNS-based Authen-
119
- # tication of Named Entities (DANE) works to secure email communications.
120
- ['4.7.325', 0, 0, 'certificate-host-mismatch: remote certificate must have a common name or subject alternative name matching the hostname (dane)'],
121
- ['5.7.325', 0, 0, 'certificate-host-mismatch: remote certificate must have a common name or subject alternative name matching the hostname (dane)'],
122
-
123
- # - The destination email system uses SPF to validate inbound mail, and there's a prob-
124
- # lem with your SPF configuration.
125
- ['5.7.23', 0, 0, 'the message was rejected because of sender policy framework violation'],
126
-
127
- # - DNSSEC checks have passed, yet upon establishing the connection the destination
128
- # mail server provides a certificate that is expired.
129
- # - A valid X.509 certificate that isn't expired must be presented. X.509 certificates
130
- # must be renewed after their expiration, commonly annually.
131
- ['5.7.322', 0, 0, "certificate-expired: destination mail server's certificate is expired"],
132
-
133
- # - Access denied, sending domain [$SenderDomain] does not pass DMARC verification
134
- # - The sender's domain in the 5322.From address doesn't pass DMARC.
135
- ['5.7.509', 0, 0, 'does not pass dmarc verification'],
136
- # Undocumented error messages ---------------------------------------------------------
137
- # - status=deferred (host outlook-com.olc.protection.outlook.com[192.0.2.255] said:
138
- # 451 4.7.650 The mail server [192.0.2.5] has been temporarily rate limited due to IP
139
- # reputation. For e-mail delivery information, see https://postmaster.live.com (S775)
140
- # [***.prod.protection.outlook.com] (in reply to MAIL FROM command))
141
- ['4.7.650', 0, 0, 'has been temporarily rate limited due to ip reputation'],
142
145
  ],
143
146
  'contenterror' => [
144
147
  # Exchange Server 2019 ----------------------------------------------------------------
@@ -477,6 +480,53 @@ module Sisimai
477
480
  ['5.2.1', 0, 0, 'content filter agent quarantined this message'],
478
481
  ],
479
482
  'speeding' => [
483
+ # Exchange Online ---------------------------------------------------------------------
484
+ # - The recipient mailbox's ability to accept messages is being throttled because it's
485
+ # receiving too many messages too quickly. This is done so a single recipient's mail
486
+ # processing doesn't unfairly impact other recipients sharing the same mailbox data-
487
+ # base.
488
+ ['4.3.2', 0, 0, 'storedrv.deliver; recipient thread limit exceeded'],
489
+
490
+ # - The sender has exceeded the recipient rate limit as described in Sending limits.
491
+ # - This could indicate the account has been compromised and is being used to send
492
+ # spam.
493
+ ['5.1.90', 0, 0, "your message can't be sent because you've reached your daily limit for message recipients"],
494
+
495
+ # - The sender has exceeded the recipient rate limit or the message rate limit as de-
496
+ # scribed in Sending limits.
497
+ # - This could indicate the account has been compromised and is being used to send
498
+ # spam.
499
+ ['5.2.2', 0, 0, 'submission quota exceeded'],
500
+
501
+ # - The sender has exceeded the maximum number of messages they're allowed to send per
502
+ # hour to a specific recipient in Exchange Online.
503
+ # - The automated mailer or sender should try again later, and reduce the number of
504
+ # messages they send per hour to a specific recipient. This limit helps protect
505
+ # Microsoft 365 or Office 365 users from rapidly filling their inboxes with a large
506
+ # number of messages from errant automated notification systems or other single-send-
507
+ # er mail storms.
508
+ ['5.2.121', 0, 0, "recipient's per hour message receive limit from specific sender exceeded"],
509
+
510
+ # - The Microsoft 365 or Office 365 recipient has exceeded the number of messages they
511
+ # can receive per hour from all senders.
512
+ # - The automated mailer or sender should try again later, and reduce the number of
513
+ # messages they send per hour to a specific recipient. This limit helps protect
514
+ # Microsoft 365 and Office 365 users from rapidly filling their inboxes with a large
515
+ # number of messages from errant automated notification systems or other mail storms.
516
+ ['5.2.122', 0, 0, "recipient's per hour message receive limit exceeded"],
517
+
518
+ # - Access denied, [$SenderIPAddress] has exceeded permitted limits within $range range
519
+ # - The sender's IPv6 range has attempted to send too many messages in too short a time
520
+ # period.
521
+ ['5.7.508', 0, 0, 'has exceeded permitted limits within'],
522
+
523
+ # - The majority of traffic from this tenant has been detected as suspicious and has
524
+ # resulted in a ban on sending ability for the tenant.
525
+ # - Ensure that any compromises or open relays have been resolved, and then contact
526
+ # support through your regular channel. For more information, see Fix email delivery
527
+ # issues for error codes 5.7.700 through 5.7.750 in Exchange Online.
528
+ ['5.7.', 700, 749, 'access denied, tenant has exceeded threshold'],
529
+ ['5.7.', 700, 749, 'access denied, traffic not accepted from this ip'],
480
530
  ],
481
531
  'suspend' => [
482
532
  # Exchange Online ---------------------------------------------------------------------
@@ -588,54 +638,6 @@ module Sisimai
588
638
 
589
639
  # Previous versions of Exchange Server ------------------------------------------------
590
640
  ['5.2.122', 0, 0, 'the recipient has exceeded their limit for'],
591
-
592
- # Exchange Online ---------------------------------------------------------------------
593
- # - The recipient mailbox's ability to accept messages is being throttled because it's
594
- # receiving too many messages too quickly. This is done so a single recipient's mail
595
- # processing doesn't unfairly impact other recipients sharing the same mailbox data-
596
- # base.
597
- ['4.3.2', 0, 0, 'storedrv.deliver; recipient thread limit exceeded'],
598
-
599
- # - The sender has exceeded the recipient rate limit as described in Sending limits.
600
- # - This could indicate the account has been compromised and is being used to send
601
- # spam.
602
- ['5.1.90', 0, 0, "your message can't be sent because you've reached your daily limit for message recipients"],
603
-
604
- # - The sender has exceeded the recipient rate limit or the message rate limit as de-
605
- # scribed in Sending limits.
606
- # - This could indicate the account has been compromised and is being used to send
607
- # spam.
608
- ['5.2.2', 0, 0, 'submission quota exceeded'],
609
-
610
- # - The sender has exceeded the maximum number of messages they're allowed to send per
611
- # hour to a specific recipient in Exchange Online.
612
- # - The automated mailer or sender should try again later, and reduce the number of
613
- # messages they send per hour to a specific recipient. This limit helps protect
614
- # Microsoft 365 or Office 365 users from rapidly filling their inboxes with a large
615
- # number of messages from errant automated notification systems or other single-send-
616
- # er mail storms.
617
- ['5.2.121', 0, 0, "recipient's per hour message receive limit from specific sender exceeded"],
618
-
619
- # - The Microsoft 365 or Office 365 recipient has exceeded the number of messages they
620
- # can receive per hour from all senders.
621
- # - The automated mailer or sender should try again later, and reduce the number of
622
- # messages they send per hour to a specific recipient. This limit helps protect
623
- # Microsoft 365 and Office 365 users from rapidly filling their inboxes with a large
624
- # number of messages from errant automated notification systems or other mail storms.
625
- ['5.2.122', 0, 0, "recipient's per hour message receive limit exceeded"],
626
-
627
- # - Access denied, [$SenderIPAddress] has exceeded permitted limits within $range range
628
- # - The sender's IPv6 range has attempted to send too many messages in too short a time
629
- # period.
630
- ['5.7.508', 0, 0, 'has exceeded permitted limits within'],
631
-
632
- # - The majority of traffic from this tenant has been detected as suspicious and has
633
- # resulted in a ban on sending ability for the tenant.
634
- # - Ensure that any compromises or open relays have been resolved, and then contact
635
- # support through your regular channel. For more information, see Fix email delivery
636
- # issues for error codes 5.7.700 through 5.7.750 in Exchange Online.
637
- ['5.7.', 700, 749, 'access denied, tenant has exceeded threshold'],
638
- ['5.7.', 700, 749, 'access denied, traffic not accepted from this ip'],
639
641
  ],
640
642
  'userunknown' => [
641
643
  # Exchange Server 2019 ----------------------------------------------------------------
@@ -700,17 +702,17 @@ module Sisimai
700
702
  ],
701
703
  }.freeze
702
704
 
703
- # Detect bounce reason from Exchange Online
704
- # @param [Sisimai::Data] argvs Parsed email object
705
+ # Detect bounce reason from Exchange Server 2019 or older and Exchange Online
706
+ # @param [Sisimai::Fact] argvs Parsed email object
705
707
  # @return [String] The bounce reason for Exchange Online
706
708
  def get(argvs)
707
- return argvs.reason unless argvs.reason.empty?
708
- return '' if argvs.diagnosticcode.empty?
709
- return '' if argvs.deliverystatus.empty?
710
- return '' unless argvs.deliverystatus =~ /\A[245][.]\d[.]\d+\z/
709
+ return argvs['reason'] unless argvs['reason'].empty?
710
+ return '' if argvs['diagnosticcode'].empty?
711
+ return '' if argvs['deliverystatus'].empty?
712
+ return '' unless Sisimai::SMTP::Status.test(argvs['deliverystatus'])
711
713
 
712
- statuscode = argvs.deliverystatus
713
- esmtperror = argvs.diagnosticcode.downcase
714
+ statuscode = argvs['deliverystatus']
715
+ esmtperror = argvs['diagnosticcode'].downcase
714
716
  thirddigit = statuscode.split('.')[-1].to_i
715
717
  reasontext = ''
716
718
 
@@ -735,7 +737,6 @@ module Sisimai
735
737
  break unless reasontext.empty?
736
738
  end
737
739
 
738
-
739
740
  return reasontext
740
741
  end
741
742