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
@@ -54,22 +54,17 @@ module Sisimai::Bite::Email
54
54
  # part or nil if it failed to parse or
55
55
  # the arguments are missing
56
56
  def scan(mhead, mbody)
57
- return nil unless mhead
58
- return nil unless mbody
59
-
60
57
  match = 0
61
58
  match += 1 if mhead['from'].include?('Postmaster@ezweb.ne.jp')
62
59
  match += 1 if mhead['from'].include?('Postmaster@au.com')
63
60
  match += 1 if mhead['subject'] == 'Mail System Error - Returned Mail'
64
- match += 1 if mhead['received'].find { |a| a.include?('ezweb.ne.jp (EZweb Mail) with') }
65
- match += 1 if mhead['received'].find { |a| a.include?('.au.com (') }
61
+ match += 1 if mhead['received'].any? { |a| a.include?('ezweb.ne.jp (EZweb Mail) with') }
62
+ match += 1 if mhead['received'].any? { |a| a.include?('.au.com (') }
66
63
  if mhead['message-id']
67
64
  match += 1 if mhead['message-id'].end_with?('.ezweb.ne.jp>', '.au.com>')
68
65
  end
69
66
  return nil if match < 2
70
67
 
71
- require 'sisimai/string'
72
- require 'sisimai/address'
73
68
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
74
69
  hasdivided = mbody.split("\n")
75
70
  rfc822list = [] # (Array) Each line in message/rfc822 part string
@@ -82,23 +77,19 @@ module Sisimai::Bite::Email
82
77
  if mhead['content-type']
83
78
  # Get the boundary string and set regular expression for matching with
84
79
  # the boundary string.
85
- require 'sisimai/mime'
86
80
  b0 = Sisimai::MIME.boundary(mhead['content-type'], 1)
87
- if b0.size > 0
88
- # Convert to regular expression
89
- rxboundary = Regexp.new('\A' << Regexp.escape(b0) << '\z')
90
- end
81
+ rxboundary = Regexp.new('\A' << Regexp.escape(b0) << '\z') unless b0.empty?
91
82
  end
92
83
  rxmessages = []
93
- ReFailures.each_key { |a| rxmessages.concat(ReFailures[a]) }
84
+ ReFailures.each_value { |a| rxmessages << a }
94
85
 
95
86
  while e = hasdivided.shift do
96
- if readcursor.zero?
87
+ if readcursor == 0
97
88
  # Beginning of the bounce message or delivery status part
98
89
  readcursor |= Indicators[:deliverystatus] if e =~ MarkingsOf[:message]
99
90
  end
100
91
 
101
- if (readcursor & Indicators[:'message-rfc822']).zero?
92
+ if (readcursor & Indicators[:'message-rfc822']) == 0
102
93
  # Beginning of the original message part
103
94
  if e =~ MarkingsOf[:rfc822] || e =~ rxboundary
104
95
  readcursor |= Indicators[:'message-rfc822']
@@ -116,7 +107,7 @@ module Sisimai::Bite::Email
116
107
  rfc822list << e
117
108
  else
118
109
  # Before "message/rfc822"
119
- next if (readcursor & Indicators[:deliverystatus]).zero?
110
+ next if (readcursor & Indicators[:deliverystatus]) == 0
120
111
  next if e.empty?
121
112
 
122
113
  # The user(s) account is disabled.
@@ -138,7 +129,7 @@ module Sisimai::Bite::Email
138
129
 
139
130
  if v['recipient']
140
131
  # There are multiple recipient addresses in the message body.
141
- push dscontents << Sisimai::Bite.DELIVERYSTATUS
132
+ dscontents << Sisimai::Bite.DELIVERYSTATUS
142
133
  v = dscontents[-1]
143
134
  end
144
135
 
@@ -172,7 +163,7 @@ module Sisimai::Bite::Email
172
163
  v['command'] = cv[1]
173
164
  else
174
165
  # Check error message
175
- if rxmessages.find { |a| e =~ a }
166
+ if rxmessages.any? { |a| e =~ a }
176
167
  # Check with regular expressions of each error
177
168
  v['diagnosis'] ||= ''
178
169
  v['diagnosis'] << ' ' << e
@@ -185,15 +176,15 @@ module Sisimai::Bite::Email
185
176
  end
186
177
  end
187
178
  end
188
- return nil if recipients.zero?
179
+ return nil unless recipients > 0
189
180
 
190
- dscontents.map do |e|
191
- if e['alterrors'].to_s.size > 0
181
+ dscontents.each do |e|
182
+ unless e['alterrors'].to_s.empty?
192
183
  # Copy alternative error message
