sisimai 4.22.7 → 4.23.0

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 (118) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +15 -0
  3. data/README-JA.md +13 -8
  4. data/README.md +14 -9
  5. data/lib/sisimai.rb +11 -12
  6. data/lib/sisimai/address.rb +13 -23
  7. data/lib/sisimai/arf.rb +10 -12
  8. data/lib/sisimai/bite/email/activehunter.rb +5 -9
  9. data/lib/sisimai/bite/email/amazonses.rb +12 -18
  10. data/lib/sisimai/bite/email/amazonworkmail.rb +7 -12
  11. data/lib/sisimai/bite/email/aol.rb +10 -16
  12. data/lib/sisimai/bite/email/apachejames.rb +8 -12
  13. data/lib/sisimai/bite/email/bigfoot.rb +10 -15
  14. data/lib/sisimai/bite/email/biglobe.rb +7 -11
  15. data/lib/sisimai/bite/email/courier.rb +11 -15
  16. data/lib/sisimai/bite/email/domino.rb +8 -13
  17. data/lib/sisimai/bite/email/einsundeins.rb +7 -11
  18. data/lib/sisimai/bite/email/exchange2003.rb +11 -15
  19. data/lib/sisimai/bite/email/exchange2007.rb +7 -11
  20. data/lib/sisimai/bite/email/exim.rb +20 -27
  21. data/lib/sisimai/bite/email/ezweb.rb +13 -22
  22. data/lib/sisimai/bite/email/facebook.rb +7 -10
  23. data/lib/sisimai/bite/email/fml.rb +4 -7
  24. data/lib/sisimai/bite/email/gmx.rb +7 -12
  25. data/lib/sisimai/bite/email/google.rb +6 -12
  26. data/lib/sisimai/bite/email/gsuite.rb +11 -18
  27. data/lib/sisimai/bite/email/imailserver.rb +6 -10
  28. data/lib/sisimai/bite/email/interscanmss.rb +7 -11
  29. data/lib/sisimai/bite/email/kddi.rb +10 -16
  30. data/lib/sisimai/bite/email/mailfoundry.rb +6 -9
  31. data/lib/sisimai/bite/email/mailmarshalsmtp.rb +6 -10
  32. data/lib/sisimai/bite/email/mailru.rb +12 -16
  33. data/lib/sisimai/bite/email/mcafee.rb +5 -9
  34. data/lib/sisimai/bite/email/messagelabs.rb +7 -10
  35. data/lib/sisimai/bite/email/messagingserver.rb +8 -14
  36. data/lib/sisimai/bite/email/mfilter.rb +6 -10
  37. data/lib/sisimai/bite/email/mxlogic.rb +11 -17
  38. data/lib/sisimai/bite/email/notes.rb +9 -13
  39. data/lib/sisimai/bite/email/office365.rb +8 -13
  40. data/lib/sisimai/bite/email/opensmtpd.rb +7 -11
  41. data/lib/sisimai/bite/email/outlook.rb +9 -13
  42. data/lib/sisimai/bite/email/postfix.rb +12 -18
  43. data/lib/sisimai/bite/email/qmail.rb +10 -15
  44. data/lib/sisimai/bite/email/receivingses.rb +10 -17
  45. data/lib/sisimai/bite/email/sendgrid.rb +8 -14
  46. data/lib/sisimai/bite/email/sendmail.rb +8 -12
  47. data/lib/sisimai/bite/email/surfcontrol.rb +5 -9
  48. data/lib/sisimai/bite/email/userdefined.rb +5 -8
  49. data/lib/sisimai/bite/email/v5sendmail.rb +7 -11
  50. data/lib/sisimai/bite/email/verizon.rb +14 -28
  51. data/lib/sisimai/bite/email/x1.rb +5 -8
  52. data/lib/sisimai/bite/email/x2.rb +5 -8
  53. data/lib/sisimai/bite/email/x3.rb +5 -9
  54. data/lib/sisimai/bite/email/x4.rb +10 -14
  55. data/lib/sisimai/bite/email/x5.rb +6 -11
  56. data/lib/sisimai/bite/email/yahoo.rb +6 -11
  57. data/lib/sisimai/bite/email/yandex.rb +8 -12
  58. data/lib/sisimai/bite/email/zoho.rb +7 -12
  59. data/lib/sisimai/bite/json/amazonses.rb +6 -12
  60. data/lib/sisimai/bite/json/sendgrid.rb +1 -7
  61. data/lib/sisimai/data.rb +26 -34
  62. data/lib/sisimai/datetime.rb +5 -5
  63. data/lib/sisimai/mail.rb +9 -3
  64. data/lib/sisimai/mail/maildir.rb +1 -3
  65. data/lib/sisimai/mail/mbox.rb +1 -1
  66. data/lib/sisimai/mail/memory.rb +47 -0
  67. data/lib/sisimai/mail/stdin.rb +1 -1
  68. data/lib/sisimai/mda.rb +7 -10
  69. data/lib/sisimai/message.rb +4 -6
  70. data/lib/sisimai/message/email.rb +16 -24
  71. data/lib/sisimai/message/json.rb +3 -5
  72. data/lib/sisimai/mime.rb +13 -18
  73. data/lib/sisimai/order/email.rb +5 -8
  74. data/lib/sisimai/order/json.rb +2 -2
  75. data/lib/sisimai/reason.rb +3 -7
  76. data/lib/sisimai/reason/blocked.rb +0 -4
  77. data/lib/sisimai/reason/contenterror.rb +1 -1
  78. data/lib/sisimai/reason/exceedlimit.rb +2 -5
  79. data/lib/sisimai/reason/expired.rb +1 -1
  80. data/lib/sisimai/reason/filtered.rb +1 -4
  81. data/lib/sisimai/reason/hasmoved.rb +1 -4
  82. data/lib/sisimai/reason/hostunknown.rb +1 -4
  83. data/lib/sisimai/reason/mailboxfull.rb +2 -5
  84. data/lib/sisimai/reason/mesgtoobig.rb +1 -4
  85. data/lib/sisimai/reason/networkerror.rb +1 -1
  86. data/lib/sisimai/reason/norelaying.rb +1 -4
  87. data/lib/sisimai/reason/notaccept.rb +1 -3
  88. data/lib/sisimai/reason/onhold.rb +1 -5
  89. data/lib/sisimai/reason/policyviolation.rb +1 -1
  90. data/lib/sisimai/reason/rejected.rb +2 -6
  91. data/lib/sisimai/reason/spamdetected.rb +1 -5
  92. data/lib/sisimai/reason/suspend.rb +2 -5
  93. data/lib/sisimai/reason/syntaxerror.rb +0 -3
  94. data/lib/sisimai/reason/systemerror.rb +1 -1
  95. data/lib/sisimai/reason/systemfull.rb +1 -1
  96. data/lib/sisimai/reason/toomanyconn.rb +1 -5
  97. data/lib/sisimai/reason/userunknown.rb +1 -4
  98. data/lib/sisimai/reason/vacation.rb +1 -1
  99. data/lib/sisimai/reason/virusdetected.rb +1 -1
  100. data/lib/sisimai/rfc2606.rb +3 -3
  101. data/lib/sisimai/rfc3464.rb +12 -20
  102. data/lib/sisimai/rfc3834.rb +1 -10
  103. data/lib/sisimai/rfc5322.rb +4 -6
  104. data/lib/sisimai/rhost.rb +0 -4
  105. data/lib/sisimai/rhost/exchangeonline.rb +5 -7
  106. data/lib/sisimai/rhost/franceptt.rb +1 -3
  107. data/lib/sisimai/rhost/godaddy.rb +2 -4
  108. data/lib/sisimai/rhost/googleapps.rb +2 -4
  109. data/lib/sisimai/rhost/kddi.rb +0 -3
  110. data/lib/sisimai/smtp/error.rb +0 -3
  111. data/lib/sisimai/smtp/reply.rb +5 -8
  112. data/lib/sisimai/smtp/status.rb +3 -4
  113. data/lib/sisimai/string.rb +13 -20
  114. data/lib/sisimai/version.rb +1 -1
  115. data/set-of-emails/maildir/bsd/email-office365-09.eml +596 -0
  116. data/set-of-emails/maildir/bsd/email-office365-10.eml +594 -0
  117. data/set-of-emails/maildir/bsd/email-postfix-45.eml +76 -0
  118. metadata +6 -2
