sisimai 4.24.1-java → 4.25.0-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sisimai might be problematic. Click here for more details.

Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -2
  3. data/ANALYTICAL-PRECISION +16 -25
  4. data/ChangeLog.md +41 -0
  5. data/Developers.mk +2 -2
  6. data/README-JA.md +13 -13
  7. data/README.md +13 -13
  8. data/lib/sisimai.rb +3 -7
  9. data/lib/sisimai/address.rb +25 -41
  10. data/lib/sisimai/arf.rb +58 -59
  11. data/lib/sisimai/bite.rb +0 -1
  12. data/lib/sisimai/bite/email.rb +7 -7
  13. data/lib/sisimai/bite/email/activehunter.rb +4 -3
  14. data/lib/sisimai/bite/email/amavis.rb +133 -0
  15. data/lib/sisimai/bite/email/amazonses.rb +53 -87
  16. data/lib/sisimai/bite/email/amazonworkmail.rb +51 -57
  17. data/lib/sisimai/bite/email/aol.rb +50 -76
  18. data/lib/sisimai/bite/email/apachejames.rb +2 -2
  19. data/lib/sisimai/bite/email/bigfoot.rb +47 -74
  20. data/lib/sisimai/bite/email/biglobe.rb +8 -9
  21. data/lib/sisimai/bite/email/courier.rb +56 -101
  22. data/lib/sisimai/bite/email/domino.rb +7 -8
  23. data/lib/sisimai/bite/email/einsundeins.rb +4 -5
  24. data/lib/sisimai/bite/email/exchange2003.rb +21 -22
  25. data/lib/sisimai/bite/email/exchange2007.rb +26 -28
  26. data/lib/sisimai/bite/email/exim.rb +48 -47
  27. data/lib/sisimai/bite/email/ezweb.rb +24 -36
  28. data/lib/sisimai/bite/email/facebook.rb +54 -79
  29. data/lib/sisimai/bite/email/fml.rb +10 -10
  30. data/lib/sisimai/bite/email/gmx.rb +6 -6
  31. data/lib/sisimai/bite/email/google.rb +12 -13
  32. data/lib/sisimai/bite/email/gsuite.rb +80 -108
  33. data/lib/sisimai/bite/email/imailserver.rb +16 -16
  34. data/lib/sisimai/bite/email/interscanmss.rb +4 -6
  35. data/lib/sisimai/bite/email/kddi.rb +9 -11
  36. data/lib/sisimai/bite/email/mailfoundry.rb +2 -2
  37. data/lib/sisimai/bite/email/mailmarshalsmtp.rb +2 -2
  38. data/lib/sisimai/bite/email/mailru.rb +12 -13
  39. data/lib/sisimai/bite/email/mcafee.rb +31 -25
  40. data/lib/sisimai/bite/email/messagelabs.rb +48 -87
  41. data/lib/sisimai/bite/email/messagingserver.rb +9 -10
  42. data/lib/sisimai/bite/email/mfilter.rb +16 -16
  43. data/lib/sisimai/bite/email/mxlogic.rb +11 -11
  44. data/lib/sisimai/bite/email/notes.rb +5 -6
  45. data/lib/sisimai/bite/email/office365.rb +25 -42
  46. data/lib/sisimai/bite/email/opensmtpd.rb +8 -8
  47. data/lib/sisimai/bite/email/outlook.rb +49 -67
  48. data/lib/sisimai/bite/email/postfix.rb +78 -112
  49. data/lib/sisimai/bite/email/qmail.rb +23 -23
  50. data/lib/sisimai/bite/email/receivingses.rb +53 -86
  51. data/lib/sisimai/bite/email/sendgrid.rb +65 -84
  52. data/lib/sisimai/bite/email/sendmail.rb +89 -117
  53. data/lib/sisimai/bite/email/surfcontrol.rb +15 -18
  54. data/lib/sisimai/bite/email/userdefined.rb +1 -1
  55. data/lib/sisimai/bite/email/v5sendmail.rb +3 -4
  56. data/lib/sisimai/bite/email/verizon.rb +7 -8
  57. data/lib/sisimai/bite/email/x1.rb +2 -2
  58. data/lib/sisimai/bite/email/x2.rb +2 -2
  59. data/lib/sisimai/bite/email/x3.rb +3 -3
  60. data/lib/sisimai/bite/email/x4.rb +22 -22
  61. data/lib/sisimai/bite/email/x5.rb +40 -49
  62. data/lib/sisimai/bite/email/yahoo.rb +3 -3
  63. data/lib/sisimai/bite/email/yandex.rb +54 -82
  64. data/lib/sisimai/bite/email/zoho.rb +6 -6
  65. data/lib/sisimai/bite/json/amazonses.rb +20 -20
  66. data/lib/sisimai/bite/json/sendgrid.rb +2 -2
  67. data/lib/sisimai/data.rb +27 -40
  68. data/lib/sisimai/datetime.rb +146 -162
  69. data/lib/sisimai/mda.rb +30 -31
  70. data/lib/sisimai/message/email.rb +83 -123
  71. data/lib/sisimai/message/json.rb +2 -4
  72. data/lib/sisimai/mime.rb +31 -34
  73. data/lib/sisimai/order/email.rb +23 -22
  74. data/lib/sisimai/reason.rb +61 -61
  75. data/lib/sisimai/reason/blocked.rb +139 -135
  76. data/lib/sisimai/reason/contenterror.rb +11 -10
  77. data/lib/sisimai/reason/exceedlimit.rb +4 -4
  78. data/lib/sisimai/reason/expired.rb +20 -20
  79. data/lib/sisimai/reason/filtered.rb +19 -18
  80. data/lib/sisimai/reason/hasmoved.rb +3 -3
  81. data/lib/sisimai/reason/hostunknown.rb +19 -19
  82. data/lib/sisimai/reason/mailboxfull.rb +49 -49
  83. data/lib/sisimai/reason/mailererror.rb +16 -16
  84. data/lib/sisimai/reason/mesgtoobig.rb +17 -17
  85. data/lib/sisimai/reason/networkerror.rb +19 -19
  86. data/lib/sisimai/reason/norelaying.rb +16 -16
  87. data/lib/sisimai/reason/notaccept.rb +9 -10
  88. data/lib/sisimai/reason/onhold.rb +1 -1
  89. data/lib/sisimai/reason/policyviolation.rb +21 -20
  90. data/lib/sisimai/reason/rejected.rb +53 -53
  91. data/lib/sisimai/reason/securityerror.rb +29 -29
  92. data/lib/sisimai/reason/spamdetected.rb +127 -127
  93. data/lib/sisimai/reason/suspend.rb +17 -17
  94. data/lib/sisimai/reason/systemerror.rb +22 -21
  95. data/lib/sisimai/reason/systemfull.rb +6 -6
  96. data/lib/sisimai/reason/toomanyconn.rb +19 -18
  97. data/lib/sisimai/reason/userunknown.rb +122 -121
  98. data/lib/sisimai/reason/vacation.rb +8 -8
  99. data/lib/sisimai/reason/virusdetected.rb +8 -8
  100. data/lib/sisimai/rfc1894.rb +142 -0
  101. data/lib/sisimai/rfc3464.rb +70 -70
  102. data/lib/sisimai/rfc3834.rb +15 -15
  103. data/lib/sisimai/rfc5322.rb +20 -36
  104. data/lib/sisimai/rhost.rb +1 -0
  105. data/lib/sisimai/rhost/exchangeonline.rb +31 -33
  106. data/lib/sisimai/rhost/franceptt.rb +23 -23
  107. data/lib/sisimai/rhost/godaddy.rb +28 -28
  108. data/lib/sisimai/rhost/googleapps.rb +39 -41
  109. data/lib/sisimai/rhost/kddi.rb +3 -3
  110. data/lib/sisimai/rhost/tencentqq.rb +51 -0
  111. data/lib/sisimai/smtp/error.rb +14 -21
  112. data/lib/sisimai/smtp/reply.rb +14 -13
  113. data/lib/sisimai/smtp/status.rb +178 -179
  114. data/lib/sisimai/string.rb +13 -12
  115. data/lib/sisimai/version.rb +1 -1
  116. data/set-of-emails/README.md +1 -5
  117. data/set-of-emails/maildir/bsd/arf-23.eml +49 -0
  118. data/set-of-emails/maildir/bsd/email-amavis-01.eml +78 -0
  119. data/set-of-emails/maildir/bsd/email-amavis-02.eml +78 -0
  120. data/set-of-emails/maildir/bsd/email-exchange2007-04.eml +146 -0
  121. data/set-of-emails/maildir/bsd/email-exim-60.eml +94 -0
  122. data/set-of-emails/maildir/bsd/email-ezweb-08.eml +49 -0
  123. data/set-of-emails/maildir/bsd/email-google-19.eml +67 -0
  124. data/set-of-emails/maildir/bsd/email-mcafee-05.eml +74 -0
  125. data/set-of-emails/maildir/bsd/email-messagingserver-12.eml +99 -0
  126. data/set-of-emails/maildir/bsd/email-postfix-46.eml +81 -0
  127. data/set-of-emails/maildir/bsd/email-postfix-47.eml +79 -0
  128. data/set-of-emails/maildir/bsd/email-postfix-48.eml +79 -0
  129. data/set-of-emails/maildir/bsd/email-postfix-49.eml +141 -0
  130. data/set-of-emails/maildir/bsd/email-postfix-50.eml +143 -0
  131. data/set-of-emails/maildir/bsd/email-postfix-51.eml +73 -0
  132. data/set-of-emails/maildir/bsd/email-postfix-52.eml +79 -0
  133. data/set-of-emails/maildir/bsd/email-postfix-53.eml +76 -0
  134. data/set-of-emails/maildir/bsd/email-postfix-54.eml +73 -0
  135. data/set-of-emails/maildir/bsd/email-postfix-55.eml +74 -0
  136. data/set-of-emails/maildir/bsd/email-postfix-56.eml +78 -0
  137. data/set-of-emails/maildir/bsd/email-qmail-10.eml +50 -0
  138. data/set-of-emails/maildir/bsd/email-x2-05.eml +38 -0
  139. data/set-of-emails/maildir/bsd/rhost-google-apps-02.eml +88 -0
  140. data/set-of-emails/maildir/bsd/rhost-tencentqq-01.eml +84 -0
  141. data/set-of-emails/maildir/bsd/rhost-tencentqq-02.eml +84 -0
  142. data/set-of-emails/maildir/bsd/rhost-tencentqq-03.eml +81 -0
  143. data/set-of-emails/maildir/dos/email-amavis-01.eml +78 -0
  144. data/set-of-emails/maildir/dos/email-apachejames-01.eml +1 -2
  145. data/set-of-emails/maildir/dos/email-messagelabs-01.eml +67 -50
  146. data/set-of-emails/maildir/dos/email-x4-01.eml +31 -76
  147. data/set-of-emails/maildir/dos/rhost-tencentqq-01.eml +84 -0
  148. data/set-of-emails/maildir/mac/email-amavis-01.eml +1 -4
  149. data/set-of-emails/maildir/mac/email-apachejames-01.eml +1 -9
  150. data/set-of-emails/maildir/mac/email-messagelabs-01.eml +1 -9
  151. data/set-of-emails/maildir/mac/email-x4-01.eml +1 -5
  152. data/set-of-emails/maildir/mac/rhost-tencentqq-01.eml +1 -4
  153. metadata +35 -4
  154. data/set-of-emails/logo/horizontalversions.png +0 -0
  155. data/set-of-emails/logo/icon.png +0 -0