193
184
  e['diagnosis'] ||= e['alterrors']
194
185
  if e['diagnosis'].start_with?('-') || e['diagnosis'].end_with?('__')
195
186
  # Override the value of diagnostic code message
196
- e['diagnosis'] = e['alterrors'] if e['alterrors'].size > 0
187
+ e['diagnosis'] = e['alterrors'] unless e['alterrors'].empty?
197
188
  end
198
189
  e.delete('alterrors')
199
190
  end
@@ -87,8 +87,6 @@ module Sisimai::Bite::Email
87
87
  # part or nil if it failed to parse or
88
88
  # the arguments are missing
89
89
  def scan(mhead, mbody)
90
- return nil unless mhead
91
- return nil unless mbody
92
90
  return nil unless mhead['from'] == 'Facebook <mailer-daemon@mx.facebook.com>'
93
91
  return nil unless mhead['subject'] == 'Sorry, your message could not be delivered'
94
92
 
@@ -112,7 +110,7 @@ module Sisimai::Bite::Email
112
110
  havepassed << e
113
111
  p = havepassed[-2]
114
112
 
115
- if readcursor.zero?
113
+ if readcursor == 0
116
114
  # Beginning of the bounce message or delivery status part
117
115
  if e == StartingOf[:message][0]
118
116
  readcursor |= Indicators[:deliverystatus]
@@ -120,7 +118,7 @@ module Sisimai::Bite::Email
120
118
  end
121
119
  end
122
120
 
123
- if (readcursor & Indicators[:'message-rfc822']).zero?
121
+ if (readcursor & Indicators[:'message-rfc822']) == 0
124
122
  # Beginning of the original message part
125
123
  if e == StartingOf[:rfc822][0]
126
124
  readcursor |= Indicators[:'message-rfc822']
@@ -138,7 +136,7 @@ module Sisimai::Bite::Email
138
136
  rfc822list << e
139
137
  else
140
138
  # Before "message/rfc822"
141
- next if (readcursor & Indicators[:deliverystatus]).zero?
139
+ next if (readcursor & Indicators[:deliverystatus]) == 0
142
140
  next if e.empty?
143
141
 
144
142
  if connvalues == connheader.keys.size
@@ -193,13 +191,13 @@ module Sisimai::Bite::Email
193
191
  else
194
192
  if cv = e.match(/\AReporting-MTA:[ ]*(?:DNS|dns);[ ]*(.+)\z/)
195
193
  # Reporting-MTA: dns; mx.example.jp
196
- next if connheader['lhost'].size > 0
194
+ next unless connheader['lhost'].empty?
197
195
  connheader['lhost'] = cv[1].downcase
198
196
  connvalues += 1
199
197
 
200
198
  elsif cv = e.match(/\AArrival-Date:[ ]*(.+)\z/)
201
199
  # Arrival-Date: Wed, 29 Apr 2009 16:03:18 +0900
202
- next if connheader['date'].size > 0
200
+ next unless connheader['date'].empty?
203
201
  connheader['date'] = cv[1]
204
202
  connvalues += 1
205
203
  end
@@ -207,10 +205,9 @@ module Sisimai::Bite::Email
207
205
  end
208
206
  end
209
207
  end
210
- return nil if recipients.zero?
211
- require 'sisimai/string'
208
+ return nil unless recipients > 0
212
209
 
213
- dscontents.map do |e|
210
+ dscontents.each do |e|
214
211
  e['lhost'] ||= connheader['lhost']
215
212
  e['agent'] = self.smtpagent
216
213
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
@@ -61,8 +61,6 @@ module Sisimai::Bite::Email
61
61
  # part or nil if it failed to parse or
62
62
  # the arguments are missing
63
63
  def scan(mhead, mbody)
64
- return nil unless mhead
65
- return nil unless mbody
66
64
  return nil unless mhead['x-mlserver']
67
65
  return nil unless mhead['from'] =~ /.+[-]admin[@].+/
68
66
  return nil unless mhead['message-id'] =~ /\A[<]\d+[.]FML.+[@].+[>]\z/
@@ -77,7 +75,7 @@ module Sisimai::Bite::Email
77
75
 
78
76
  readcursor |= Indicators[:deliverystatus]
79
77
  while e = hasdivided.shift do
80
- if (readcursor & Indicators[:'message-rfc822']).zero?
78
+ if (readcursor & Indicators[:'message-rfc822']) == 0
81
79
  # Beginning of the original message part
82
80
  if e == StartingOf[:rfc822][0]
