sisimai 4.16.0-java → 4.17.0-java

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

Potentially problematic release.


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

Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/ANALYTICAL-PRECISION +7 -7
  4. data/Changes +15 -0
  5. data/Makefile +1 -1
  6. data/README.md +30 -28
  7. data/lib/sisimai.rb +20 -1
  8. data/lib/sisimai/address.rb +28 -9
  9. data/lib/sisimai/arf.rb +37 -46
  10. data/lib/sisimai/data.rb +67 -43
  11. data/lib/sisimai/datetime.rb +210 -210
  12. data/lib/sisimai/mda.rb +30 -30
  13. data/lib/sisimai/message.rb +3 -5
  14. data/lib/sisimai/msp/de/einsundeins.rb +14 -42
  15. data/lib/sisimai/msp/de/gmx.rb +17 -44
  16. data/lib/sisimai/msp/jp/biglobe.rb +15 -44
  17. data/lib/sisimai/msp/jp/ezweb.rb +20 -50
  18. data/lib/sisimai/msp/jp/kddi.rb +16 -43
  19. data/lib/sisimai/msp/ru/mailru.rb +20 -48
  20. data/lib/sisimai/msp/ru/yandex.rb +16 -50
  21. data/lib/sisimai/msp/uk/messagelabs.rb +17 -51
  22. data/lib/sisimai/msp/us/amazonses.rb +18 -40
  23. data/lib/sisimai/msp/us/amazonworkmail.rb +17 -35
  24. data/lib/sisimai/msp/us/aol.rb +17 -41
  25. data/lib/sisimai/msp/us/bigfoot.rb +15 -48
  26. data/lib/sisimai/msp/us/facebook.rb +63 -90
  27. data/lib/sisimai/msp/us/google.rb +15 -44
  28. data/lib/sisimai/msp/us/office365.rb +21 -46
  29. data/lib/sisimai/msp/us/outlook.rb +17 -50
  30. data/lib/sisimai/msp/us/receivingses.rb +20 -43
  31. data/lib/sisimai/msp/us/sendgrid.rb +13 -37
  32. data/lib/sisimai/msp/us/verizon.rb +30 -74
  33. data/lib/sisimai/msp/us/yahoo.rb +12 -40
  34. data/lib/sisimai/msp/us/zoho.rb +14 -42
  35. data/lib/sisimai/mta/activehunter.rb +11 -40
  36. data/lib/sisimai/mta/apachejames.rb +18 -40
  37. data/lib/sisimai/mta/courier.rb +20 -57
  38. data/lib/sisimai/mta/domino.rb +24 -56
  39. data/lib/sisimai/mta/exchange.rb +26 -54
  40. data/lib/sisimai/mta/exim.rb +20 -39
  41. data/lib/sisimai/mta/imailserver.rb +26 -71
  42. data/lib/sisimai/mta/interscanmss.rb +26 -44
  43. data/lib/sisimai/mta/mailfoundry.rb +12 -42
  44. data/lib/sisimai/mta/mailmarshalsmtp.rb +13 -43
  45. data/lib/sisimai/mta/mcafee.rb +17 -46
  46. data/lib/sisimai/mta/messagingserver.rb +14 -47
  47. data/lib/sisimai/mta/mfilter.rb +12 -35
  48. data/lib/sisimai/mta/mxlogic.rb +18 -42
  49. data/lib/sisimai/mta/notes.rb +22 -45
  50. data/lib/sisimai/mta/opensmtpd.rb +18 -48
  51. data/lib/sisimai/mta/postfix.rb +15 -45
  52. data/lib/sisimai/mta/qmail.rb +32 -60
  53. data/lib/sisimai/mta/sendmail.rb +13 -38
  54. data/lib/sisimai/mta/surfcontrol.rb +15 -44
  55. data/lib/sisimai/mta/userdefined.rb +14 -30
  56. data/lib/sisimai/mta/v5sendmail.rb +18 -40
  57. data/lib/sisimai/mta/x1.rb +12 -41
  58. data/lib/sisimai/mta/x2.rb +12 -41
  59. data/lib/sisimai/mta/x3.rb +12 -39
  60. data/lib/sisimai/mta/x4.rb +33 -66
  61. data/lib/sisimai/mta/x5.rb +15 -42
  62. data/lib/sisimai/reason.rb +8 -71
  63. data/lib/sisimai/reason/blocked.rb +3 -0
  64. data/lib/sisimai/reason/contenterror.rb +3 -0
  65. data/lib/sisimai/reason/delivered.rb +27 -0
  66. data/lib/sisimai/reason/exceedlimit.rb +3 -0
  67. data/lib/sisimai/reason/expired.rb +3 -0
  68. data/lib/sisimai/reason/feedback.rb +18 -0
  69. data/lib/sisimai/reason/filtered.rb +4 -0
  70. data/lib/sisimai/reason/hasmoved.rb +3 -0
  71. data/lib/sisimai/reason/hostunknown.rb +3 -0
  72. data/lib/sisimai/reason/mailboxfull.rb +3 -0
  73. data/lib/sisimai/reason/mailererror.rb +3 -0
  74. data/lib/sisimai/reason/mesgtoobig.rb +3 -0
  75. data/lib/sisimai/reason/networkerror.rb +3 -0
  76. data/lib/sisimai/reason/norelaying.rb +3 -0
  77. data/lib/sisimai/reason/notaccept.rb +3 -0
  78. data/lib/sisimai/reason/onhold.rb +3 -0
  79. data/lib/sisimai/reason/rejected.rb +3 -0
  80. data/lib/sisimai/reason/securityerror.rb +3 -0
  81. data/lib/sisimai/reason/spamdetected.rb +3 -0
  82. data/lib/sisimai/reason/suspend.rb +3 -0
  83. data/lib/sisimai/reason/syntaxerror.rb +41 -0
  84. data/lib/sisimai/reason/systemerror.rb +3 -0
  85. data/lib/sisimai/reason/systemfull.rb +3 -0
  86. data/lib/sisimai/reason/toomanyconn.rb +3 -0
  87. data/lib/sisimai/reason/undefined.rb +18 -0
  88. data/lib/sisimai/reason/userunknown.rb +3 -0
  89. data/lib/sisimai/reason/vacation.rb +18 -0
  90. data/lib/sisimai/rfc3464.rb +15 -40
  91. data/lib/sisimai/rfc3834.rb +1 -10
  92. data/lib/sisimai/rfc5322.rb +57 -19
  93. data/lib/sisimai/rhost/googleapps.rb +82 -82
  94. data/lib/sisimai/smtp/reply.rb +2 -1
  95. data/lib/sisimai/smtp/status.rb +154 -152
  96. data/lib/sisimai/string.rb +2 -3
  97. data/lib/sisimai/version.rb +1 -1
  98. data/set-of-emails/maildir/bsd/rfc3464-29.eml +60 -0
  99. data/set-of-emails/maildir/bsd/us-amazonworkmail-06.eml +156 -0
  100. data/set-of-emails/maildir/bsd/us-amazonworkmail-07.eml +158 -0
  101. data/set-of-emails/maildir/bsd/us-google-15.eml +97 -0
  102. data/set-of-emails/maildir/bsd/us-google-16.eml +99 -0
  103. data/set-of-emails/maildir/bsd/us-google-17.eml +104 -0
  104. data/set-of-emails/maildir/dos/apachejames-01.eml +4 -4
  105. data/set-of-emails/maildir/dos/us-amazonworkmail-01.eml +156 -0
  106. data/set-of-emails/maildir/dos/us-office365-01.eml +102 -0
  107. data/set-of-emails/maildir/mac/apachejames-01.eml +1 -9
  108. data/set-of-emails/maildir/mac/us-amazonworkmail-01.eml +1 -7
  109. data/set-of-emails/maildir/mac/us-office365-01.eml +1 -4
  110. metadata +17 -2