@@ -25,19 +25,20 @@ module Sisimai
25
25
  EngineOrder3 = [
26
26
  # These modules have no MTA specific header but listed in the following
27
27
  # subject header based regular expressions.
28
+ 'Sisimai::Bite::Email::Sendmail',
29
+ 'Sisimai::Bite::Email::Postfix',
28
30
  'Sisimai::Bite::Email::Qmail',
31
+ 'Sisimai::Bite::Email::SendGrid',
32
+ 'Sisimai::Bite::Email::Courier',
33
+ 'Sisimai::Bite::Email::OpenSMTPD',
29
34
  'Sisimai::Bite::Email::Notes',
30
35
  'Sisimai::Bite::Email::MessagingServer',
31
36
  'Sisimai::Bite::Email::Domino',
37
+ 'Sisimai::Bite::Email::Bigfoot',
32
38
  'Sisimai::Bite::Email::EinsUndEins',
33
- 'Sisimai::Bite::Email::OpenSMTPD',
34
39
  'Sisimai::Bite::Email::MXLogic',
35
- 'Sisimai::Bite::Email::Postfix',
36
- 'Sisimai::Bite::Email::Sendmail',
37
- 'Sisimai::Bite::Email::Courier',
40
+ 'Sisimai::Bite::Email::Amavis',
38
41
  'Sisimai::Bite::Email::IMailServer',
39
- 'Sisimai::Bite::Email::SendGrid',
40
- 'Sisimai::Bite::Email::Bigfoot',
41
42
  'Sisimai::Bite::Email::X4',
42
43
  ].freeze