83
81
  readcursor |= Indicators[:'message-rfc822']
@@ -100,7 +98,7 @@ module Sisimai::Bite::Email
100
98
  rfc822list << e.lstrip
101
99
  else
102
100
  # Before "message/rfc822"
103
- next if (readcursor & Indicators[:deliverystatus]).zero?
101
+ next if (readcursor & Indicators[:deliverystatus]) == 0
104
102
  next if e.empty?
105
103
 
106
104
  # Duplicated Message-ID in <2ndml@example.com>.
@@ -125,10 +123,9 @@ module Sisimai::Bite::Email
125
123
  end
126
124
  end
127
125
  end
128
- return nil if recipients.zero?
126
+ return nil unless recipients > 0
129
127
 
130
- require 'sisimai/string'
131
- dscontents.map do |e|
128
+ dscontents.each do |e|
132
129
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
133
130
  e['agent'] = self.smtpagent
134
131
  e.each_key { |a| e[a] ||= '' }
@@ -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
  # :from => %r/\AMAILER-DAEMON[@]/,
41
38
  # :subject => %r/\AMail delivery failed: returning message to sender\z/,
42
39
  return nil unless mhead['x-gmx-antispam']
@@ -50,7 +47,7 @@ module Sisimai::Bite::Email
50
47
  v = nil
51
48
 
52
49
  while e = hasdivided.shift do
53
- if readcursor.zero?
50
+ if readcursor == 0
54
51
  # Beginning of the bounce message or delivery status part
55
52
  if e.start_with?(StartingOf[:message][0])
56
53
  readcursor |= Indicators[:deliverystatus]
@@ -58,7 +55,7 @@ module Sisimai::Bite::Email
58
55
  end
59
56
  end
60
57
 
61
- if (readcursor & Indicators[:'message-rfc822']).zero?
58
+ if (readcursor & Indicators[:'message-rfc822']) == 0
62
59
  # Beginning of the original message part
63
60
  if e.start_with?(StartingOf[:rfc822][0])
64
61
  readcursor |= Indicators[:'message-rfc822']
@@ -76,7 +73,7 @@ module Sisimai::Bite::Email
76
73
  rfc822list << e
77
74
  else
78
75
  # Before "message/rfc822"
79
- next if (readcursor & Indicators[:deliverystatus]).zero?
76
+ next if (readcursor & Indicators[:deliverystatus]) == 0
80
77
  next if e.empty?
81
78
 
82
79
  # This message was created automatically by mail delivery software.
@@ -131,17 +128,15 @@ module Sisimai::Bite::Email
131
128
  end
132
129
  end
133
130
  end
134
- return nil if recipients.zero?
131
+ return nil unless recipients > 0
135
132
 
136
- require 'sisimai/string'
137
- dscontents.map do |e|
133
+ dscontents.each do |e|
138
134
  e['agent'] = self.smtpagent
139
- e['diagnosis'] = e['diagnosis'].gsub(/\\n/, ' ')
140
- e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
135
+ e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'].gsub(/\\n/, ' '))
141
136
 
142
137
  MessagesOf.each_key do |r|
143
138
  # Verify each regular expression of session errors
144
- next unless MessagesOf[r].find { |a| e['diagnosis'].include?(a) }
139
+ next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
145
140
  e['reason'] = r.to_s
146
141
  break
147
142
  end
@@ -121,9 +121,6 @@ module Sisimai::Bite::Email
121
121
  # part or nil if it failed to parse or
122
122
  # the arguments are missing
123
123
  def scan(mhead, mbody)
124
- return nil unless mhead
125
- return nil unless mbody
126
-
127
124
  # Google Mail
128
125
  # From: Mail Delivery Subsystem <mailer-daemon@googlemail.com>
129
126
  # Received: from vw-in-f109.1e100.net [74.125.113.109] by ...
@@ -174,7 +171,6 @@ module Sisimai::Bite::Email
174
171
  return nil unless mhead['from'].end_with?('<mailer-daemon@googlemail.com>')
175
172
  return nil unless mhead['subject'].start_with?('Delivery Status Notification')
176
173
 
177
- require 'sisimai/address'
178
174
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
179
175
  hasdivided = mbody.split("\n")
180
176
  rfc822list = [] # (Array) Each line in message/rfc822 part string
@@ -185,12 +181,12 @@ module Sisimai::Bite::Email
185
181
  v = nil
186
182
 
187
183
  while e = hasdivided.shift do
188
- if readcursor.zero?
184
+ if readcursor == 0
189
185
  # Beginning of the bounce message or delivery status part