@@ -19,8 +19,6 @@ module Sisimai
19
19
  },
20
20
  }
21
21
  Indicators = Sisimai::MSP.INDICATORS
22
- LongFields = Sisimai::RFC5322.LONGFIELDS
23
- RFC822Head = Sisimai::RFC5322.HEADERFIELDS
24
22
 
25
23
  def description; return 'Verizon Wireless: http://www.verizonwireless.com'; end
26
24
  def smtpagent; return 'US::Verizon'; end
@@ -59,11 +57,10 @@ module Sisimai
59
57
 
60
58
  require 'sisimai/mime'
61
59
  require 'sisimai/address'
62
- dscontents = []; dscontents << Sisimai::MSP.DELIVERYSTATUS
60
+ dscontents = [Sisimai::MSP.DELIVERYSTATUS]
63
61
  hasdivided = mbody.split("\n")
64
- rfc822next = { 'from' => false, 'to' => false, 'subject' => false }
65
- rfc822part = '' # (String) message/rfc822-headers part
66
- previousfn = '' # (String) Previous field name
62
+ rfc822list = [] # (Array) Each line in message/rfc822 part string
63
+ blanklines = 0 # (Integer) The number of blank lines
67
64
  readcursor = 0 # (Integer) Points the current cursor position
68
65
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
69
66
  senderaddr = '' # (String) Sender address in the message body