@@ -46,9 +46,6 @@ module Sisimai::Bite::Email
46
46
  # part or nil if it failed to parse or
47
47
  # the arguments are missing
48
48
  def scan(mhead, mbody)
49
- return nil unless mhead
50
- return nil unless mbody
51
-
52
49
  # :from => %r/ [(]Mail Delivery System[)]\z/,
53
50
  return nil unless mhead['subject'] == 'Undelivered Mail Returned to Sender'
54
51
 
@@ -73,7 +70,7 @@ module Sisimai::Bite::Email
73
70
  havepassed << e
74
71
  p = havepassed[-2]
75
72
 
76
- if readcursor.zero?
73
+ if readcursor == 0
77
74
  # Beginning of the bounce message or delivery status part
78
75
  if e =~ MarkingsOf[:message]
79
76
  readcursor |= Indicators[:deliverystatus]
@@ -81,7 +78,7 @@ module Sisimai::Bite::Email
81
78
  end
82
79
  end
83
80
 
84
- if (readcursor & Indicators[:'message-rfc822']).zero?
81
+ if (readcursor & Indicators[:'message-rfc822']) == 0
85
82
  # Beginning of the original message part
86
83
  if e.start_with?(StartingOf[:rfc822][0], StartingOf[:rfc822][1])