190
186
  readcursor |= Indicators[:deliverystatus] if e.start_with?(StartingOf[:message][0])
191
187
  end
192
188
 
193
- if (readcursor & Indicators[:'message-rfc822']).zero?
189
+ if (readcursor & Indicators[:'message-rfc822']) == 0
194
190
  # Beginning of the original message part
195
191
  if e =~ MarkingsOf[:rfc822]
196
192
  readcursor |= Indicators[:'message-rfc822']
@@ -208,7 +204,7 @@ module Sisimai::Bite::Email
208
204
  rfc822list << e
209
205
  else
210
206
  # Before "message/rfc822"
211
- next if (readcursor & Indicators[:deliverystatus]).zero?
207
+ next if (readcursor & Indicators[:deliverystatus]) == 0
212
208
  next if e.empty?
213
209
 
214
210
  # Technical details of permanent failure:=20
@@ -247,11 +243,9 @@ module Sisimai::Bite::Email
247
243
  end
248
244
  end
249
245
  end
250
- return nil if recipients.zero?
246
+ return nil unless recipients > 0
251
247
 
252
- require 'sisimai/string'
253
- require 'sisimai/smtp/status'
254
- dscontents.map do |e|
248
+ dscontents.each do |e|
255
249
  e['agent'] = self.smtpagent
256
250
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
257
251
 
@@ -283,7 +277,7 @@ module Sisimai::Bite::Email
283
277
  # No state code
284
278
  MessagesOf.each_key do |r|
285
279
  # Verify each regular expression of session errors
286
- next unless MessagesOf[r].find { |a| e['diagnosis'].include?(a) }
280
+ next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
287
281
  e['reason'] = r.to_s
288
282
  break
289
283
  end
@@ -35,14 +35,10 @@ module Sisimai::Bite::Email
35
35
  # part or nil if it failed to parse or
36
36
  # the arguments are missing
37
37
  def scan(mhead, mbody)
38
- return nil unless mhead
39
- return nil unless mbody
40
-
41
38
  return nil unless mhead['from'].end_with?('<mailer-daemon@googlemail.com>')
42
39
  return nil unless mhead['subject'].start_with?('Delivery Status Notification')
43
40
  return nil unless mhead['x-gm-message-state']
44
41
 
45
- require 'sisimai/address'
46
42
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
47
43
  hasdivided = mbody.split("\n")
48
44
  rfc822list = [] # (Array) Each line in message/rfc822 part string
@@ -60,12 +56,12 @@ module Sisimai::Bite::Email
60
56
  v = nil
61
57
 
62
58
  while e = hasdivided.shift do
63
- if readcursor.zero?
59
+ if readcursor == 0
64
60
  # Beginning of the bounce message or delivery status part
65
61
  readcursor |= Indicators[:deliverystatus] if e =~ MarkingsOf[:message]
66
62
  end
67
63
 
68
- if (readcursor & Indicators[:'message-rfc822']).zero?
64
+ if (readcursor & Indicators[:'message-rfc822']) == 0
69
65
  # Beginning of the original message part
70
66
  if e =~ MarkingsOf[:rfc822]
71
67
  readcursor |= Indicators[:'message-rfc822']
@@ -83,7 +79,7 @@ module Sisimai::Bite::Email
83
79
  rfc822list << e
84
80
  else
85
81
  # Before "message/rfc822"
86
- next if (readcursor & Indicators[:deliverystatus]).zero?
82
+ next if (readcursor & Indicators[:deliverystatus]) == 0
87
83
 
88
84
  if connvalues == connheader.keys.size
89
85
  # Final-Recipient: rfc822; kijitora@example.de
@@ -127,7 +123,7 @@ module Sisimai::Bite::Email
127
123
  v['diagnosis'] = cv[2]
128
124
  else
129
125
  # Append error messages continued from the previous line
130
- if endoferror == false && v['diagnosis'].to_s.size > 0
126
+ if endoferror == false && !v['diagnosis'].to_s.empty?
131
127
  endoferror ||= true if e.empty?
132
128
  endoferror ||= true if e.start_with?('--')
133
129
 
@@ -144,13 +140,13 @@ module Sisimai::Bite::Email
144
140
  # X-Original-Message-ID: <06C1ED5C-7E02-4036-AEE1-AA448067FB2C@example.jp>
145
141
  if cv = e.match(/\AReporting-MTA:[ ]*(?:DNS|dns);[ ]*(.+)\z/)
146
142
  # Reporting-MTA: dns; mx.example.jp