@@ -83,11 +80,8 @@ module Sisimai
83
80
  }
84
81
  reFailure = {
85
82
  # The attempted recipient address does not exist.
86
- 'userunknown' => %r{
87
- 550[ ][-][ ]Requested[ ]action[ ]not[ ]taken:[ ]no[ ]such[ ]user[ ]here
88
- }x,
83
+ userunknown: %r/550[ ][-][ ]Requested[ ]action[ ]not[ ]taken:[ ]no[ ]such[ ]user[ ]here/x,
89
84
  }
90
- rfc822next = { 'from' => 0, 'to' => 0, 'subject' => 0 }
91
85
  boundary00 = Sisimai::MIME.boundary(mhead['content-type']) || ''
92
86
 
93
87
  if boundary00.size > 0
@@ -99,7 +93,7 @@ module Sisimai
99
93
  if readcursor == 0
100
94
  # Beginning of the bounce message or delivery status part
101
95
  if e =~ re1[:begin]
102
- readcursor |= Indicators[:'deliverystatus']
96
+ readcursor |= Indicators[:deliverystatus]
103
97
  next
104
98
  end
105
99
  end
@@ -114,30 +108,16 @@ module Sisimai
114
108
 
115
109
  if readcursor & Indicators[:'message-rfc822'] > 0
116
110
  # After "message/rfc822"
117
- if cv = e.match(/\A([-0-9A-Za-z]+?)[:][ ]*.+\z/)
118
- # Get required headers only
119
- lhs = cv[1].downcase
120
- previousfn = ''
121
- next unless RFC822Head.key?(lhs)
122
-
123
- previousfn = lhs
124
- rfc822part += e + "\n"
125
-
126
- elsif e =~ /\A[ \t]+/
127
- # Continued line from the previous line
128
- next if rfc822next[previousfn]
129
- rfc822part += e + "\n" if LongFields.key?(previousfn)
130
-
131
- else
132
- # Check the end of headers in rfc822 part
133
- next unless LongFields.key?(previousfn)
134
- next unless e.empty?
135
- rfc822next[previousfn] = true
111
+ if e.empty?
112
+ blanklines += 1
113
+ break if blanklines > 1
114
+ next
136
115
  end
116
+ rfc822list << e
137
117
 
138
118
  else
139
119
  # Before "message/rfc822"
140
- next if readcursor & Indicators[:'deliverystatus'] == 0
120
+ next if readcursor & Indicators[:deliverystatus] == 0
141
121
  next if e.empty?
142
122
 
143
123
  # Message details:
@@ -180,11 +160,8 @@ module Sisimai
180
160
  :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
181
161
  }
182
162
  reFailure = {
183
- 'userunknown' => %r{
184
- No[ ]valid[ ]recipients[ ]for[ ]this[ ]MM
185
- }x,
163
+ userunknown: %r/No[ ]valid[ ]recipients[ ]for[ ]this[ ]MM/x,
186
164
  }
187
- rfc822next = { 'from' => 0, 'to' => 0, 'subject' => 0 }
188
165
  boundary00 = Sisimai::MIME.boundary(mhead['content-type'])
189
166
  if boundary00.size > 0
190
167
  # Convert to regular expression
@@ -195,7 +172,7 @@ module Sisimai
195
172
  if readcursor == 0
196
173
  # Beginning of the bounce message or delivery status part
197
174
  if e =~ re1[:begin]
198
- readcursor |= Indicators[:'deliverystatus']
175
+ readcursor |= Indicators[:deliverystatus]
199
176
  next
200
177
  end
201
178
  end
@@ -210,30 +187,16 @@ module Sisimai
210
187
 
211
188
  if readcursor & Indicators[:'message-rfc822'] > 0
212
189
  # After "message/rfc822"