87
84
  readcursor |= Indicators[:'message-rfc822']
@@ -99,7 +96,7 @@ module Sisimai::Bite::Email
99
96
  rfc822list << e
100
97
  else
101
98
  # Before "message/rfc822"
102
- next if (readcursor & Indicators[:deliverystatus]).zero?
99
+ next if (readcursor & Indicators[:deliverystatus]) == 0
103
100
  next if e.empty?
104
101
 
105
102
  if connvalues == connheader.keys.size
@@ -152,7 +149,7 @@ module Sisimai::Bite::Email
152
149
  # 685 #endif
153
150
  v['date'] = cv[1]
154
151
  else
155
- if cv = e.match(/\ADiagnostic-Code:[ ]*(.+?);[ ]*(.+)\z/)
152
+ if cv = e.match(/\ADiagnostic-Code:[ ]*(.+?);[ ]*(.*)\z/)
156
153
  # Diagnostic-Code: SMTP; 550 5.1.1 <userunknown@example.jp>... User Unknown
157
154
  v['spec'] = cv[1].upcase
158
155
  v['diagnosis'] = cv[2]
@@ -188,13 +185,13 @@ module Sisimai::Bite::Email
188
185
  else
189
186
  if cv = e.match(/\AReporting-MTA:[ ]*(?:DNS|dns);[ ]*(.+)\z/)
190
187
  # Reporting-MTA: dns; mx.example.jp
191
- next if connheader['lhost'].size > 0
188
+ next unless connheader['lhost'].empty?
192
189
  connheader['lhost'] = cv[1].downcase
193
190
  connvalues += 1
194
191
 
195
192
  elsif cv = e.match(/\AArrival-Date:[ ]*(.+)\z/)
196
193
  # Arrival-Date: Wed, 29 Apr 2009 16:03:18 +0900
197
- next if connheader['date'].size > 0
194
+ next unless connheader['date'].empty?
198
195
  connheader['date'] = cv[1]
199
196
  connvalues += 1
200
197
 
@@ -227,20 +224,17 @@ module Sisimai::Bite::Email
227
224
  end # End of if: rfc822
228
225
  end
229
226
 
230
- if recipients.zero?
227
+ unless recipients > 0
231
228
  # Fallback: set recipient address from error message
