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
@@ -37,11 +37,8 @@ module Sisimai::Bite::Email
37
37
  # part or nil if it failed to parse or
38
38
  # the arguments are missing
39
39
  def scan(mhead, mbody)
40
- return nil unless mhead
41
- return nil unless mbody
42
40
  return nil unless mhead['subject'].start_with?('DELIVERY FAILURE:')
43
41
 
44
- require 'sisimai/address'
45
42
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
46
43
  hasdivided = mbody.split("\n")
47
44
  rfc822list = [] # (Array) Each line in message/rfc822 part string
@@ -54,7 +51,7 @@ module Sisimai::Bite::Email
54
51
  while e = hasdivided.shift do
55
52
  next if e.empty?
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.start_with?(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
 
85
82
  # Your message
86
83
  #
@@ -126,27 +123,25 @@ module Sisimai::Bite::Email
126
123
  end
127
124
  end
128
125
  end
129
- return nil if recipients.zero?
126
+ return nil unless recipients > 0
130
127
 
131
- require 'sisimai/string'
132
- require 'sisimai/smtp/status'
133
- dscontents.map do |e|
128
+ dscontents.each do |e|
134
129
  e['agent'] = self.smtpagent
135
130
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
136
131
  e['recipient'] = Sisimai::Address.s3s4(e['recipient'])
137
132
 
138
133
  MessagesOf.each_key do |r|
139
134
  # Check each regular expression of Domino error messages
140
- next unless MessagesOf[r].find { |a| e['diagnosis'].include?(a) }
135
+ next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
141
136
  e['reason'] = r.to_s
142
137
  pseudostatus = Sisimai::SMTP::Status.code(r.to_s, false)
143
- e['status'] = pseudostatus if pseudostatus.size > 0
138
+ e['status'] = pseudostatus unless pseudostatus.empty?
144
139
  break
145
140
  end
146
141
  e.each_key { |a| e[a] ||= '' }
147
142
  end
148
143
 
149
- unless rfc822list.find { |a| a.start_with?('Subject:') }
144
+ unless rfc822list.any? { |a| a.start_with?('Subject:') }
150
145
  # Set the value of subjecttxt as a Subject if there is no original
151
146
  # message in the bounce mail.
152
147
  rfc822list << ('Subject: ' << subjecttxt)
@@ -31,8 +31,6 @@ 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
34
  return nil unless mhead['from'].start_with?('"Mail Delivery System"')
37
35
  return nil unless mhead['subject'] == 'Mail delivery failed: returning message to sender'
38
36
 
@@ -45,7 +43,7 @@ module Sisimai::Bite::Email
45
43
  v = nil
46
44
 
47
45
  while e = hasdivided.shift do
48
- if readcursor.zero?
46
+ if readcursor == 0
49
47
  # Beginning of the bounce message or delivery status part
50
48
  if e.start_with?(StartingOf[:message][0])
51
49
  readcursor |= Indicators[:deliverystatus]
@@ -53,7 +51,7 @@ module Sisimai::Bite::Email
53
51
  end
54
52
  end
55
53
 
56
- if (readcursor & Indicators[:'message-rfc822']).zero?
54
+ if (readcursor & Indicators[:'message-rfc822']) == 0
57
55
  # Beginning of the original message part
58
56
  if e.start_with?(StartingOf[:rfc822][0])
59
57
  readcursor |= Indicators[:'message-rfc822']
@@ -71,7 +69,7 @@ module Sisimai::Bite::Email
71
69
  rfc822list << e
72
70
  else
73
71
  # Before "message/rfc822"
74
- next if (readcursor & Indicators[:deliverystatus]).zero?
72
+ next if (readcursor & Indicators[:deliverystatus]) == 0
75
73
  next if e.empty?
76
74
 
77
75
  # The following address failed:
@@ -103,17 +101,15 @@ module Sisimai::Bite::Email
103
101
  end
104
102
  end
105
103
  end
106
- return nil if recipients.zero?
104
+ return nil unless recipients > 0
107
105
 
108
- require 'sisimai/string'
109
- dscontents.map do |e|
106
+ dscontents.each do |e|
110
107
  e['agent'] = self.smtpagent
111
- e['diagnosis'] = e['diagnosis'].to_s.gsub(/\A#{StartingOf[:error][0]}/, '')
112
- e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
108
+ e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'].to_s.gsub(/\A#{StartingOf[:error][0]}/, ''))
113
109
 
114
110
  MessagesOf.each_key do |r|
115
111
  # Verify each regular expression of session errors
116
- next unless MessagesOf[r].find { |a| e['diagnosis'].include?(a) }
112
+ next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
117
113
  e['reason'] = r.to_s
118
114
  break
119
115
  end
@@ -57,8 +57,6 @@ module Sisimai::Bite::Email
57
57
  # part or nil if it failed to parse or
58
58
  # the arguments are missing
59
59
  def scan(mhead, mbody)
60
- return nil unless mhead
61
- return nil unless mbody
62
60
  match = 0
63
61
  tryto = []
64
62
 
@@ -81,7 +79,7 @@ module Sisimai::Bite::Email
81
79
  throw :EXCHANGE_OR_NOT if match > 0
82
80
  end
83
81
 
84
- throw :EXCHANGE_OR_NOT if mhead['received'].size.zero?
82
+ throw :EXCHANGE_OR_NOT if mhead['received'].empty?
85
83
  mhead['received'].each do |e|
86
84
  # Received: by ***.**.** with Internet Mail Service (5.5.2657.72)
87
85
  next unless e.include?(' with Internet Mail Service (')
@@ -91,7 +89,7 @@ module Sisimai::Bite::Email
91
89
  break
92
90
  end
93
91
  end
94
- return nil if match.zero?
92
+ return nil unless match > 0
95
93
 
96
94
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
97
95
  hasdivided = mbody.split("\n")
@@ -109,7 +107,7 @@ module Sisimai::Bite::Email
109
107
  v = nil
110
108
 
111
109
  while e = hasdivided.shift do
112
- if readcursor.zero?
110
+ if readcursor == 0
113
111
  # Beginning of the bounce message or delivery status part
114
112
  if e.start_with?(StartingOf[:message][0])
115
113
  readcursor |= Indicators[:deliverystatus]
@@ -117,7 +115,7 @@ module Sisimai::Bite::Email
117
115
  end
118
116
  end
119
117
 
120
- if (readcursor & Indicators[:'message-rfc822']).zero?
118
+ if (readcursor & Indicators[:'message-rfc822']) == 0
121
119
  # Beginning of the original message part
122
120
  if e.start_with?(StartingOf[:rfc822][0])
123
121
  readcursor |= Indicators[:'message-rfc822']
@@ -135,7 +133,7 @@ module Sisimai::Bite::Email
135
133
  rfc822list << e
136
134
  else
137
135
  # Before "message/rfc822"
138
- next if (readcursor & Indicators[:deliverystatus]).zero?
136
+ next if (readcursor & Indicators[:deliverystatus]) == 0
139
137
  next if statuspart
140
138
 
141
139
  if connvalues == connheader.keys.size
@@ -192,13 +190,13 @@ module Sisimai::Bite::Email
192
190
  #
193
191
  if cv = e.match(/\A[ \t]+To:[ \t]+(.+)\z/)
194
192
  # To: shironeko@example.jp
195
- next if connheader['to'].size > 0
193
+ next unless connheader['to'].empty?
196
194
  connheader['to'] = cv[1]
197
195
  connvalues += 1
198
196
 
199
197
  elsif cv = e.match(/\A[ \t]+Subject:[ \t]+(.+)\z/)
200
198
  # Subject: ...
201
- next if connheader['subject'].size > 0
199
+ next unless connheader['subject'].empty?
202
200
  connheader['subject'] = cv[1]
203
201
  connvalues += 1
204
202
 
@@ -206,18 +204,16 @@ module Sisimai::Bite::Email
206
204
  e.match(%r|\A[ \t]+Sent:[ \t]+(\d+[/]\d+[/]\d+[ \t]+\d+:\d+:\d+[ \t].+)|)
207
205
  # Sent: Thu, 29 Apr 2010 18:14:35 +0000
208
206
  # Sent: 4/29/99 9:19:59 AM
209
- next if connheader['date'].size > 0
207
+ next unless connheader['date'].empty?
210
208
  connheader['date'] = cv[1]
211
209
  connvalues += 1
212
210
  end
213
211
  end
214
212
  end
215
213
  end
216
- return nil if recipients.zero?
214
+ return nil unless recipients > 0
217
215
 
218
- require 'sisimai/string'
219
- require 'sisimai/smtp/status'
220
- dscontents.map do |e|
216
+ dscontents.each do |e|
221
217
  if cv = e['diagnosis'].match(/\AMSEXCH:.+[ \t]*[(]([0-9A-F]{8})[)][ \t]*(.*)\z/)
222
218
  # MSEXCH:IMS:KIJITORA CAT:EXAMPLE:EXCHANGE 0 (000C05A6) Unknown Recipient
223
219
  capturedcode = cv[1]
@@ -229,7 +225,7 @@ module Sisimai::Bite::Email
229
225
  next unless ErrorCodes[r].index(capturedcode)
230
226
  e['reason'] = r.to_s
231
227
  pseudostatus = Sisimai::SMTP::Status.code(r.to_s)
232
- e['status'] = pseudostatus if pseudostatus.size > 0
228
+ e['status'] = pseudostatus unless pseudostatus.empty?
233
229
  break
234
230
  end
235
231
  e['diagnosis'] = errormessage
@@ -45,9 +45,6 @@ module Sisimai::Bite::Email
45
45
  # part or nil if it failed to parse or
46
46
  # the arguments are missing
47
47
  def scan(mhead, mbody)
48
- return nil unless mhead
49
- return nil unless mbody
50
-
51
48
  return nil unless mhead['subject'].start_with?('Undeliverable:')
52
49
  return nil unless mhead['content-language']
53
50
  return nil unless mhead['content-language'] =~ /\A[a-z]{2}(?:[-][A-Z]{2})?\z/
@@ -65,7 +62,7 @@ module Sisimai::Bite::Email
65
62
  v = nil
66
63
 
67
64
  while e = hasdivided.shift do
68
- if readcursor.zero?
65
+ if readcursor == 0
69
66
  # Beginning of the bounce message or delivery status part
70
67
  if e =~ MarkingsOf[:message]
71
68
  readcursor |= Indicators[:deliverystatus]
@@ -73,7 +70,7 @@ module Sisimai::Bite::Email
73
70
  end
74
71
  end
75
72
 
76
- if (readcursor & Indicators[:'message-rfc822']).zero?
73
+ if (readcursor & Indicators[:'message-rfc822']) == 0
77
74
  # Beginning of the original message part
78
75
  if e.start_with?(StartingOf[:rfc822][0])
79
76
  readcursor |= Indicators[:'message-rfc822']
@@ -91,7 +88,7 @@ module Sisimai::Bite::Email
91
88
  rfc822list << e
92
89
  else
93
90
  # Before "message/rfc822"
94
- next if (readcursor & Indicators[:deliverystatus]).zero?
91
+ next if (readcursor & Indicators[:deliverystatus]) == 0
95
92
 
96
93
  if connvalues == connheader.keys.size
97
94
  # Diagnostic information for administrators:
@@ -123,7 +120,7 @@ module Sisimai::Bite::Email
123
120
  v['status'] = cv[2]
124
121
  v['diagnosis'] = e
125
122
  else
126
- if v['diagnosis'].to_s.size > 0 && v['diagnosis'].end_with?('=')
123
+ if !v['diagnosis'].to_s.empty? && v['diagnosis'].end_with?('=')
127
124
  # Continued line of error messages
128
125
  v['diagnosis'] = v['diagnosis'].chomp('=')
129
126
  v['diagnosis'] << e
@@ -135,17 +132,16 @@ module Sisimai::Bite::Email
135
132
  # Generating server: mta22.neko.example.org
136
133
  if cv = e.match(MarkingsOf[:rhost])
137
134
  # Generating server: mta22.neko.example.org
138
- next if connheader['rhost'].size > 0
135
+ next unless connheader['rhost'].empty?
139
136
  connheader['rhost'] = cv[1]
140
137
  connvalues += 1
141
138
  end
142
139
  end
143
140
  end
144
141
  end
145
- return nil if recipients.zero?
142
+ return nil unless recipients > 0
146
143
 
147
- require 'sisimai/string'
148
- dscontents.map do |e|
144
+ dscontents.each do |e|
149
145
  if cv = e['diagnosis'].match(MarkingsOf[:error])
150
146
  # #550 5.1.1 RESOLVER.ADR.RecipNotFound; not found ##
151
147
  f = cv[1]
@@ -139,9 +139,6 @@ module Sisimai::Bite::Email
139
139
  # part or nil if it failed to parse or
140
140
  # the arguments are missing
141
141
  def scan(mhead, mbody)
142
- return nil unless mhead
143
- return nil unless mbody
144
-
145
142
  # :'message-id' => %r/\A[<]\w+[-]\w+[-]\w+[@].+\z/,
146
143
  return nil if mhead['from'] =~ /[@].+[.]mail[.]ru[>]?/
147
144
  return nil unless mhead['from'].start_with?('Mail Delivery System')
@@ -171,14 +168,13 @@ module Sisimai::Bite::Email
171
168
  if mhead['content-type']
172
169
  # Get the boundary string and set regular expression for matching with
173
170
  # the boundary string.
174
- require 'sisimai/mime'
175
171
  boundary00 = Sisimai::MIME.boundary(mhead['content-type']) || ''
176
172
  end
177
173
 
178
174
  while e = hasdivided.shift do
179
175
  break if e == StartingOf[:endof][0]
180
176
 
181
- if readcursor.zero?
177
+ if readcursor == 0
182
178
  # Beginning of the bounce message or delivery status part
183
179
  if e =~ MarkingsOf[:message]
184
180
  readcursor |= Indicators[:deliverystatus]
@@ -186,7 +182,7 @@ module Sisimai::Bite::Email
186
182
  end
187
183
  end
188
184
 
189
- if (readcursor & Indicators[:'message-rfc822']).zero?
185
+ if (readcursor & Indicators[:'message-rfc822']) == 0
190
186
  # Beginning of the original message part
191
187
  if e =~ MarkingsOf[:rfc822]
192
188
  readcursor |= Indicators[:'message-rfc822']
@@ -204,7 +200,7 @@ module Sisimai::Bite::Email
204
200
  rfc822list << e
205
201
  else
206
202
  # Before "message/rfc822"
207
- next if (readcursor & Indicators[:deliverystatus]).zero?
203
+ next if (readcursor & Indicators[:deliverystatus]) == 0
208
204
  next if e.empty?
209
205
 
210
206
  # This message was created automatically by mail delivery software.
@@ -266,7 +262,7 @@ module Sisimai::Bite::Email
266
262
  v['alterrors'] ||= ''
267
263
  v['alterrors'] << e + ' '
268
264
  else
269
- if boundary00.size > 0
265
+ if !boundary00.empty?
270
266
  # --NNNNNNNNNN-eximdsn-MMMMMMMMMM
271
267
  # Content-type: message/delivery-status
272
268
  # ...
@@ -292,7 +288,7 @@ module Sisimai::Bite::Email
292
288
  v['spec'] ||= cv[1].include?('@') ? 'SMTP' : 'X-UNIX'
293
289
  else
294
290
  # Error message ?
295
- if havepassed[:deliverystatus].zero?
291
+ if havepassed[:deliverystatus] == 0
296
292
  # Content-type: message/delivery-status
297
293
  havepassed[:deliverystatus] = 1 if e.start_with?(StartingOf[:deliverystatus][0])
298
294
  v['alterrors'] ||= ''
@@ -302,7 +298,7 @@ module Sisimai::Bite::Email
302
298
  else
303
299
  if dscontents.size == recipients
304
300
  # Error message
305
- next unless e.size
301
+ next if e.empty?
306
302
  v['diagnosis'] ||= ''
307
303
  v['diagnosis'] << e + ' '
308
304
  else
@@ -327,10 +323,10 @@ module Sisimai::Bite::Email
327
323
 
328
324
  if recipients > 0
329
325
  # Check "an undisclosed address", "unroutable address"
330
- dscontents.map do |q|
326
+ dscontents.each do |q|
331
327
  # Replace the recipient address with the value of "alias"
332
328
  next unless q['alias']
333
- next unless q['alias'].size > 0
329
+ next if q['alias'].empty?
334
330
  if q['recipient'].empty? || q['recipient'].include?('@') == false
335
331
  # The value of "recipient" is empty or does not include "@"
336
332
  q['recipient'] = q['alias']
@@ -356,9 +352,9 @@ module Sisimai::Bite::Email
356
352
  end
357
353
  end
358
354
  end
359
- return nil if recipients.zero?
355
+ return nil unless recipients > 0
360
356
 
361
- if mhead['received'].size > 0
357
+ unless mhead['received'].empty?
362
358
  # Get the name of local MTA
363
359
  # Received: from marutamachi.example.org (c192128.example.net [192.0.2.128])
364
360
  if cv = mhead['received'][-1].match(/from[ \t]([^ ]+)/)
@@ -366,17 +362,14 @@ module Sisimai::Bite::Email
366
362
  end
367
363
  end
368
364
 
369
- require 'sisimai/string'
370
- require 'sisimai/smtp/reply'
371
- require 'sisimai/smtp/status'
372
- dscontents.map do |e|
365
+ dscontents.each do |e|
373
366
  # Set default values if each value is empty.
374
367
  e['agent'] = self.smtpagent
375
368
  e['lhost'] ||= localhost0
376
369
 
377
370
  unless e['diagnosis']
378
371
  # Empty Diagnostic-Code: or error message
379
- if boundary00.size > 0
372
+ unless boundary00.empty?
380
373
  # --NNNNNNNNNN-eximdsn-MMMMMMMMMM
381
374
  # Content-type: message/delivery-status
382
375
  #
@@ -392,14 +385,14 @@ module Sisimai::Bite::Email
392
385
  e['diagnosis'] = dscontents[0]['diagnosis'] || ''
393
386
  e['spec'] ||= dscontents[0]['spec']
394
387
 
395
- if dscontents[0]['alterrors'].to_s.size > 0
388
+ unless dscontents[0]['alterrors'].to_s.empty?
396
389
  # The value of "alterrors" is also copied
397
390
  e['alterrors'] = dscontents[0]['alterrors']
398
391
  end
399
392
  end
400
393
  end
401
394
 
402
- if e['alterrors'].to_s.size > 0
395
+ unless e['alterrors'].to_s.empty?
403
396
  # Copy alternative error message
404
397
  if e['diagnosis'].nil? || e['diagnosis'].empty?
405
398
  e['diagnosis'] = e['alterrors']
@@ -407,7 +400,7 @@ module Sisimai::Bite::Email
407
400
 
408
401
  if e['diagnosis'].start_with?('-') || e['diagnosis'].end_with?('__')
409
402
  # Override the value of diagnostic code message
410
- e['diagnosis'] = e['alterrors'] if e['alterrors'].size > 0
403
+ e['diagnosis'] = e['alterrors'] unless e['alterrors'].empty?
411
404
  else
412
405
  # Check the both value and try to match
413
406
  if e['diagnosis'].size < e['alterrors'].size
@@ -421,7 +414,7 @@ module Sisimai::Bite::Email
421
414
  e.delete('alterrors')
422
415
  end
423
416
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis']) || ''
424
- e['diagnosis'] = e['diagnosis'].sub(/\b__.+\z/, '')
417
+ e['diagnosis'].sub!(/\b__.+\z/, '')
425
418
 
426
419
  unless e['rhost']
427
420
  # Get the remote host name
@@ -432,7 +425,7 @@ module Sisimai::Bite::Email
432
425
 
433
426
  unless e['rhost']
434
427
  # Get localhost and remote host name from Received header.
435
- e['rhost'] = Sisimai::RFC5322.received(mhead['received'][-1]).pop if mhead['received'].size > 0
428
+ e['rhost'] = Sisimai::RFC5322.received(mhead['received'][-1]).pop unless mhead['received'].empty?
436
429
  end
437
430
  end
438
431
 
@@ -458,14 +451,14 @@ module Sisimai::Bite::Email
458
451
  # Verify each regular expression of session errors
459
452
  MessagesOf.each_key do |r|
460
453
  # Check each regular expression
461
- next unless MessagesOf[r].find { |a| e['diagnosis'].include?(a) }
454
+ next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
462
455
  e['reason'] = r.to_s
463
456
  break
464
457
  end
465
458
 
466
459
  unless e['reason']
467
460
  # The reason "expired"
468
- e['reason'] = 'expired' if DelayedFor.find { |a| e['diagnosis'].include?(a) }
461
+ e['reason'] = 'expired' if DelayedFor.any? { |a| e['diagnosis'].include?(a) }
469
462
  end
470
463
  end
471
464
  end
@@ -503,7 +496,7 @@ module Sisimai::Bite::Email
503
496
  break
504
497
  end
505
498
 
506
- s1 = sv[0, 1].to_i if sv.size > 0
499
+ s1 = sv[0, 1].to_i unless sv.empty?
507
500
  v1 = s1 + r1
508
501
  v1 << e['status'][0, 1].to_i if e['status']
509
502