213
- if cv = e.match(/\A([-0-9A-Za-z]+?)[:][ ]*.+\z/)
214
- # Get required headers only
215
- lhs = cv[1].downcase
216
- previousfn = ''
217
- next unless RFC822Head.key?(lhs)
218
-
219
- previousfn = lhs
220
- rfc822part += e + "\n"
221
-
222
- elsif e =~ /\A[ \t]+/
223
- # Continued line from the previous line
224
- next if rfc822next[previousfn]
225
- rfc822part += e + "\n" if LongFields.key?(previousfn)
226
-
227
- else
228
- # Check the end of headers in rfc822 part
229
- next unless LongFields.key?(previousfn)
230
- next unless e.empty?
231
- rfc822next[previousfn] = true
190
+ if e.empty?
191
+ blanklines += 1
192
+ break if blanklines > 1
193
+ next
232
194
  end
195
+ rfc822list << e
233
196
 
234
197
  else
235
198
  # Before "message/rfc822"
236
- next if readcursor & Indicators[:'deliverystatus'] == 0
199
+ next if readcursor & Indicators[:deliverystatus] == 0
237
200
  next if e.empty?
238
201
 
239
202
  # Original Message:
@@ -271,36 +234,29 @@ module Sisimai
271
234
 
272
235
  return nil if recipients == 0
273
236
 
274
- # Set the value of "MAIL FROM:" or "From:", and "Subject"
275
- rfc822part += sprintf("From: %s\n", senderaddr) unless rfc822part =~ /\bFrom: /
276
- rfc822part += sprintf("Subject: %s\n", subjecttxt) unless rfc822part =~ /\bSubject: /
237
+ if !rfc822list.find { |a| a =~ /^From: / }
238
+ # Set the value of "MAIL FROM:" or "From:"
239
+ rfc822list << sprintf('From: %s', senderaddr)
277
240
 
278
- require 'sisimai/string'
279
- require 'sisimai/smtp/status'
241
+ elsif !rfc822list.find { |a| a =~ /^Subject: / }
242
+ # Set the value of "Subject:"
243
+ rfc822list << sprintf('Subject: %s', subjecttxt)
244
+ end
280
245
 
246
+ require 'sisimai/string'
281
247
  dscontents.map do |e|
282
- if mhead['received'].size > 0
283
- # Get localhost and remote host name from Received header.
284
- r0 = mhead['received']
285
- %w|lhost rhost|.each { |a| e[a] ||= '' }
286
- e['lhost'] = Sisimai::RFC5322.received(r0[0]).shift if e['lhost'].empty?
287
- e['rhost'] = Sisimai::RFC5322.received(r0[-1]).pop if e['rhost'].empty?
288
- end
248
+ e['agent'] = Sisimai::MSP::US::Verizon.smtpagent
289
249
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
290
250
 
291
251
  reFailure.each_key do |r|
292
252
  # Verify each regular expression of session errors
293
253
  next unless e['diagnosis'] =~ reFailure[r]
294
- e['reason'] = r
254
+ e['reason'] = r.to_s
295
255
  break
296
256
  end
297
-
298
- e['status'] = Sisimai::SMTP::Status.find(e['diagnosis'])
299
- e['spec'] = e['reason'] == 'mailererror' ? 'X-UNIX' : 'SMTP'
300
- e['action'] = 'failed' if e['status'] =~ /\A[45]/
301
- e['agent'] = Sisimai::MSP::US::Verizon.smtpagent
302
257
  end
303
258
 
259
+ rfc822part = Sisimai::RFC5322.weedout(rfc822list)
304
260
  return { 'ds' => dscontents, 'rfc822' => rfc822part }
305
261
  end
306
262
 
@@ -17,8 +17,6 @@ module Sisimai
17
17
  :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
18
18
  }
19
19
  Indicators = Sisimai::MSP.INDICATORS
20
- LongFields = Sisimai::RFC5322.LONGFIELDS
21
- RFC822Head = Sisimai::RFC5322.HEADERFIELDS
22
20
 
23
21
  def description; return 'Yahoo! MAIL: https://www.yahoo.com'; end
24
22
  def smtpagent; return 'US::Yahoo'; end
@@ -46,11 +44,10 @@ module Sisimai
46
44
  return nil unless mbody
47
45
  return nil unless mhead['x-ymailisg']
48
46
 
49
- dscontents = []; dscontents << Sisimai::MSP.DELIVERYSTATUS
47
+ dscontents = [Sisimai::MSP.DELIVERYSTATUS]
50
48
  hasdivided = mbody.split("\n")