232
- if anotherset['recipient'].to_s.size > 0
229
+ unless anotherset['recipient'].to_s.empty?
233
230
  # Set recipient address
234
231
  dscontents[-1]['recipient'] = anotherset['recipient']
235
232
  recipients += 1
236
233
  end
237
234
  end
238
- return nil if recipients.zero?
235
+ return nil unless recipients > 0
239
236
 
240
- require 'sisimai/string'
241
- require 'sisimai/smtp/status'
242
- require 'sisimai/smtp/reply'
243
- dscontents.map do |e|
237
+ dscontents.each do |e|
244
238
  # Set default values if each value is empty.
245
239
  connheader.each_key { |a| e[a] ||= connheader[a] || '' }
246
240
 
@@ -264,7 +258,7 @@ module Sisimai::Bite::Email
264
258
  if e['status'] == '' || e['status'].start_with?('4.0.0', '5.0.0')
265
259
  # Check the value of D.S.N. in anotherset
266
260
  as = Sisimai::SMTP::Status.find(anotherset['diagnosis'])
267
- if as.size > 0 && as[-3, 3] != '0.0'
261
+ if !as.empty? && as[-3, 3] != '0.0'
268
262
  # The D.S.N. is neither an empty nor *.0.0
269
263
  e['status'] = as
270
264
  end
@@ -273,7 +267,7 @@ module Sisimai::Bite::Email
273
267
  if e['replycode'] == '' || e['replycode'].start_with?('400', '500')
274
268
  # Check the value of SMTP reply code in anotherset
275
269
  ar = Sisimai::SMTP::Reply.find(anotherset['diagnosis'])
276
- if ar.size > 0 && ar[-2, 2].to_i != 0
270
+ if !ar.empty? && ar[-2, 2].to_i != 0
277
271
  # The SMTP reply code is neither an empty nor *00
278
272
  e['replycode'] = ar
279
273
  end
@@ -115,9 +115,6 @@ module Sisimai::Bite::Email
115
115
  # part or nil if it failed to parse or
116
116
  # the arguments are missing
117
117
  def scan(mhead, mbody)
118
- return nil unless mhead
119
- return nil unless mbody
120
-
121
118
  # Pre process email headers and the body part of the message which generated
122
119
  # by qmail, see http://cr.yp.to/qmail.html
123
120
  # e.g.) Received: (qmail 12345 invoked for bounce); 29 Apr 2009 12:34:56 -0000
@@ -125,8 +122,8 @@ module Sisimai::Bite::Email
125
122
  tryto = /\A[(]qmail[ ]+\d+[ ]+invoked[ ]+(?:for[ ]+bounce|from[ ]+network)[)]/
126
123
  match = 0
127
124
  match += 1 if mhead['subject'] == 'failure notice'
128
- match += 1 if mhead['received'].find { |a| a =~ tryto }
129
- return nil if match.zero?
125
+ match += 1 if mhead['received'].any? { |a| a =~ tryto }
126
+ return nil unless match > 0
130
127
 
131
128
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
132
129
  hasdivided = mbody.split("\n")
@@ -137,7 +134,7 @@ module Sisimai::Bite::Email
137
134
  v = nil
138
135
 
139
136
  while e = hasdivided.shift do
140
- if readcursor.zero?
137
+ if readcursor == 0
141
138
  # Beginning of the bounce message or delivery status part
142
139
  if e.start_with?(StartingOf[:message][0])
143
140
  readcursor |= Indicators[:deliverystatus]
@@ -145,7 +142,7 @@ module Sisimai::Bite::Email
145
142
  end
146
143
  end
147
144
 
148
- if (readcursor & Indicators[:'message-rfc822']).zero?
145
+ if (readcursor & Indicators[:'message-rfc822']) == 0
149
146
  # Beginning of the original message part
150
147
  if e == StartingOf[:rfc822][0]
151
148
  readcursor |= Indicators[:'message-rfc822']
@@ -163,7 +160,7 @@ module Sisimai::Bite::Email
163
160
  rfc822list << e
