bounce_email 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/HISTORY.md +4 -0
- data/VERSION +1 -1
- data/lib/bounce_email.rb +2 -24
- data/test/bounce_email_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 389a9e0770cb526a74372b21a69bec34e74e2838
|
4
|
+
data.tar.gz: 48acb9da2dc68c2a86e3ade32ce0ddb5fcefc9f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88e393b37a5868b299bc1551d68feb785f677f47fbe2b340e218a1c091a815fd94d07c701586fda52e084cb4153bad586e016b3f7dd46f189481f6d7e31a4866
|
7
|
+
data.tar.gz: 3f5c4fa7c27729d0de1e0f29ba1fcc02cfc00e11923babe6f7817e7bc4dad1ca260e1cbcc5674fd3eaec076e0a5eeaa75674866b5a300f9bdad5810f2a27a5af
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.2.8
|
2
|
+
|
3
|
+
* Properly parse the email original when it's attached in the last part of a multipart bounce email (@blainejohnson17, livebg/bounce_email#12). Read more about [the issue and the reasoning behind the fix here](https://github.com/livebg/bounce_email/pull/12#issuecomment-312431646).
|
4
|
+
|
1
5
|
## 0.2.7
|
2
6
|
|
3
7
|
* Extract and save the bounced email's date field in the email original (@blainejohnson17, livebg/bounce_email#11)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.8
|
data/lib/bounce_email.rb
CHANGED
@@ -221,7 +221,7 @@ module BounceEmail
|
|
221
221
|
def get_original_mail(mail) #worked alright for me, for sure this has to be extended
|
222
222
|
original =
|
223
223
|
if mail.multipart?
|
224
|
-
::Mail.new(mail.parts.last)
|
224
|
+
::Mail.new(mail.parts.last.body)
|
225
225
|
elsif i = index_of_original_message_delimiter(mail)
|
226
226
|
::Mail.new(extract_original_message_after_delimiter(mail, i))
|
227
227
|
end
|
@@ -242,19 +242,7 @@ module BounceEmail
|
|
242
242
|
end
|
243
243
|
|
244
244
|
def extract_and_assign_fields_from(bounce, original)
|
245
|
-
|
246
|
-
original.add_message_id extract_field_from(original, /^Message-ID:/)
|
247
|
-
end
|
248
|
-
|
249
|
-
original.from ||= extract_field_from(original, /^From:/)
|
250
|
-
|
251
|
-
original.to ||= (extract_original_to_field_from_header(bounce) ||
|
252
|
-
extract_field_from(original, /^To:/))
|
253
|
-
|
254
|
-
original.subject ||= extract_field_from(original, /^Subject:/)
|
255
|
-
|
256
|
-
original.date ||= extract_field_from(original, /^Date:/)
|
257
|
-
|
245
|
+
original.to ||= extract_original_to_field_from_header(bounce)
|
258
246
|
original
|
259
247
|
end
|
260
248
|
|
@@ -262,15 +250,5 @@ module BounceEmail
|
|
262
250
|
header = mail.header["X-Failed-Recipients"]
|
263
251
|
header.value if header && header.value
|
264
252
|
end
|
265
|
-
|
266
|
-
def extract_field_from(mail, field_name)
|
267
|
-
lines = original_mail_body_lines(mail)
|
268
|
-
field = lines.detect { |line| line.match field_name }
|
269
|
-
field.split(':', 2).last.strip if field
|
270
|
-
end
|
271
|
-
|
272
|
-
def original_mail_body_lines(mail)
|
273
|
-
@original_mail_body_lines ||= mail.body.to_s.split(/(?:\r\n|\n)+/)
|
274
|
-
end
|
275
253
|
end
|
276
254
|
end
|
data/test/bounce_email_test.rb
CHANGED
@@ -108,7 +108,7 @@ class BounceEmailTest < Test::Unit::TestCase
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def test_original_message_with_multipart_mails
|
111
|
-
multipart_mails = %w(05 07 10 11 13 15 16 23 24)
|
111
|
+
multipart_mails = %w(04 05 07 10 11 13 15 16 23 24)
|
112
112
|
multipart_mails.map do |file|
|
113
113
|
mail = File.join(File.dirname(__FILE__), 'bounces', "tt_bounce_#{file}.txt")
|
114
114
|
bounce = BounceEmail::Mail.new Mail.read(mail)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bounce_email
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Bielohlawek
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-
|
14
|
+
date: 2017-07-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: mail
|