51
- rfc822next = { 'from' => false, 'to' => false, 'subject' => false }
52
- rfc822part = '' # (String) message/rfc822-headers part
53
- previousfn = '' # (String) Previous field name
49
+ rfc822list = [] # (Array) Each line in message/rfc822 part string
50
+ blanklines = 0 # (Integer) The number of blank lines
54
51
  readcursor = 0 # (Integer) Points the current cursor position
55
52
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
56
53
  v = nil
@@ -59,7 +56,7 @@ module Sisimai
59
56
  if readcursor == 0
60
57
  # Beginning of the bounce message or delivery status part
61
58
  if e =~ Re1[:begin]
62
- readcursor |= Indicators[:'deliverystatus']
59
+ readcursor |= Indicators[:deliverystatus]
63
60
  next
64
61
  end
65
62
  end
@@ -74,30 +71,16 @@ module Sisimai
74
71
 
75
72
  if readcursor & Indicators[:'message-rfc822'] > 0
76
73
  # After "message/rfc822"
77
- if cv = e.match(/\A([-0-9A-Za-z]+?)[:][ ]*.+\z/)
78
- # Get required headers only
79
- lhs = cv[1].downcase
80
- previousfn = ''
81
- next unless RFC822Head.key?(lhs)
82
-
83
- previousfn = lhs
84
- rfc822part += e + "\n"
85
-
86
- elsif e =~ /\A[ \t]+/
87
- # Continued line from the previous line
88
- next if rfc822next[previousfn]
89
- rfc822part += e + "\n" if LongFields.key?(previousfn)
90
-
91
- else
92
- # Check the end of headers in rfc822 part
93
- next unless LongFields.key?(previousfn)
94
- next unless e.empty?
95
- rfc822next[previousfn] = true
74
+ if e.empty?
75
+ blanklines += 1
76
+ break if blanklines > 1
77
+ next
96
78
  end
79
+ rfc822list << e
97
80
 
98
81
  else
99
82
  # Before "message/rfc822"
100
- next if readcursor & Indicators[:'deliverystatus'] == 0
83
+ next if readcursor & Indicators[:deliverystatus] == 0
101
84
  next if e.empty?
102
85
 
103
86
  # Sorry, we were unable to deliver your message to the following address.
@@ -148,27 +131,16 @@ module Sisimai
148
131
  end
149
132
  end
150
133
  end
151
-
152
134
  return nil if recipients == 0
153
135
  require 'sisimai/string'
154
- require 'sisimai/smtp/status'
155
136
 
156
137
  dscontents.map do |e|
157
- if mhead['received'].size > 0
158
- # Get localhost and remote host name from Received header.
159
- r0 = mhead['received']
160
- %w|lhost rhost|.each { |a| e[a] ||= '' }
161
- e['lhost'] = Sisimai::RFC5322.received(r0[0]).shift if e['lhost'].empty?
162
- e['rhost'] = Sisimai::RFC5322.received(r0[-1]).pop if e['rhost'].empty?
163
- end
164
138
  e['diagnosis'] = e['diagnosis'].gsub(/\\n/, ' ')
165
139
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
166
-
167
- e['status'] = Sisimai::SMTP::Status.find(e['diagnosis'])
168
- e['spec'] ||= 'SMTP'
169
- e['agent'] = Sisimai::MSP::US::Yahoo.smtpagent
140
+ e['agent'] = Sisimai::MSP::US::Yahoo.smtpagent
170
141
  end
171
142
 
143
+ rfc822part = Sisimai::RFC5322.weedout(rfc822list)
172
144
  return { 'ds' => dscontents, 'rfc822' => rfc822part }
173
145
  end
174
146
 
@@ -23,11 +23,9 @@ module Sisimai
23
23
  :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
24
24
  }
25
25
  ReFailure = {
26
- 'expired' => %r/Host not reachable/
26
+ expired: %r/Host not reachable/
27
27
  }
28
28
  Indicators = Sisimai::MSP.INDICATORS
29
- LongFields = Sisimai::RFC5322.LONGFIELDS
30
- RFC822Head = Sisimai::RFC5322.HEADERFIELDS
31
29
 
32
30
  def description; return 'Zoho Mail: https://www.zoho.com'; end
33
31
  def smtpagent; return 'US::Zoho'; end
@@ -54,11 +52,10 @@ module Sisimai
54
52
  return nil unless mbody