164
161
  else
165
162
  # Before "message/rfc822"
166
- next if (readcursor & Indicators[:deliverystatus]).zero?
163
+ next if (readcursor & Indicators[:deliverystatus]) == 0
167
164
  next if e.empty?
168
165
 
169
166
  # <kijitora@example.jp>:
@@ -196,11 +193,9 @@ module Sisimai::Bite::Email
196
193
  end
197
194
  end
198
195
  end
199
- return nil if recipients.zero?
196
+ return nil unless recipients > 0
200
197
 
201
- require 'sisimai/string'
202
- require 'sisimai/smtp/status'
203
- dscontents.map do |e|
198
+ dscontents.each do |e|
204
199
  e['agent'] = self.smtpagent
205
200
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis']) || ''
206
201
 
@@ -241,12 +236,12 @@ module Sisimai::Bite::Email
241
236
  # Verify each regular expression of session errors
242
237
  if e['alterrors']
243
238
  # Check the value of "alterrors"
244
- next unless MessagesOf[r].find { |a| e['alterrors'].include?(a) }
239
+ next unless MessagesOf[r].any? { |a| e['alterrors'].include?(a) }
245
240
  e['reason'] = r.to_s
246
241
  end
247
242
  break if e['reason']
248
243
 
249
- next unless MessagesOf[r].find { |a| e['diagnosis'].include?(a) }
244
+ next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
250
245
  e['reason'] = r.to_s
251
246
  break
252
247
  end
@@ -254,7 +249,7 @@ module Sisimai::Bite::Email
254
249
  unless e['reason']
255
250
  FailOnLDAP.each_key do |r|
256
251
  # Verify each regular expression of LDAP errors
257
- next unless FailOnLDAP[r].find { |a| e['diagnosis'].include?(a) }
252
+ next unless FailOnLDAP[r].any? { |a| e['diagnosis'].include?(a) }
258
253
  e['reason'] = r.to_s
259
254
  break
260
255
  end
@@ -40,9 +40,6 @@ module Sisimai::Bite::Email
40
40
  # part or nil if it failed to parse or
41
41
  # the arguments are missing
42
42
  def scan(mhead, mbody)
43
- return nil unless mhead
44
- return nil unless mbody
45
-
46
43
  # :subject => %r/\ADelivery Status Notification [(]Failure[)]\z/,
47
44
  # :received => %r/.+[.]smtp-out[.].+[.]amazonses[.]com\b/,
48
45
  return nil unless mhead['x-ses-outgoing']
@@ -66,7 +63,7 @@ module Sisimai::Bite::Email
66
63
  havepassed << e
67
64
  p = havepassed[-2]
68
65
 
69
- if readcursor.zero?
66
+ if readcursor == 0
70
67
  # Beginning of the bounce message or delivery status part
71
68
  if e == StartingOf[:message][0]
72
69
  readcursor |= Indicators[:deliverystatus]
@@ -74,7 +71,7 @@ module Sisimai::Bite::Email
74
71
  end
75
72
  end
76
73
 
77
- if (readcursor & Indicators[:'message-rfc822']).zero?
74
+ if (readcursor & Indicators[:'message-rfc822']) == 0
78
75
  # Beginning of the original message part
79
76
  if e == StartingOf[:rfc822][0]
80
77
  readcursor |= Indicators[:'message-rfc822']
@@ -92,7 +89,7 @@ module Sisimai::Bite::Email
92
89
  rfc822list << e
93
90
  else
94
91
  # Before "message/rfc822"
95
- next if (readcursor & Indicators[:deliverystatus]).zero?
92
+ next if (readcursor & Indicators[:deliverystatus]) == 0
96
93
  next if e.empty?
97
94
 
98
95
  if connvalues == connheader.keys.size
@@ -156,29 +153,25 @@ module Sisimai::Bite::Email
156
153
  # Reporting-MTA: dns; inbound-smtp.us-west-2.amazonaws.com
157
154
  if cv = e.match(/\AReporting-MTA:[ ]*(?:DNS|dns);[ ]*(.+)\z/)
