bounce_email 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c78d63fcf13d9a6ff01002e733528e625c5711a0
4
- data.tar.gz: 5ca361001d0929091f392ec47971b542f77e5c62
3
+ metadata.gz: 2b8e9f25b36dce53b33d25f917cb84b495bbc3c9
4
+ data.tar.gz: 35776ace384b6a8f76074fcb223112d4feae01e6
5
5
  SHA512:
6
- metadata.gz: d451617b7f643007b672821870aa53afad12c1e1ff74b988363b86aed857fed34c732321975014e02a979d808d59a163d071eade8d1ff0569b23060ccbc9ff75
7
- data.tar.gz: c6c50ac546c1318e232facda201ef94f82cd5658688feb31ec758fd404b726fe1f98747372fd5f4a3b9dd3166b2b79a81aa6d40570d58b83f0ab33eb9395a12d
6
+ metadata.gz: e6ece81090252f87b3be36f0b3c86530e1dcf910cde99463977a8fa13a7d6b8c14ae0eac94b4b915d38c27dacb15c5727796cc21a36c79658c978f50fc01a67b
7
+ data.tar.gz: 0c4f261ede847ad967883971895d8206da080729664061d79d28c6aa58f5d63d824dd0d1903bdecc542dda9c2ed76631533a00fa8b2c11e2fb808a0a37471df3
data/HISTORY.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.2.6
2
+
3
+ * Replaced 'X-Original-To' header with 'X-Failed-Recipients' (@saghaulor, livebg/bounce_email#10)
4
+ * Properly extract "To" from original email (@saghaulor, livebg/bounce_email#8)
5
+
1
6
  ## 0.2.5
2
7
 
3
8
  * Fix parsing of original mail (@saghaulor, livebg/bounce_email#6)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
data/lib/bounce_email.rb CHANGED
@@ -225,7 +225,7 @@ module BounceEmail
225
225
  elsif i = index_of_original_message_delimiter(mail)
226
226
  ::Mail.new(extract_original_message_after_delimiter(mail, i))
227
227
  end
228
- return extract_and_assign_fields_from_original_mail(original) if original
228
+ return extract_and_assign_fields_from(mail, original) if original
229
229
  rescue => e
230
230
  nil
231
231
  end
@@ -241,16 +241,24 @@ module BounceEmail
241
241
  message
242
242
  end
243
243
 
244
- def extract_and_assign_fields_from_original_mail(mail)
245
- if mail.message_id.nil?
246
- mail.add_message_id extract_field_from(mail, 'Message-ID:')
244
+ def extract_and_assign_fields_from(bounce, original)
245
+ if original.message_id.nil?
246
+ original.add_message_id extract_field_from(original, /^Message-ID:/)
247
247
  end
248
248
 
249
- mail.from ||= extract_field_from(mail, 'From:')
250
- mail.to ||= extract_field_from(mail, 'To:')
251
- mail.subject ||= extract_field_from(mail, 'Subject:')
249
+ original.from ||= extract_field_from(original, /^From:/)
252
250
 
253
- mail
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
257
+ end
258
+
259
+ def extract_original_to_field_from_header(mail)
260
+ header = mail.header["X-Failed-Recipients"]
261
+ header.value if header && header.value
254
262
  end
255
263
 
256
264
  def extract_field_from(mail, field_name)
@@ -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(03 04 05 07 10 11 13 15 16 23 24)
111
+ multipart_mails = %w(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)
@@ -119,6 +119,18 @@ class BounceEmailTest < Test::Unit::TestCase
119
119
  end
120
120
  end
121
121
 
122
+ def test_original_message_with_multipart_mails_without_to_field
123
+ multipart_mails = %w(03 04)
124
+ multipart_mails.map do |file|
125
+ mail = File.join(File.dirname(__FILE__), 'bounces', "tt_bounce_#{file}.txt")
126
+ bounce = BounceEmail::Mail.new Mail.read(mail)
127
+ assert_not_nil bounce.original_mail
128
+ assert_not_nil bounce.original_mail.message_id
129
+ assert_equal [], bounce.original_mail.to
130
+ assert_not_nil bounce.original_mail.from
131
+ end
132
+ end
133
+
122
134
  def test_original_message_without_inline_original_message
123
135
  bounce = test_bounce('tt_bounce_01')
124
136
  assert_nil bounce.original_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.5
4
+ version: 0.2.6
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: 2015-04-07 00:00:00.000000000 Z
14
+ date: 2015-05-05 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: mail