55
53
  return nil unless mhead['x-zohomail']
56
54
 
57
- dscontents = []; dscontents << Sisimai::MSP.DELIVERYSTATUS
55
+ dscontents = [Sisimai::MSP.DELIVERYSTATUS]
58
56
  hasdivided = mbody.split("\n")
59
- rfc822next = { 'from' => false, 'to' => false, 'subject' => false }
60
- rfc822part = '' # (String) message/rfc822-headers part
61
- previousfn = '' # (String) Previous field name
57
+ rfc822list = [] # (Array) Each line in message/rfc822 part string
58
+ blanklines = 0 # (Integer) The number of blank lines
62
59
  readcursor = 0 # (Integer) Points the current cursor position
63
60
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
64
61
  qprintable = false
@@ -68,7 +65,7 @@ module Sisimai
68
65
  if readcursor == 0
69
66
  # Beginning of the bounce message or delivery status part
70
67
  if e =~ Re1[:begin]
71
- readcursor |= Indicators[:'deliverystatus']
68
+ readcursor |= Indicators[:deliverystatus]
72
69
  next
73
70
  end
74
71
  end
@@ -83,30 +80,16 @@ module Sisimai
83
80
 
84
81
  if readcursor & Indicators[:'message-rfc822'] > 0
85
82
  # After "message/rfc822"
86
- if cv = e.match(/\A([-0-9A-Za-z]+?)[:][ ]*.+\z/)
87
- # Get required headers only
88
- lhs = cv[1].downcase
89
- previousfn = ''
90
- next unless RFC822Head.key?(lhs)
91
-
92
- previousfn = lhs
93
- rfc822part += e + "\n"
94
-
95
- elsif e =~ /\A[ \t]+/
96
- # Continued line from the previous line
97
- next if rfc822next[previousfn]
98
- rfc822part += e + "\n" if LongFields.key?(previousfn)
99
-
100
- else
101
- # Check the end of headers in rfc822 part
102
- next unless LongFields.key?(previousfn)
103
- next unless e.empty?
104
- rfc822next[previousfn] = true
83
+ if e.empty?
84
+ blanklines += 1
85
+ break if blanklines > 1
86
+ next
105
87
  end
88
+ rfc822list << e
106
89
 
107
90
  else
108
91
  # Before "message/rfc822"
109
- next if readcursor & Indicators[:'deliverystatus'] == 0
92
+ next if readcursor & Indicators[:deliverystatus] == 0
110
93
  next if e.empty?
111
94
 
112
95
  # This message was created automatically by mail delivery software.
@@ -160,34 +143,23 @@ module Sisimai
160
143
  end
161
144
  end
162
145
  end
163
-
164
146
  return nil if recipients == 0
165
147
  require 'sisimai/string'
166
- require 'sisimai/smtp/status'
167
148
 
168
149
  dscontents.map do |e|
169
- if mhead['received'].size > 0
170
- # Get localhost and remote host name from Received header.
171
- r0 = mhead['received']
172
- %w|lhost rhost|.each { |a| e[a] ||= '' }
173
- e['lhost'] = Sisimai::RFC5322.received(r0[0]).shift if e['lhost'].empty?
174
- e['rhost'] = Sisimai::RFC5322.received(r0[-1]).pop if e['rhost'].empty?
175
- end
150
+ e['agent'] = Sisimai::MSP::US::Zoho.smtpagent
176
151
  e['diagnosis'] = e['diagnosis'].gsub(/\\n/, ' ')
177
152
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
178
153
 
179
154
  ReFailure.each_key do |r|
180
155
  # Verify each regular expression of session errors
181
156
  next unless e['diagnosis'] =~ ReFailure[r]
182
- e['reason'] = r
157
+ e['reason'] = r.to_s
183
158
  break
184
159
  end
185
-
186
- e['status'] = Sisimai::SMTP::Status.find(e['diagnosis'])
187
- e['spec'] ||= 'SMTP'
188
- e['agent'] = Sisimai::MSP::US::Zoho.smtpagent
189
160
  end
190
161
 
162
+ rfc822part = Sisimai::RFC5322.weedout(rfc822list)
191
163
  return { 'ds' => dscontents, 'rfc822' => rfc822part }
192
164
  end
193
165
 
@@ -19,8 +19,6 @@ module Sisimai
19
19
  :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
20
20
  }