158
155
  # Reporting-MTA: dns; mx.example.jp
159
- next if connheader['lhost'].size > 0
156
+ next unless connheader['lhost'].empty?
160
157
  connheader['lhost'] = cv[1].downcase
161
158
  connvalues += 1
162
159
 
163
160
  elsif cv = e.match(/\AArrival-Date:[ ]*(.+)\z/)
164
161
  # Arrival-Date: Wed, 29 Apr 2009 16:03:18 +0900
165
- next if connheader['date'].size > 0
162
+ next unless connheader['date'].empty?
166
163
  connheader['date'] = cv[1]
167
164
  connvalues += 1
168
165
  end
169
166
  end
170
167
  end
171
168
  end
172
- return nil if recipients.zero?
169
+ return nil unless recipients > 0
173
170
 
174
- require 'sisimai/string'
175
- require 'sisimai/smtp/status'
176
- dscontents.map do |e|
171
+ dscontents.each do |e|
177
172
  # Set default values if each value is empty.
178
173
  connheader.each_key { |a| e[a] ||= connheader[a] || '' }
179
-
180
- e['diagnosis'] = e['diagnosis'].gsub(/\\n/, ' ')
181
- e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
174
+ e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'].gsub(/\\n/, ' '))
182
175
 
183
176
  if e['status'].to_s.start_with?('5.0.0', '5.1.0', '4.0.0', '4.1.0')
184
177
  # Get other D.S.N. value from the error message
@@ -189,12 +182,12 @@ module Sisimai::Bite::Email
189
182
  errormessage = cv[1]
190
183
  end
191
184
  pseudostatus = Sisimai::SMTP::Status.find(errormessage)
192
- e['status'] = pseudostatus if pseudostatus.size > 0
185
+ e['status'] = pseudostatus unless pseudostatus.empty?
193
186
  end
194
187
 
195
188
  MessagesOf.each_key do |r|
196
189
  # Verify each regular expression of session errors
197
- next unless MessagesOf[r].find { |a| e['diagnosis'].include?(a) }
190
+ next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
198
191
  e['reason'] = r.to_s
199
192
  break
200
193
  end
@@ -31,15 +31,11 @@ module Sisimai::Bite::Email
31
31
  # part or nil if it failed to parse or
32
32
  # the arguments are missing
33
33
  def scan(mhead, mbody)
34
- return nil unless mhead
35
- return nil unless mbody
36
-
37
34
  # :'from' => %r/\AMAILER-DAEMON\z/,
38
35
  return nil unless mhead['return-path']
39
36
  return nil unless mhead['return-path'] == '<apps@sendgrid.net>'
40
37
  return nil unless mhead['subject'] == 'Undelivered Mail Returned to Sender'
41
38
 
42
- require 'sisimai/datetime'
43
39
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
44
40
  hasdivided = mbody.split("\n")
45
41
  havepassed = ['']
@@ -59,7 +55,7 @@ module Sisimai::Bite::Email
59
55
  havepassed << e
60
56
  p = havepassed[-2]
61
57
 
62
- if readcursor.zero?
58
+ if readcursor == 0
63
59
  # Beginning of the bounce message or delivery status part
64
60
  if e == StartingOf[:message][0]
65
61
  readcursor |= Indicators[:deliverystatus]
@@ -67,7 +63,7 @@ module Sisimai::Bite::Email
67
63
  end
68
64
  end
69
65
 
70
- if (readcursor & Indicators[:'message-rfc822']).zero?
66
+ if (readcursor & Indicators[:'message-rfc822']) == 0
71
67
  # Beginning of the original message part
72
68
  if e == StartingOf[:rfc822][0]
73
69
  readcursor |= Indicators[:'message-rfc822']
@@ -85,7 +81,7 @@ module Sisimai::Bite::Email
85
81
  rfc822list << e
86
82
  else
87
83
  # Before "message/rfc822"
88
- next if (readcursor & Indicators[:deliverystatus]).zero?
84
+ next if (readcursor & Indicators[:deliverystatus]) == 0
89
85
  next if e.empty?