43
44
  EngineOrder4 = [
@@ -58,12 +59,12 @@ module Sisimai
58
59
  EngineOrder5 = [
59
60
  # These modules have one or more MTA specific headers but other headers
60
61
  # also required for detecting MTA name
61
- 'Sisimai::Bite::Email::Google',
62
62
  'Sisimai::Bite::Email::Outlook',
63
63
  'Sisimai::Bite::Email::MailRu',
64
64
  'Sisimai::Bite::Email::MessageLabs',
65
65
  'Sisimai::Bite::Email::MailMarshalSMTP',
66
66
  'Sisimai::Bite::Email::MFILTER',
67
+ 'Sisimai::Bite::Email::Google',
67
68
  ].freeze
68
69
  EngineOrder9 = [
69
70
  # These modules have one or more MTA specific headers
@@ -72,8 +73,8 @@ module Sisimai
72
73
  'Sisimai::Bite::Email::AmazonSES',
73
74
  'Sisimai::Bite::Email::GMX',
74
75
  'Sisimai::Bite::Email::Yandex',
75
- 'Sisimai::Bite::Email::ReceivingSES',
76
76
  'Sisimai::Bite::Email::Office365',
77
+ 'Sisimai::Bite::Email::ReceivingSES',
77
78
  'Sisimai::Bite::Email::AmazonWorkMail',
78
79
  'Sisimai::Bite::Email::Zoho',
79
80
  'Sisimai::Bite::Email::McAfee',
@@ -87,9 +88,8 @@ module Sisimai
87
88
  'subject' => {
88
89
  'delivery' => [
89
90
  'Sisimai::Bite::Email::Exim',
90
- 'Sisimai::Bite::Email::Courier',
91
- 'Sisimai::Bite::Email::Google',
92
91
  'Sisimai::Bite::Email::Outlook',
92
+ 'Sisimai::Bite::Email::Courier',
93
93
  'Sisimai::Bite::Email::Domino',
94
94
  'Sisimai::Bite::Email::OpenSMTPD',
95
95
  'Sisimai::Bite::Email::EinsUndEins',
@@ -98,11 +98,11 @@ module Sisimai
98
98
  'Sisimai::Bite::Email::X4',
99
99
  'Sisimai::Bite::Email::X3',
100
100
  'Sisimai::Bite::Email::X2',
101
+ 'Sisimai::Bite::Email::Google',
101
102
  ],
102
103
  'noti' => [
103
- 'Sisimai::Bite::Email::Qmail',
104
104
  'Sisimai::Bite::Email::Sendmail',
105
- 'Sisimai::Bite::Email::Google',
105
+ 'Sisimai::Bite::Email::Qmail',
106
106
  'Sisimai::Bite::Email::Outlook',
107
107
  'Sisimai::Bite::Email::Courier',
108
108
  'Sisimai::Bite::Email::MessagingServer',
@@ -110,37 +110,39 @@ module Sisimai
110
110
  'Sisimai::Bite::Email::X4',
111
111
  'Sisimai::Bite::Email::X3',
112
112
  'Sisimai::Bite::Email::MFILTER',
113
+ 'Sisimai::Bite::Email::Google',
113
114
  ],
114
115
  'return' => [
115
116
  'Sisimai::Bite::Email::Postfix',
116
117
  'Sisimai::Bite::Email::Sendmail',
117
118
  'Sisimai::Bite::Email::SendGrid',
118
119
  'Sisimai::Bite::Email::Bigfoot',
119
- 'Sisimai::Bite::Email::X1',
120
120
  'Sisimai::Bite::Email::EinsUndEins',
121
+ 'Sisimai::Bite::Email::X1',
121
122
  'Sisimai::Bite::Email::Biglobe',
122
123
  'Sisimai::Bite::Email::V5sendmail',
123
124
  ],
124
125
  'undeliver' => [
125
126
  'Sisimai::Bite::Email::Postfix',
127
+ 'Sisimai::Bite::Email::Office365',
126
128
  'Sisimai::Bite::Email::Exchange2007',
127
129
  'Sisimai::Bite::Email::Exchange2003',
130
+ 'Sisimai::Bite::Email::SendGrid',
128
131
  'Sisimai::Bite::Email::Notes',
129
- 'Sisimai::Bite::Email::Office365',
130
132
  'Sisimai::Bite::Email::Verizon',
131
- 'Sisimai::Bite::Email::SendGrid',
133
+ 'Sisimai::Bite::Email::Amavis',
132
134
  'Sisimai::Bite::Email::IMailServer',
133
135
  'Sisimai::Bite::Email::MailMarshalSMTP',
134
136
  ],
135
137
  'failure' => [
136
138
  'Sisimai::Bite::Email::Qmail',
137
- 'Sisimai::Bite::Email::Domino',
138
- 'Sisimai::Bite::Email::Google',
139
139
  'Sisimai::Bite::Email::Outlook',
140
140
  'Sisimai::Bite::Email::MailRu',
141
+ 'Sisimai::Bite::Email::Domino',
141
142
  'Sisimai::Bite::Email::X4',
142
143
  'Sisimai::Bite::Email::X2',
143
144
  'Sisimai::Bite::Email::MFILTER',
145
+ 'Sisimai::Bite::Email::Google',
144
146
  ],
145
147
  'warning' => [
146
148
  'Sisimai::Bite::Email::Postfix',
@@ -149,6 +151,7 @@ module Sisimai
149
151
  ],
150
152
  },
151
153
  }.freeze
154
+ Skips = { 'return-path' => 1, 'x-mailer' => 1 }.freeze
152
155
 
153
156
  # @abstract Make default order of MTA modules to be loaded
154
157
  # @return [Array] Default order list of MTA modules
@@ -180,7 +183,6 @@ module Sisimai
180
183
  def headers
181
184
  order = Sisimai::Bite::Email.heads.map { |e| 'Sisimai::Bite::Email::' << e }
182
185
  table = {}
183
- skips = { 'return-path' => 1, 'x-mailer' => 1 }
184
186
 
185
187
  while e = order.shift do
186
188
  # Load email headers from each MTA module
@@ -188,10 +190,9 @@ module Sisimai
188
190
 
189
191
  Module.const_get(e).headerlist.each do |v|
190
192
  # Get header name which required each MTA module
191
- q = v.downcase
192
- next if skips.key?(q)
193
- table[q] ||= {}
194
- table[q][e] = 1
193
+ next if Skips.key?(v)
194
+ table[v] ||= []
195
+ table[v] << e
195
196
  end
196
197
  end
197
198
  return table
@@ -8,7 +8,10 @@ module Sisimai
8
8
  # Reason list better to retry detecting an error reason
9
9
  # @return [Array] Reason list
10
10
  def retry
11
- return %w[undefined onhold systemerror securityerror networkerror hostunknown userunknown]
11
+ return {
12
+ 'undefined' => 1, 'onhold' => 1, 'systemerror' => 1, 'securityerror' => 1,
13
+ 'networkerror' => 1, 'hostunknown' => 1, 'userunknown' => 1
14
+ }.freeze
12
15
  end
13
16
  GetRetried = Sisimai::Reason.retry
14
17
  ClassOrder = [
@@ -49,9 +52,9 @@ module Sisimai
49
52
  return nil unless argvs
50
53
  return nil unless argvs.is_a? Sisimai::Data
51
54
 
52
- unless GetRetried.index(argvs.reason)
55
+ unless GetRetried.key?(argvs.reason)
53
56
  # Return reason text already decided except reason match with the
54
- # regular expression of ->retry() method.
57
+ # regular expression of retry() method.
55
58
  return argvs.reason unless argvs.reason.empty?
56
59
  end
57
60
 
@@ -87,14 +90,14 @@ module Sisimai
87
90
  # Action: delayed => "expired"
88
91
  reasontext = nil
89
92
  reasontext ||= 'expired' if argvs.action == 'delayed'
90
- unless reasontext
91
- # Try to match with message patterns in Sisimai::Reason::Vacation
92
- require 'sisimai/reason/vacation'
93
- reasontext = 'vacation' if Sisimai::Reason::Vacation.match(argvs.diagnosticcode.downcase)
94
- end
95
- reasontext ||= 'onhold' unless argvs.diagnosticcode.empty?
93
+ return reasontext if reasontext
94
+
95
+ # Try to match with message patterns in Sisimai::Reason::Vacation
96
+ require 'sisimai/reason/vacation'
97
+ reasontext = 'vacation' if Sisimai::Reason::Vacation.match(argvs.diagnosticcode.downcase)
98
+ reasontext ||= 'onhold' unless argvs.diagnosticcode.empty?
99
+ reasontext ||= 'undefined'
96
100
  end
97
- reasontext ||= 'undefined'
98
101
  end
99
102
  return reasontext
100
103
  end
@@ -108,16 +111,15 @@ module Sisimai
108
111
  return nil unless argvs.is_a? Sisimai::Data
109
112
  return argvs.reason unless argvs.reason.empty?
110
113
 
114
+ require 'sisimai/smtp/status'
111
115
  statuscode = argvs.deliverystatus || ''
112
- diagnostic = argvs.diagnosticcode.downcase || ''
113
- commandtxt = argvs.smtpcommand || ''
114
- trytomatch = nil
115
- reasontext = Sisimai::SMTP::Status.name(statuscode)
116
+ reasontext = Sisimai::SMTP::Status.name(statuscode) || ''
116
117
 
117
118
  catch :TRY_TO_MATCH do
118
119
  while true
119
- trytomatch ||= true if reasontext.empty?
120
- trytomatch ||= true if GetRetried.index(reasontext)
120
+ diagnostic = argvs.diagnosticcode.downcase || ''
121
+ trytomatch = reasontext.empty? ? true : false
122
+ trytomatch ||= true if GetRetried.key?(reasontext)
121
123
  trytomatch ||= true if argvs.diagnostictype != 'SMTP'
122
124
  throw :TRY_TO_MATCH unless trytomatch
123
125
 
@@ -138,39 +140,37 @@ module Sisimai
138
140
  reasontext = e.downcase
139
141
  break
140
142
  end
141
-
142
- if reasontext.empty?
143
- # Check the value of Status:
144
- v = statuscode[0, 3]
145
- if v == '5.6' || v == '4.6'
146
- # X.6.0 Other or undefined media error
147
- reasontext = 'contenterror'
148
-
149
- elsif v == '5.7' || v == '4.7'
150
- # X.7.0 Other or undefined security status
151
- reasontext = 'securityerror'
152
-
153
- elsif %w[X-UNIX X-POSTFIX].include?(argvs.diagnostictype)
154
- # Diagnostic-Code: X-UNIX; ...
155
- reasontext = 'mailererror'
156
- else
157
- # 50X Syntax Error?
158
- require 'sisimai/reason/syntaxerror'
159
- reasontext = 'syntaxerror' if Sisimai::Reason::SyntaxError.true(argvs)
160
- end
143
+ throw :TRY_TO_MATCH unless reasontext.empty?
144
+
145
+ # Check the value of Status:
146
+ v = statuscode[0, 3]
147
+ if v == '5.6' || v == '4.6'
148
+ # X.6.0 Other or undefined media error
149
+ reasontext = 'contenterror'
150
+
151
+ elsif v == '5.7' || v == '4.7'
152
+ # X.7.0 Other or undefined security status
153
+ reasontext = 'securityerror'
154
+
155
+ elsif %w[X-UNIX X-POSTFIX].include?(argvs.diagnostictype)
156
+ # Diagnostic-Code: X-UNIX; ...
157
+ reasontext = 'mailererror'
158
+ else
159
+ # 50X Syntax Error?
160
+ require 'sisimai/reason/syntaxerror'
161
+ reasontext = 'syntaxerror' if Sisimai::Reason::SyntaxError.true(argvs)
161
162
  end
162
-
163
- if reasontext.empty?
164
- # Check the value of Action: field, first
165
- if argvs.action.start_with?('delayed', 'expired')
166
- # Action: delayed, expired
167
- reasontext = 'expired'
168
- else
169
- # Rejected at connection or after EHLO|HELO
170
- reasontext = 'blocked' if %w[HELO EHLO].index(commandtxt)
171
- end
163
+ throw :TRY_TO_MATCH unless reasontext.empty?
164
+
165
+ # Check the value of Action: field, first
166
+ if argvs.action.start_with?('delayed', 'expired')
167
+ # Action: delayed, expired
168
+ reasontext = 'expired'
169
+ else
170
+ # Rejected at connection or after EHLO|HELO
171
+ commandtxt = argvs.smtpcommand || ''
172
+ reasontext = 'blocked' if %w[HELO EHLO].index(commandtxt)
172
173
  end
173
-
174
174
  throw :TRY_TO_MATCH
175
175
  end
176
176
  end
@@ -182,15 +182,10 @@ module Sisimai
182
182
  # @return [String] Bounce reason
183
183
  def match(argv1)
184
184
  return nil unless argv1
185
- require 'sisimai/smtp/status'
186
185
 
187
186
  reasontext = ''
188
- typestring = ''
189
187
  diagnostic = argv1.downcase
190
188
 
191
- statuscode = Sisimai::SMTP::Status.find(argv1)
192
- if cv = argv1.match(/\A(SMTP|X-.+);/i) then typestring = cv[1].upcase end
193
-
194
189
  # Diagnostic-Code: SMTP; ... or empty value
195
190
  ClassOrder[2].each do |e|
196
191
  # Check the value of Diagnostic-Code: and the value of Status:, it is a
@@ -209,17 +204,22 @@ module Sisimai
209
204
  reasontext = r.text
210
205
  break
211
206
  end
207
+ return reasontext unless reasontext.empty?
212
208
 
213
- if reasontext.empty?
209
+ typestring = ''
210
+ if cv = argv1.match(/\A(SMTP|X-.+);/i)
214
211
  # Check the value of typestring
215
- if typestring == 'X-UNIX'
216
- # X-Unix; ...
217
- reasontext = 'mailererror'
218
- else
219
- # Detect the bounce reason from "Status:" code
220
- reasontext = Sisimai::SMTP::Status.name(statuscode) || 'undefined'
221
- reasontext = 'undefined' if reasontext.empty?
222
- end
212
+ typestring = cv[1].upcase
213
+ end
214
+
215
+ if typestring == 'X-UNIX'
216
+ # X-Unix; ...
217
+ reasontext = 'mailererror'
218
+ else
219
+ # Detect the bounce reason from "Status:" code
220
+ require 'sisimai/smtp/status'
221
+ statuscode = Sisimai::SMTP::Status.find(argv1) || ''
222
+ reasontext = Sisimai::SMTP::Status.name(statuscode) || 'undefined'
223
223
  end
224
224
  return reasontext
225
225
  end
@@ -9,6 +9,143 @@ module Sisimai
9
9
  module Blocked
10
10
  # Imported from p5-Sisimail/lib/Sisimai/Reason/Blocked.pm
11
11
  class << self
12
+ Regex = %r{(?>
13
+ access[ ]denied[.][ ]ip[ ]name[ ]lookup[ ]failed
14
+ |access[ ]from[ ]ip[ ]address[ ].+[ ]blocked
15
+ |all[ ]mail[ ]servers[ ]must[ ]have[ ]a[ ]ptr[ ]record[ ]with[ ]a[ ]valid[ ]reverse[ ]dns[ ]entry
16
+ |bad[ ]sender[ ]ip[ ]address
17
+ |banned[ ]sending[ ]ip # Office365
18
+ |blacklisted[ ]by
19
+ |(?:blocked|refused)[ ]-[ ]see[ ]https?://
20
+ |blocked[ ]using[ ]
21
+ |can[']t[ ]determine[ ]purported[ ]responsible[ ]address
22
+ |cannot[ ](?:
23
+ find[ ]your[ ]hostname
24
+ |resolve[ ]your[ ]address
25
+ )
26
+ |client[ ]host[ ](?:
27
+ .+[ ]blocked[ ]using
28
+ |rejected:[ ](?:
29
+ abus[ ]detecte[ ]gu_eib_0[24] # SFR
30
+ |cannot[ ]find[ ]your[ ]hostname # Yahoo!
31
+ |may[ ]not[ ]be[ ]mail[ ]exchanger
32
+ |was[ ]not[ ]authenticated # Microsoft
33
+ )
34
+ )
35
+ |confirm[ ]this[ ]mail[ ]server
36
+ |connection[ ](?:
37
+ dropped
38
+ |refused[ ]by
39
+ |reset[ ]by[ ]peer
40
+ |was[ ]dropped[ ]by[ ]remote[ ]host
41
+ )
42
+ |connections[ ](?:
43
+ not[ ]accepted[ ]from[ ]ip[ ]addresses[ ]on[ ]spamhaus[ ]xbl
44
+ |will[ ]not[ ]be[ ]accepted[ ]from[ ].+because[ ]the[ ]ip[ ]is[ ]in[ ]spamhaus's[ ]list
45
+ )
46
+ |currently[ ]sending[ ]spam[ ]see:[ ]
47
+ |domain[ ](?:
48
+ .+[ ]mismatches[ ]client[ ]ip
49
+ |does[ ]not[ ]exist:
50
+ )
51
+ |dns[ ]lookup[ ]failure:[ ].+[ ]try[ ]again[ ]later
52
+ |dnsbl:attrbl
53
+ |dynamic/zombied/spam[ ]ips[ ]blocked
54
+ |email[ ]blocked[ ]by[ ](?:.+[.]barracudacentral[.]org|spamhaus)
55
+ |esmtp[ ]not[ ]accepting[ ]connections # icloud.com
56
+ |fix[ ]reverse[ ]dns[ ]for[ ].+
57
+ |go[ ]away
58
+ |helo[ ]command[ ]rejected:
59
+ |host[ ].+[ ]refused[ ]to[ ]talk[ ]to[ ]me:[ ]\d+[ ]blocked
60
+ |hosts[ ]with[ ]dynamic[ ]ip
61
+ |http://(?:
62
+ spf[.]pobox[.]com/why[.]html
63
+ |www[.]spamcop[.]net/bl[.]
64
+ )
65
+ |invalid[ ]ip[ ]for[ ]sending[ ]mail[ ]of[ ]domain
66
+ |ip[ ]\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3}[ ]is[ ]blocked[ ]by[ ]EarthLink # Earthlink
67
+ |ip[/]domain[ ]reputation[ ]problems
68
+ |is[ ](?:
69
+ in[ ]a[ ]black[ ]list[ ]at[ ].+[.]
70
+ |in[ ]an[ ].*rbl[ ]on[ ].+
71
+ |not[ ]allowed[ ]to[ ]send[ ](?:
72
+ mail[ ]from
73
+ |from[ ].+[ ]per[ ]it's[ ]spf[ ]record
74
+ )
75
+ )
76
+ |mail[ ]server[ ]at[ ].+[ ]is[ ]blocked
77
+ |mail[ ]from[ ]\d+[.]\d+[.]\d+[.]\d[ ]refused:
78
+ |message[ ]from[ ].+[ ]rejected[ ]based[ ]on[ ]blacklist
79
+ |messages[ ]from[ ].+[ ]temporarily[ ]deferred[ ]due[ ]to[ ]user[ ]complaints # Yahoo!
80
+ |no[ ](?:
81
+ access[ ]from[ ]mail[ ]server
82
+ |ptr[ ]record[ ]found[.]
83
+ )
84
+ |not[ ]currently[ ]accepting[ ]mail[ ]from[ ]your[ ]ip # Microsoft
85
+ |part[ ]of[ ]their[ ]network[ ]is[ ]on[ ]our[ ]block[ ]list
86
+ |please[ ](?:
87
+ get[ ]a[ ]custom[ ]reverse[ ]dns[ ]name[ ]from[ ]your[ ]isp[ ]for[ ]your[ ]host
88
+ |inspect[ ]your[ ]spf[ ]settings
89
+ |use[ ]the[ ]smtp[ ]server[ ]of[ ]your[ ]isp
90
+ )
91
+ |ptr[ ]record[ ]setup
92
+ |rejecting[ ]open[ ]proxy # Sendmail(srvrsmtp.c)
93
+ |reverse[ ]dns[ ](?:
94
+ failed
95
+ |required
96
+ |lookup[ ]for[ ]host[ ].+[ ]failed[ ]permanently
97
+ )
98
+ |sender[ ]ip[ ](?:
99
+ address[ ]rejected
100
+ |reverse[ ]lookup[ ]rejected
101
+ )
102
+ |server[ ]access[ ](?:
103
+ .+[ ]forbidden[ ]by[ ]invalid[ ]rdns[ ]record[ ]of[ ]your[ ]mail[ ]server
104
+ |forbidden[ ]by[ ]your[ ]ip[ ]
105
+ )
106
+ |server[ ]ip[ ].+[ ]listed[ ]as[ ]abusive
107
+ |service[ ]not[ ]available,[ ]closing[ ]transmission[ ]channel
108
+ |service[ ]permits[ ]\d+[ ]unverifyable[ ]sending[ ]ips
109
+ |smtp[ ]error[ ]from[ ]remote[ ]mail[ ]server[ ]after[ ]initial[ ]connection: # Exim
110
+ |sorry,[ ](?:
111
+ that[ ]domain[ ]isn'?t[ ]in[ ]my[ ]list[ ]of[ ]allowed[ ]rcpthosts
112
+ |your[ ]remotehost[ ]looks[ ]suspiciously[ ]like[ ]spammer
113
+ )
114
+ |spf[ ](?:
115
+ .+[ ]domain[ ]authentication[ ]fail
116
+ |record
117
+ |check:[ ]fail
118
+ )
119
+ |spf:[ ].+[ ]is[ ]not[ ]allowed[ ]to[ ]send[ ]mail.+[a-z]{3}.+401
120
+ |the[ ](?:email|domain|ip).+[ ]is[ ]blacklisted
121
+ |this[ ]system[ ]will[ ]not[ ]accept[ ]messages[ ]from[ ]servers[/]devices[ ]with[ ]no[ ]reverse[ ]dns
122
+ |too[ ]many[ ](?:
123
+ spams[ ]from[ ]your[ ]ip # free.fr
124
+ |unwanted[ ]messages[ ]have[ ]been[ ]sent[ ]from[ ]the[ ]following[ ]ip[ ]address[ ]above
125
+ )
126
+ |unresolvable[ ]relay[ ]host[ ]name
127
+ |veuillez[ ]essayer[ ]plus[ ]tard.+[a-z]{3}.+(?:103|510)
128
+ |your[ ](?:
129
+ network[ ]is[ ]temporary[ ]blacklisted
130
+ |sender's[ ]ip[ ]address[ ]is[ ]listed[ ]at[ ].+[.]abuseat[.]org
131
+ |server[ ]requires[ ]confirmation
132
+ )
133
+ |was[ ]blocked[ ]by[ ].+
134
+ |we[ ]do[ ]not[ ]accept[ ]mail[ ]from[ ](?: # @mail.ru
135
+ dynamic[ ]ips
136
+ |hosts[ ]with[ ]dynamic[ ]ip[ ]or[ ]generic[ ]dns[ ]ptr-records
137
+ )
138
+ |you[ ]are[ ](?:
139
+ not[ ]allowed[ ]to[ ]connect
140
+ |sending[ ]spam
141
+ )
142
+ |your[ ](?:
143
+ access[ ]to[ ]submit[ ]messages[ ]to[ ]this[ ]e-mail[ ]system[ ]has[ ]been[ ]rejected
144
+ |message[ ]was[ ]rejected[ ]for[ ]possible[ ]spam/virus[ ]content
145
+ )
146
+ )
147
+ }x
148
+
12
149
  def text; return 'blocked'; end
13
150
  def description; return 'Email rejected due to client IP address or a hostname'; end
14
151
 
@@ -18,140 +155,7 @@ module Sisimai
18
155
  # true: Matched
19
156
  def match(argv1)
20
157
  return nil unless argv1
21
- regex = %r{(?>
22
- access[ ]denied[.][ ]ip[ ]name[ ]lookup[ ]failed
23
- |access[ ]from[ ]ip[ ]address[ ].+[ ]blocked
24
- |all[ ]mail[ ]servers[ ]must[ ]have[ ]a[ ]ptr[ ]record[ ]with[ ]a[ ]valid[ ]reverse[ ]dns[ ]entry
25
- |bad[ ]sender[ ]ip[ ]address
26
- |banned[ ]sending[ ]ip # Office365
27
- |blacklisted[ ]by
28
- |(?:blocked|refused)[ ]-[ ]see[ ]https?://
29
- |blocked[ ]using[ ]
30
- |can[']t[ ]determine[ ]purported[ ]responsible[ ]address
31
- |cannot[ ](?:
32
- find[ ]your[ ]hostname
33
- |resolve[ ]your[ ]address
34
- )
35
- |client[ ]host[ ](?:
36
- .+[ ]blocked[ ]using
37
- |rejected:[ ](?:
38
- abus[ ]detecte[ ]gu_eib_0[24] # SFR
39
- |cannot[ ]find[ ]your[ ]hostname # Yahoo!
40
- |may[ ]not[ ]be[ ]mail[ ]exchanger
41
- |was[ ]not[ ]authenticated # Microsoft
42
- )
43
- )
44
- |confirm[ ]this[ ]mail[ ]server
45
- |connection[ ](?:
46
- dropped
47
- |refused[ ]by
48
- |reset[ ]by[ ]peer
49
- |was[ ]dropped[ ]by[ ]remote[ ]host
50
- )
51
- |connections[ ](?:
52
- not[ ]accepted[ ]from[ ]ip[ ]addresses[ ]on[ ]spamhaus[ ]xbl
53
- |will[ ]not[ ]be[ ]accepted[ ]from[ ].+because[ ]the[ ]ip[ ]is[ ]in[ ]spamhaus's[ ]list
54
- )
55
- |currently[ ]sending[ ]spam[ ]see:[ ]
56
- |domain[ ](?:
57
- .+[ ]mismatches[ ]client[ ]ip
58
- |does[ ]not[ ]exist:
59
- )
60
- |dns[ ]lookup[ ]failure:[ ].+[ ]try[ ]again[ ]later
61
- |dnsbl:attrbl
62
- |dynamic/zombied/spam[ ]ips[ ]blocked
63
- |email[ ]blocked[ ]by[ ](?:.+[.]barracudacentral[.]org|spamhaus)
64
- |esmtp[ ]not[ ]accepting[ ]connections # icloud.com
65
- |fix[ ]reverse[ ]dns[ ]for[ ].+
66
- |go[ ]away
67
- |helo[ ]command[ ]rejected:
68
- |host[ ].+[ ]refused[ ]to[ ]talk[ ]to[ ]me:[ ]\d+[ ]blocked
69
- |hosts[ ]with[ ]dynamic[ ]ip
70
- |http://(?:
71
- spf[.]pobox[.]com/why[.]html
72
- |www[.]spamcop[.]net/bl[.]
73
- )
74
- |invalid[ ]ip[ ]for[ ]sending[ ]mail[ ]of[ ]domain
75
- |ip[ ]\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3}[ ]is[ ]blocked[ ]by[ ]EarthLink # Earthlink
76
- |ip[/]domain[ ]reputation[ ]problems
77
- |is[ ](?:
78
- in[ ]a[ ]black[ ]list[ ]at[ ].+[.]
79
- |in[ ]an[ ].*rbl[ ]on[ ].+
80
- |not[ ]allowed[ ]to[ ]send[ ](?:
81
- mail[ ]from
82
- |from[ ].+[ ]per[ ]it's[ ]spf[ ]record
83
- )
84
- )
85
- |mail[ ]server[ ]at[ ].+[ ]is[ ]blocked
86
- |mail[ ]from[ ]\d+[.]\d+[.]\d+[.]\d[ ]refused:
87
- |message[ ]from[ ].+[ ]rejected[ ]based[ ]on[ ]blacklist
88
- |messages[ ]from[ ].+[ ]temporarily[ ]deferred[ ]due[ ]to[ ]user[ ]complaints # Yahoo!
89
- |no[ ](?:
90
- access[ ]from[ ]mail[ ]server
91
- |ptr[ ]record[ ]found[.]
92
- )
93
- |not[ ]currently[ ]accepting[ ]mail[ ]from[ ]your[ ]ip # Microsoft
94
- |part[ ]of[ ]their[ ]network[ ]is[ ]on[ ]our[ ]block[ ]list
95
- |please[ ](?:
96
- get[ ]a[ ]custom[ ]reverse[ ]dns[ ]name[ ]from[ ]your[ ]isp[ ]for[ ]your[ ]host
97
- |inspect[ ]your[ ]spf[ ]settings
98
- |use[ ]the[ ]smtp[ ]server[ ]of[ ]your[ ]isp
99
- )
100
- |ptr[ ]record[ ]setup
101
- |rejecting[ ]open[ ]proxy # Sendmail(srvrsmtp.c)
102
- |reverse[ ]dns[ ](?:
103
- failed
104
- |required
105
- |lookup[ ]for[ ]host[ ].+[ ]failed[ ]permanently
106
- )
107
- |sender[ ]ip[ ](?:
108
- address[ ]rejected
109
- |reverse[ ]lookup[ ]rejected
110
- )
111
- |server[ ]access[ ](?:
112
- .+[ ]forbidden[ ]by[ ]invalid[ ]rdns[ ]record[ ]of[ ]your[ ]mail[ ]server
113
- |forbidden[ ]by[ ]your[ ]ip[ ]
114
- )
115
- |server[ ]ip[ ].+[ ]listed[ ]as[ ]abusive
116
- |service[ ]permits[ ]\d+[ ]unverifyable[ ]sending[ ]ips
117
- |smtp[ ]error[ ]from[ ]remote[ ]mail[ ]server[ ]after[ ]initial[ ]connection: # Exim
118
- |sorry,[ ](?:
119
- that[ ]domain[ ]isn'?t[ ]in[ ]my[ ]list[ ]of[ ]allowed[ ]rcpthosts
120
- |your[ ]remotehost[ ]looks[ ]suspiciously[ ]like[ ]spammer
121
- )
122
- |spf[ ](?:
123
- .+[ ]domain[ ]authentication[ ]fail
124
- |record
125
- |check:[ ]fail
126
- )
127
- |spf:[ ].+[ ]is[ ]not[ ]allowed[ ]to[ ]send[ ]mail.+[a-z]{3}.+401
128
- |the[ ](?:email|domain|ip).+[ ]is[ ]blacklisted
129
- |this[ ]system[ ]will[ ]not[ ]accept[ ]messages[ ]from[ ]servers[/]devices[ ]with[ ]no[ ]reverse[ ]dns
130
- |too[ ]many[ ]spams[ ]from[ ]your[ ]ip # free.fr
131
- |unresolvable[ ]relay[ ]host[ ]name
132
- |veuillez[ ]essayer[ ]plus[ ]tard.+[a-z]{3}.+(?:103|510)
133
- |your[ ](?:
134
- network[ ]is[ ]temporary[ ]blacklisted
135
- |sender's[ ]ip[ ]address[ ]is[ ]listed[ ]at[ ].+[.]abuseat[.]org
136
- |server[ ]requires[ ]confirmation
137
- )
138
- |was[ ]blocked[ ]by[ ].+
139
- |we[ ]do[ ]not[ ]accept[ ]mail[ ]from[ ](?: # @mail.ru
140
- dynamic[ ]ips
141
- |hosts[ ]with[ ]dynamic[ ]ip[ ]or[ ]generic[ ]dns[ ]ptr-records
142
- )
143
- |you[ ]are[ ](?:
144
- not[ ]allowed[ ]to[ ]connect
145
- |sending[ ]spam
146
- )
147
- |your[ ](?:
148
- access[ ]to[ ]submit[ ]messages[ ]to[ ]this[ ]e-mail[ ]system[ ]has[ ]been[ ]rejected
149
- |message[ ]was[ ]rejected[ ]for[ ]possible[ ]spam/virus[ ]content
150
- )
151
- )
152
- }x
153
-
154
- return true if argv1 =~ regex
158
+ return true if argv1 =~ Regex
155
159
  return false
156
160
  end
157
161
 
@@ -162,7 +166,7 @@ module Sisimai
162
166
  # @see http://www.ietf.org/rfc/rfc2822.txt
163
167
  def true(argvs)
164
168
  return true if argvs.reason == 'blocked'
165
- return true if Sisimai::SMTP::Status.name(argvs.deliverystatus) == 'blocked'
169
+ return true if Sisimai::SMTP::Status.name(argvs.deliverystatus).to_s == 'blocked'
166
170
  return true if match(argvs.diagnosticcode.downcase)
167
171
  return false
168
172
  end