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
@@ -29,9 +29,6 @@ module Sisimai::Bite::Email
29
29
  # part or nil if it failed to parse or
30
30
  # the arguments are missing
31
31
  def scan(mhead, mbody)
32
- return nil unless mhead
33
- return nil unless mbody
34
-
35
32
  # :received => %r/[ ][(]InterScanMSS[)][ ]with[ ]/,
36
33
  match = 0
37
34
  tryto = [
@@ -42,8 +39,8 @@ module Sisimai::Bite::Email
42
39
  '=?iso-2022-jp?B?GyRCJWEhPCVrR1s/LiRLPDpHVCQ3JF4kNyQ/GyhCDQo=?=',
43
40
  ]
44
41
  match += 1 if mhead['from'].start_with?('"InterScan MSS"')
45
- match += 1 if tryto.find { |a| mhead['subject'] == a }
46
- return nil if match.zero?
42
+ match += 1 if tryto.any? { |a| mhead['subject'] == a }
43
+ return nil unless match > 0
47
44
 
48
45
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
49
46
  hasdivided = mbody.split("\n")
@@ -54,7 +51,7 @@ module Sisimai::Bite::Email
54
51
  v = nil
55
52
 
56
53
  while e = hasdivided.shift do
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.start_with?(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
  # Sent <<< RCPT TO:<kijitora@example.co.jp>
@@ -120,10 +117,9 @@ module Sisimai::Bite::Email
120
117
  end
121
118
  end
122
119
  end
123
- return nil if recipients.zero?
120
+ return nil unless recipients > 0
124
121
 
125
- require 'sisimai/string'
126
- dscontents.map do |e|
122
+ dscontents.each do |e|
127
123
  e['agent'] = self.smtpagent
128
124
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
129
125
  e.each_key { |a| e[a] ||= '' }
@@ -37,19 +37,14 @@ 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
-
43
40
  # :'message-id' => %r/[@].+[.]ezweb[.]ne[.]jp[>]\z/,
44
41
  match = 0
45
42
  match += 1 if mhead['from'] =~ /no-reply[@].+[.]dion[.]ne[.]jp/
46
43
  match += 1 if mhead['reply-to'].to_s == 'no-reply@app.auone-net.jp'
47
- match += 1 if mhead['received'].find { |a| a.include?('ezweb.ne.jp (') }
48
- match += 1 if mhead['received'].find { |a| a.include?('.au.com (') }
49
- return nil if match.zero?
44
+ match += 1 if mhead['received'].any? { |a| a.include?('ezweb.ne.jp (') }
45
+ match += 1 if mhead['received'].any? { |a| a.include?('.au.com (') }
46
+ return nil unless match > 0
50
47
 
51
- require 'sisimai/string'
52
- require 'sisimai/address'
53
48
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
54
49
  hasdivided = mbody.split("\n")
55
50
  rfc822list = [] # (Array) Each line in message/rfc822 part string
@@ -59,7 +54,7 @@ module Sisimai::Bite::Email
59
54
  v = nil
60
55
 
61
56
  while e = hasdivided.shift do
62
- if readcursor.zero?
57
+ if readcursor == 0
63
58
  # Beginning of the bounce message or delivery status part
64
59
  if e =~ MarkingsOf[:message]
65
60
  readcursor |= Indicators[:deliverystatus]
@@ -67,7 +62,7 @@ module Sisimai::Bite::Email
67
62
  end
68
63
  end
69
64
 
70
- if (readcursor & Indicators[:'message-rfc822']).zero?
65
+ if (readcursor & Indicators[:'message-rfc822']) == 0
71
66
  # Beginning of the original message part
72
67
  if e == StartingOf[:rfc822][0]
73
68
  readcursor |= Indicators[:'message-rfc822']
@@ -85,7 +80,7 @@ module Sisimai::Bite::Email
85
80
  rfc822list << e
86
81
  else
87
82
  # Before "message/rfc822"
88
- next if (readcursor & Indicators[:deliverystatus]).zero?
83
+ next if (readcursor & Indicators[:deliverystatus]) == 0
89
84
  next if e.empty?
90
85
 
91
86
  v = dscontents[-1]
@@ -95,7 +90,7 @@ module Sisimai::Bite::Email
95
90
  # As their mailbox is full.
96
91
  if v['recipient']
97
92
  # There are multiple recipient addresses in the message body.
98
- push dscontents << Sisimai::Bite.DELIVERYSTATUS
93
+ dscontents << Sisimai::Bite.DELIVERYSTATUS
99
94
  v = dscontents[-1]
100
95
  end
101
96
 
@@ -115,10 +110,9 @@ module Sisimai::Bite::Email
115
110
  end
116
111
  end
117
112
  end
118
- return nil if recipients.zero?
113
+ return nil unless recipients > 0
119
114
 
120
- require 'sisimai/smtp/status'
121
- dscontents.map do |e|
115
+ dscontents.each do |e|
122
116
  e['agent'] = self.smtpagent
123
117
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
124
118
 
@@ -135,7 +129,7 @@ module Sisimai::Bite::Email
135
129
  # SMTP command is not RCPT
136
130
  MessagesOf.each_key do |r|
137
131
  # Verify each regular expression of session errors
138
- next unless MessagesOf[r].find { |a| e['diagnosis'].include?(a) }
132
+ next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
139
133
  e['reason'] = r.to_s
140
134
  break
141
135
  end
@@ -29,10 +29,8 @@ module Sisimai::Bite::Email
29
29
  # part or nil if it failed to parse or
30
30
  # the arguments are missing
31
31
  def scan(mhead, mbody)
32
- return nil unless mhead
33
- return nil unless mbody
34
32
  return nil unless mhead['subject'] == 'Message delivery has failed'
35
- return nil unless mhead['received'].find { |a| a.include?('(MAILFOUNDRY) id ') }
33
+ return nil unless mhead['received'].any? { |a| a.include?('(MAILFOUNDRY) id ') }
36
34
 
37
35
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
38
36
  hasdivided = mbody.split("\n")
@@ -43,7 +41,7 @@ module Sisimai::Bite::Email
43
41
  v = nil
44
42
 
45
43
  while e = hasdivided.shift do
46
- if readcursor.zero?
44
+ if readcursor == 0
47
45
  # Beginning of the bounce message or delivery status part
48
46
  if e == StartingOf[:message][0]
49
47
  readcursor |= Indicators[:deliverystatus]
@@ -51,7 +49,7 @@ module Sisimai::Bite::Email
51
49
  end
52
50
  end
53
51
 
54
- if (readcursor & Indicators[:'message-rfc822']).zero?
52
+ if (readcursor & Indicators[:'message-rfc822']) == 0
55
53
  # Beginning of the original message part
56
54
  if e == StartingOf[:rfc822][0]
57
55
  readcursor |= Indicators[:'message-rfc822']
@@ -69,7 +67,7 @@ module Sisimai::Bite::Email
69
67
  rfc822list << e
70
68
  else
71
69
  # Before "message/rfc822"
72
- next if (readcursor & Indicators[:deliverystatus]).zero?
70
+ next if (readcursor & Indicators[:deliverystatus]) == 0
73
71
  next if e.empty?
74
72
 
75
73
  # Unable to deliver message to: <kijitora@example.org>
@@ -105,10 +103,9 @@ module Sisimai::Bite::Email
105
103
  end
106
104
  end
107
105
  end
108
- return nil if recipients.zero?
106
+ return nil unless recipients > 0
109
107
 
110
- require 'sisimai/string'
111
- dscontents.map do |e|
108
+ dscontents.each do |e|
112
109
  e['agent'] = self.smtpagent
113
110
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
114
111
  e.each_key { |a| e[a] ||= '' }
@@ -30,11 +30,8 @@ module Sisimai::Bite::Email
30
30
  # part or nil if it failed to parse or
31
31
  # the arguments are missing
32
32
  def scan(mhead, mbody)
33
- return nil unless mhead
34
- return nil unless mbody
35
33
  return nil unless mhead['subject'].start_with?('Undeliverable Mail: "')
36
34
 
37
- require 'sisimai/mime'
38
35
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
39
36
  hasdivided = mbody.split("\n")
40
37
  rfc822list = [] # (Array) Each line in message/rfc822 part string
@@ -54,7 +51,7 @@ module Sisimai::Bite::Email
54
51
  end
55
52
 
56
53
  while e = hasdivided.shift do
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 =~ regularexp
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
  break if e =~ regularexp
85
82
 
86
83
  # Your message:
@@ -113,7 +110,7 @@ module Sisimai::Bite::Email
113
110
  # 550 5.1.1 User unknown
114
111
  v['diagnosis'] = e
115
112
 
116
- elsif v['diagnosis'].to_s.size > 0 && endoferror == false
113
+ elsif !v['diagnosis'].to_s.empty? && endoferror == false
117
114
  # Append error messages
118
115
  endoferror = true if e.start_with?(StartingOf[:rcpts][0])
119
116
  next if endoferror
@@ -145,10 +142,9 @@ module Sisimai::Bite::Email
145
142
  end
146
143
  end
147
144
  end
148
- return nil if recipients.zero?
145
+ return nil unless recipients > 0
149
146
 
150
- require 'sisimai/string'
151
- dscontents.map do |e|
147
+ dscontents.each do |e|
152
148
  e['agent'] = self.smtpagent
153
149
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
154
150
  e.each_key { |a| e[a] ||= '' }
@@ -64,9 +64,6 @@ module Sisimai::Bite::Email
64
64
  # part or nil if it failed to parse or
65
65
  # the arguments are missing
66
66
  def scan(mhead, mbody)
67
- return nil unless mhead
68
- return nil unless mbody
69
-
70
67
  return nil unless mhead['from'] =~ /[<]?mailer-daemon[@].*mail[.]ru[>]?/i
71
68
  return nil unless mhead['message-id'].end_with?('.mail.ru>', 'smailru.net>')
72
69
  return nil unless mhead['subject'] =~ %r{(?:
@@ -89,7 +86,7 @@ module Sisimai::Bite::Email
89
86
  v = nil
90
87
 
91
88
  while e = hasdivided.shift do
92
- if readcursor.zero?
89
+ if readcursor == 0
93
90
  # Beginning of the bounce message or delivery status part
94
91
  if e.start_with?(StartingOf[:message][0])
95
92
  readcursor |= Indicators[:deliverystatus]
@@ -97,7 +94,7 @@ module Sisimai::Bite::Email
97
94
  end
98
95
  end
99
96
 
100
- if (readcursor & Indicators[:'message-rfc822']).zero?
97
+ if (readcursor & Indicators[:'message-rfc822']) == 0
101
98
  # Beginning of the original message part
102
99
  if e == StartingOf[:rfc822][0]
103
100
  readcursor |= Indicators[:'message-rfc822']
@@ -116,7 +113,7 @@ module Sisimai::Bite::Email
116
113
  rfc822list << e
117
114
  else
118
115
  # Before "message/rfc822"
119
- next if (readcursor & Indicators[:deliverystatus]).zero?
116
+ next if (readcursor & Indicators[:deliverystatus]) == 0
120
117
  next if e.empty?
121
118
 
122
119
  # Это письмо создано автоматически
@@ -164,7 +161,7 @@ module Sisimai::Bite::Email
164
161
  end
165
162
  end
166
163
 
167
- if recipients.zero?
164
+ unless recipients > 0
168
165
  # Fallback for getting recipient addresses
169
166
  if mhead['x-failed-recipients']
170
167
  # X-Failed-Recipients: kijitora@example.jp
@@ -180,32 +177,31 @@ module Sisimai::Bite::Email
180
177
  end
181
178
  end
182
179
  end
183
- return nil if recipients.zero?
180
+ return nil unless recipients > 0
184
181
 
185
- if mhead['received'].size > 0
182
+ unless mhead['received'].empty?
186
183
  # Get the name of local MTA
187
184
  # Received: from marutamachi.example.org (c192128.example.net [192.0.2.128])
188
185
  if cv = mhead['received'][-1].match(/from[ \t]([^ ]+)/)
189
186
  localhost0 = cv[1]
190
187
  end
191
188
  end
192
- require 'sisimai/string'
193
189
 
194
- dscontents.map do |e|
190
+ dscontents.each do |e|
195
191
  # Set default values if each value is empty.
196
192
  e['lhost'] ||= localhost0
197
193
 
198
- if e['alterrors'].to_s.size > 0
194
+ unless e['alterrors'].to_s.empty?
199
195
  # Copy alternative error message
200
196
  e['diagnosis'] ||= e['alterrors']
201
197
  if e['diagnosis'].start_with?('-') || e['diagnosis'].end_with?('__')
202
198
  # Override the value of diagnostic code message
203
- e['diagnosis'] = e['alterrors'] if e['alterrors'].size > 0
199
+ e['diagnosis'] = e['alterrors'] unless e['alterrors'].empty?
204
200
  end
205
201
  e.delete('alterrors')
206
202
  end
207
203
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis']) || ''
208
- e['diagnosis'] = e['diagnosis'].sub(/\b__.+\z/, '')
204
+ e['diagnosis'].sub!(/\b__.+\z/, '')
209
205
 
210
206
  unless e['rhost']
211
207
  # Get the remote host name
@@ -216,7 +212,7 @@ module Sisimai::Bite::Email
216
212
 
217
213
  unless e['rhost']
218
214
  # Get localhost and remote host name from Received header.
219
- e['rhost'] = Sisimai::RFC5322.received(mhead['received'][-1]).pop if mhead['received'].size > 0
215
+ e['rhost'] = Sisimai::RFC5322.received(mhead['received'][-1]).pop unless mhead['received'].empty?
220
216
  end
221
217
  end
222
218
 
@@ -242,7 +238,7 @@ module Sisimai::Bite::Email
242
238
  # Verify each regular expression of session errors
243
239
  MessagesOf.each_key do |r|
244
240
  # Check each regular expression
245
- next unless MessagesOf[r].find { |a| e['diagnosis'].include?(a) }
241
+ next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
246
242
  e['reason'] = r.to_s
247
243
  break
248
244
  end
@@ -31,13 +31,10 @@ 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['x-nai-header']
37
35
  return nil unless mhead['x-nai-header'].start_with?('Modified by McAfee ')
38
36
  return nil unless mhead['subject'] == 'Delivery Status'
39
37
 
40
- require 'sisimai/address'
41
38
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
42
39
  hasdivided = mbody.split("\n")
43
40
  havepassed = ['']
@@ -53,7 +50,7 @@ module Sisimai::Bite::Email
53
50
  havepassed << e
54
51
  p = havepassed[-2]
55
52
 
56
- if readcursor.zero?
53
+ if readcursor == 0
57
54
  # Beginning of the bounce message or delivery status part
58
55
  if e.include?(StartingOf[:message][0])
59
56
  readcursor |= Indicators[:deliverystatus]
@@ -61,7 +58,7 @@ module Sisimai::Bite::Email
61
58
  end
62
59
  end
63
60
 
64
- if (readcursor & Indicators[:'message-rfc822']).zero?
61
+ if (readcursor & Indicators[:'message-rfc822']) == 0
65
62
  # Beginning of the original message part
66
63
  if e == StartingOf[:rfc822][0]
67
64
  readcursor |= Indicators[:'message-rfc822']
@@ -79,7 +76,7 @@ module Sisimai::Bite::Email
79
76
  rfc822list << e
80
77
  else
81
78
  # Before "message/rfc822"
82
- next if (readcursor & Indicators[:deliverystatus]).zero?
79
+ next if (readcursor & Indicators[:deliverystatus]) == 0
83
80
  next if e.empty?
84
81
 
85
82
  # Content-Type: text/plain; name="deliveryproblems.txt"
@@ -129,10 +126,9 @@ module Sisimai::Bite::Email
129
126
  end
130
127
  end
131
128
  end
132
- return nil if recipients.zero?
129
+ return nil unless recipients > 0
133
130
 
134
- require 'sisimai/string'
135
- dscontents.map do |e|
131
+ dscontents.each do |e|
136
132
  e['agent'] = smtpagent
137
133
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'] || diagnostic)
138
134
 
@@ -39,8 +39,6 @@ module Sisimai::Bite::Email
39
39
  # part or nil if it failed to parse or
40
40
  # the arguments are missing
41
41
  def scan(mhead, mbody)
42
- return nil unless mhead
43
- return nil unless mbody
44
42
  return nil unless mhead['x-msg-ref']
45
43
  return nil unless mhead['from'].include?('MAILER-DAEMON@messagelabs.com')
46
44
  return nil unless mhead['subject'].start_with?('Mail Delivery Failure')
@@ -65,7 +63,7 @@ module Sisimai::Bite::Email
65
63
  havepassed << e
66
64
  p = havepassed[-2]
67
65
 
68
- if readcursor.zero?
66
+ if readcursor == 0
69
67
  # Beginning of the bounce message or delivery status part
70
68
  if e.start_with?(StartingOf[:message][0])
71
69
  readcursor |= Indicators[:deliverystatus]
@@ -73,7 +71,7 @@ module Sisimai::Bite::Email
73
71
  end
74
72
  end
75
73
 
76
- if (readcursor & Indicators[:'message-rfc822']).zero?
74
+ if (readcursor & Indicators[:'message-rfc822']) == 0
77
75
  # Beginning of the original message part
78
76
  if e == StartingOf[:rfc822][0]
79
77
  readcursor |= Indicators[:'message-rfc822']
@@ -91,7 +89,7 @@ module Sisimai::Bite::Email
91
89
  rfc822list << e
92
90
  else
93
91
  # Before "message/rfc822"
94
- next if (readcursor & Indicators[:deliverystatus]).zero?
92
+ next if (readcursor & Indicators[:deliverystatus]) == 0
95
93
  next if e.empty?
96
94
 
97
95
  if connvalues == connheader.keys.size
@@ -162,23 +160,22 @@ module Sisimai::Bite::Email
162
160
  # Arrival-Date: Tue, 23 Dec 2014 20:39:34 +0000
163
161
  if cv = e.match(/\AReporting-MTA:[ ]*(?:DNS|dns);[ ]*(.+)\z/)
164
162
  # Reporting-MTA: dns; server-15.bemta-3.messagelabs.com
165
- next if connheader['lhost'].size > 0
163
+ next unless connheader['lhost'].empty?
166
164
  connheader['lhost'] = cv[1].downcase
167
165
  connvalues += 1
168
166
 
169
167
  elsif cv = e.match(/\AArrival-Date:[ ]*(.+)\z/)
170
168
  # Arrival-Date: Tue, 23 Dec 2014 20:39:34 +0000
171
- next if connheader['date'].size > 0
169
+ next unless connheader['date'].empty?
172
170
  connheader['date'] = cv[1]
173
171
  connvalues += 1
174
172
  end
175
173
  end
176
174
  end
177
175
  end
178
- return nil if recipients.zero?
176
+ return nil unless recipients > 0
179
177
 
180
- require 'sisimai/string'
181
- dscontents.map do |e|
178
+ dscontents.each do |e|
182
179
  # Set default values if each value is empty.
183
180
  connheader.each_key { |a| e[a] ||= connheader[a] || '' }
184
181
  e['command'] = commandset.shift || ''