90
86
 
91
87
  if connvalues == connheader.keys.size
@@ -153,7 +149,7 @@ module Sisimai::Bite::Email
153
149
 
154
150
  elsif cv = e.match(/\AArrival-Date:[ ]*(.+)\z/)
155
151
  # Arrival-Date: Wed, 29 Apr 2009 16:03:18 +0900
156
- next if connheader['date'].size > 0
152
+ next unless connheader['date'].empty?
157
153
  arrivaldate = cv[1]
158
154
 
159
155
  if cv = e.match(/\AArrival-Date: (\d{4})[-](\d{2})[-](\d{2}) (\d{2})[-](\d{2})[-](\d{2})\z/)
@@ -169,11 +165,9 @@ module Sisimai::Bite::Email
169
165
  end
170
166
  end
171
167
  end
172
- return nil if recipients.zero?
168
+ return nil unless recipients > 0
173
169
 
174
- require 'sisimai/string'
175
- require 'sisimai/smtp/status'
176
- dscontents.map do |e|
170
+ dscontents.each do |e|
177
171
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
178
172
 
179
173
  # Get the value of SMTP status code as a pseudo D.S.N.
@@ -186,7 +180,7 @@ module Sisimai::Bite::Email
186
180
  # Get the value of D.S.N. from the error message or the value of
187
181
  # Diagnostic-Code header.
188
182
  pseudostatus = Sisimai::SMTP::Status.find(e['diagnosis'])
189
- e['status'] = pseudostatus if pseudostatus.size > 0
183
+ e['status'] = pseudostatus unless pseudostatus.empty?
190
184
  end
191
185
 
192
186
  if e['action'] == 'expired'
@@ -196,7 +190,7 @@ module Sisimai::Bite::Email
196
190
  # Set pseudo Status code value if the value of Status is not
197
191
  # defined or 4.0.0 or 5.0.0.
198
192
  pseudostatus = Sisimai::SMTP::Status.code('expired')
199
- e['status'] = pseudostatus if pseudostatus.size > 0
193
+ e['status'] = pseudostatus unless pseudostatus.empty?
200
194
  end
201
195
  end
202
196
 
@@ -34,9 +34,6 @@ module Sisimai::Bite::Email
34
34
  # part or nil if it failed to parse or
35
35
  # the arguments are missing
36
36
  def scan(mhead, mbody)
37
- return nil unless mhead
38
- return nil unless mbody
39
-
40
37
  return nil unless mhead['subject'] =~ /(?:see transcript for details\z|\AWarning: )/
41
38
  unless mhead['subject'].downcase =~ /\A[ \t]*fwd?:/
42
39
  # Fwd: Returned mail: see transcript for details
@@ -67,7 +64,7 @@ module Sisimai::Bite::Email
67
64
  havepassed << e
68
65
  p = havepassed[-2]
69
66
 
70
- if readcursor.zero?
67
+ if readcursor == 0
71
68
  # Beginning of the bounce message or delivery status part
72
69
  if e.start_with?(StartingOf[:message][0])
73
70
  readcursor |= Indicators[:deliverystatus]
@@ -75,7 +72,7 @@ module Sisimai::Bite::Email
75
72
  end
76
73
  end
77
74
 
78
- if (readcursor & Indicators[:'message-rfc822']).zero?
75
+ if (readcursor & Indicators[:'message-rfc822']) == 0
79
76
  # Beginning of the original message part
80
77
  if e.start_with?(StartingOf[:rfc822][0], StartingOf[:rfc822][1])
81
78
  readcursor |= Indicators[:'message-rfc822']
@@ -93,7 +90,7 @@ module Sisimai::Bite::Email
93
90
  rfc822list << e
94
91
  else
95
92
  # Before "message/rfc822"
96
- next if (readcursor & Indicators[:deliverystatus]).zero?
93
+ next if (readcursor & Indicators[:deliverystatus]) == 0
97
94
  next if e.empty?
98
95
 