147
- next if connheader['lhost'].size > 0
143
+ next unless connheader['lhost'].empty?
148
144
  connheader['lhost'] = cv[1].downcase
149
145
  connvalues += 1
150
146
 
151
147
  elsif cv = e.match(/\AArrival-Date:[ ]*(.+)\z/)
152
148
  # Arrival-Date: Wed, 29 Apr 2009 16:03:18 +0900
153
- next if connheader['date'].size > 0
149
+ next unless connheader['date'].empty?
154
150
  connheader['date'] = cv[1]
155
151
  connvalues += 1
156
152
  else
@@ -193,12 +189,9 @@ module Sisimai::Bite::Email
193
189
  end
194
190
  end
195
191
  end
196
- return nil if recipients.zero?
192
+ return nil unless recipients > 0
197
193
 
198
- require 'sisimai/string'
199
- require 'sisimai/smtp/reply'
200
- require 'sisimai/smtp/status'
201
- dscontents.map do |e|
194
+ dscontents.each do |e|
202
195
  # Set default values if each value is empty.
203
196
  connheader.each_key { |a| e[a] ||= connheader[a] || '' }
204
197
 
@@ -219,7 +212,7 @@ module Sisimai::Bite::Email
219
212
  if e['status'] == '' || e['status'].start_with?('4.0.0', '5.0.0')
220
213
  # Check the value of D.S.N. in anotherset
221
214
  as = Sisimai::SMTP::Status.find(anotherset['diagnosis'])
222
- if as.size > 0 && as[-3, 3] != '0.0'
215
+ if !as.empty? && as[-3, 3] != '0.0'
223
216
  # The D.S.N. is neither an empty nor *.0.0
224
217
  e['status'] = as
225
218
  end
@@ -228,7 +221,7 @@ module Sisimai::Bite::Email
228
221
  if e['replycode'].empty? || e['replycode'].start_with?('400', '500')
229
222
  # Check the value of SMTP reply code in anotherset
230
223
  ar = Sisimai::SMTP::Reply.find(anotherset['diagnosis'])
231
- if ar.size > 0 && ar[-2, 2].to_i != 0
224
+ if !ar.empty? && ar[-2, 2].to_i != 0
232
225
  # The SMTP reply code is neither an empty nor *00
233
226
  e['replycode'] = ar
234
227
  end
@@ -246,7 +239,7 @@ module Sisimai::Bite::Email
246
239
 
247
240
  MessagesOf.each_key do |r|
248
241
  # Guess an reason of the bounce
249
- next unless MessagesOf[r].find { |a| e['diagnosis'].include?(a) }
242
+ next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
250
243
  e['reason'] = r.to_s
251
244
  break
252
245
  end
@@ -46,13 +46,10 @@ 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
  match = 0
53
50
  match += 1 if mhead['subject'] =~ /\AUndeliverable Mail[ ]*\z/
54
51
  match += 1 if mhead['x-mailer'].to_s.start_with?('<SMTP32 v')
55
- return nil if match.zero?
52
+ return nil unless match > 0
56
53
 
57
54
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
58
55
  hasdivided = mbody.split("\n")
@@ -63,7 +60,7 @@ module Sisimai::Bite::Email
63
60
  v = nil
64
61
 
65
62
  while e = hasdivided.shift do
66
- if readcursor.zero?
63
+ if readcursor == 0
67
64
  # Beginning of the bounce message or delivery status part
68
65
  if e == StartingOf[:message][0]
69
66
  readcursor |= Indicators[:deliverystatus]
@@ -71,7 +68,7 @@ module Sisimai::Bite::Email
71
68
  end
72
69
  end
73
70
 
74
- if (readcursor & Indicators[:'message-rfc822']).zero?
71
+ if (readcursor & Indicators[:'message-rfc822']) == 0
75
72
  # Beginning of the original message part
76
73
  if e == StartingOf[:rfc822][0]
77
74
  readcursor |= Indicators[:'message-rfc822']
@@ -123,13 +120,12 @@ module Sisimai::Bite::Email
123
120
  end
124
121
  end
125
122
  end
126
- return nil if recipients.zero?
123
+ return nil unless recipients > 0
127
124
 
128
- require 'sisimai/string'
129
- dscontents.map do |e|
125
+ dscontents.each do |e|
130
126
  e['agent'] = self.smtpagent
131
127
 
132
- if e['alterrors'].to_s.size > 0
128
+ unless e['alterrors'].to_s.empty?
133
129
  # Copy alternative error message
134
130
  e['diagnosis'] = if e['diagnosis']
135
131
  e['alterrors'] + ' ' + e['diagnosis']