21
21
  Indicators = Sisimai::MTA.INDICATORS
22
- LongFields = Sisimai::RFC5322.LONGFIELDS
23
- RFC822Head = Sisimai::RFC5322.HEADERFIELDS
24
22
 
25
23
  def description; return 'TransWARE Active!hunter'; end
26
24
  def smtpagent; return 'Activehunter'; end
@@ -43,11 +41,10 @@ module Sisimai
43
41
  return nil unless mbody
44
42
  return nil unless mhead['x-ahmailid']
45
43
 
46
- dscontents = []; dscontents << Sisimai::MTA.DELIVERYSTATUS
44
+ dscontents = [Sisimai::MTA.DELIVERYSTATUS]
47
45
  hasdivided = mbody.split("\n")
48
- rfc822next = { 'from' => false, 'to' => false, 'subject' => false }
49
- rfc822part = '' # (String) message/rfc822-headers part
50
- previousfn = '' # (String) Previous field name
46
+ rfc822list = [] # (Array) Each line in message/rfc822 part string
47
+ blanklines = 0 # (Integer) The number of blank lines
51
48
  readcursor = 0 # (Integer) Points the current cursor position
52
49
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
53
50
  v = nil
@@ -56,7 +53,7 @@ module Sisimai
56
53
  if readcursor == 0
57
54
  # Beginning of the bounce message or delivery status part
58
55
  if e =~ Re1[:begin]
59
- readcursor |= Indicators[:'deliverystatus']
56
+ readcursor |= Indicators[:deliverystatus]
60
57
  next
61
58
  end
62
59
  end
@@ -71,30 +68,16 @@ module Sisimai
71
68
 
72
69
  if readcursor & Indicators[:'message-rfc822'] > 0
73
70
  # After "message/rfc822"
74
- if cv = e.match(/\A([-0-9A-Za-z]+?)[:][ ]*.+\z/)
75
- # Get required headers only
76
- lhs = cv[1].downcase
77
- previousfn = ''
78
- next unless RFC822Head.key?(lhs)
79
-
80
- previousfn = lhs
81
- rfc822part += e + "\n"
82
-
83
- elsif e =~ /\A[ \t]+/
84
- # Continued line from the previous line
85
- next if rfc822next[previousfn]
86
- rfc822part += e + "\n" if LongFields.key?(previousfn)
87
-
88
- else
89
- # Check the end of headers in rfc822 part
90
- next unless LongFields.key?(previousfn)
91
- next unless e.empty?
92
- rfc822next[previousfn] = true
71
+ if e.empty?
72
+ blanklines += 1
73
+ break if blanklines > 1
74
+ next
93
75
  end
76
+ rfc822list << e
94
77
 
95
78
  else
96
79
  # Before "message/rfc822"
97
- next if readcursor & Indicators[:'deliverystatus'] == 0
80
+ next if readcursor & Indicators[:deliverystatus] == 0
98
81
  next if e.empty?
99
82
 
100
83
  # ----- The following addresses had permanent fatal errors -----
@@ -123,28 +106,16 @@ module Sisimai
123
106
  end
124
107
  end
125
108
  end
126
-
127
109
  return nil if recipients == 0
128
110
  require 'sisimai/string'
129
- require 'sisimai/smtp/status'
130
111
 
131
112
  dscontents.map do |e|
132
- if mhead['received'].size > 0
133
- # Get localhost and remote host name from Received header.
134
- r0 = mhead['received']
135
- %w|lhost rhost|.each { |a| e[a] ||= '' }
136
- e['lhost'] = Sisimai::RFC5322.received(r0[0]).shift if e['lhost'].empty?
137
- e['rhost'] = Sisimai::RFC5322.received(r0[-1]).pop if e['rhost'].empty?
138
- end
139
-
140
113
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
141
- e['status'] = Sisimai::SMTP::Status.find(e['diagnosis'])
142
- e['spec'] = e['reason'] == 'mailererror' ? 'X-UNIX' : 'SMTP'
143
- e['action'] = 'failed' if e['status'] =~ /\A[45]/
144
114
  e['agent'] = Sisimai::MTA::Activehunter.smtpagent
145
115
  e.each_key { |a| e[a] ||= '' }
146
116
  end
147
117
 
118
+ rfc822part = Sisimai::RFC5322.weedout(rfc822list)
148
119
  return { 'ds' => dscontents, 'rfc822' => rfc822part }
149
120
  end
150
121