99
96
  if connvalues == connheader.keys.size
@@ -170,7 +167,7 @@ module Sisimai::Bite::Email
170
167
 
171
168
  elsif cv = e.match(/\AReporting-MTA:[ ]*(?:DNS|dns);[ ]*(.+)\z/)
172
169
  # Reporting-MTA: dns; mx.example.jp
173
- next if connheader['rhost'].size > 0
170
+ next unless connheader['rhost'].empty?
174
171
  connheader['rhost'] = cv[1].downcase
175
172
  connvalues += 1
176
173
 
@@ -184,7 +181,7 @@ module Sisimai::Bite::Email
184
181
 
185
182
  elsif cv = e.match(/\AArrival-Date:[ ]*(.+)\z/)
186
183
  # Arrival-Date: Wed, 29 Apr 2009 16:03:18 +0900
187
- next if connheader['date'].size > 0
184
+ next unless connheader['date'].empty?
188
185
  connheader['date'] = cv[1]
189
186
  connvalues += 1
190
187
  else
@@ -226,17 +223,16 @@ module Sisimai::Bite::Email
226
223
  end
227
224
  end
228
225
  end
229
- return nil if recipients.zero?
226
+ return nil unless recipients > 0
230
227
 
231
- require 'sisimai/string'
232
- dscontents.map do |e|
228
+ dscontents.each do |e|
233
229
  # Set default values if each value is empty.
234
230
  connheader.each_key { |a| e[a] ||= connheader[a] || '' }
235
231
 
236
232
  e['agent'] = self.smtpagent
237
233
  e['command'] ||= commandtxt
238
234
  if e['command'].empty?
239
- e['command'] = 'EHLO' if esmtpreply.size > 0
235
+ e['command'] = 'EHLO' unless esmtpreply.empty?
240
236
  end
241
237
 
242
238
  if anotherset['diagnosis']
@@ -32,9 +32,6 @@ module Sisimai::Bite::Email
32
32
  # part or nil if it failed to parse or
33
33
  # the arguments are missing
34
34
  def scan(mhead, mbody)
35
- return nil unless mhead
36
- return nil unless mbody
37
-
38
35
  # :'from' => %r/ [(]Mail Delivery System[)]\z/,
39
36
  return nil unless mhead['x-sef-processed']
40
37
  return nil unless mhead['x-mailer']
@@ -54,7 +51,7 @@ module Sisimai::Bite::Email
54
51
  havepassed << e
55
52
  p = havepassed[-2]
56
53
 
57
- if readcursor.zero?
54
+ if readcursor == 0
58
55
  # Beginning of the bounce message or delivery status part
59
56
  if e == StartingOf[:message][0]
60
57
  readcursor |= Indicators[:deliverystatus]
@@ -62,7 +59,7 @@ module Sisimai::Bite::Email
62
59
  end
63
60
  end
64
61
 
65
- if (readcursor & Indicators[:'message-rfc822']).zero?
62
+ if (readcursor & Indicators[:'message-rfc822']) == 0
66
63
  # Beginning of the original message part
67
64
  if e == StartingOf[:rfc822][0]
68
65
  readcursor |= Indicators[:'message-rfc822']
@@ -80,7 +77,7 @@ module Sisimai::Bite::Email
80
77
  rfc822list << e
81
78
  else
82
79
  # Before "message/rfc822"
83
- next if (readcursor & Indicators[:deliverystatus]).zero?
80
+ next if (readcursor & Indicators[:deliverystatus]) == 0
84
81
  next if e.empty?
85
82
 
86
83
  # Your message could not be sent.
@@ -135,10 +132,9 @@ module Sisimai::Bite::Email
135
132
  end
136
133
  end
137
134
  end
138
- return nil if recipients.zero?
135
+ return nil unless recipients > 0
139
136
 
140
- require 'sisimai/string'
141
- dscontents.map do |e|
137
+ dscontents.each do |e|
142
138
  e['agent'] = self.smtpagent
143
139
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
144
140
  e.each_key { |a| e[a] ||= '' }