bounce_email 0.2.2 → 0.2.3
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 +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +1 -1
- data/HISTORY.md +17 -0
- data/README.md +18 -7
- data/VERSION +1 -1
- data/bounce_email.gemspec +4 -0
- data/lib/bounce_email.rb +23 -8
- data/test/bounce_email_test.rb +21 -5
- metadata +49 -55
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 9fe2e41f68b363d56e006effeefda2677e50efc2
|
|
4
|
+
data.tar.gz: e49e1d1201f050555dd8698f501e24bb1e5d0c9f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: dac46158c4ec4666b8a94a2c3cde4ae426e5865e52d8e9117356f04103fe569d551a363c912f21df6fd2358867892dd9b7d20725cc27acb7424d13e752b0bd1f
|
|
7
|
+
data.tar.gz: 0fbffdd4385603a275a871f5e77471c7454364b5cc8e949869cc4300ae1aced6a0703637249c6d308db90eb2de6a8534cc93d7376e87c7958152103e004317cf
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/HISTORY.md
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
+
## 0.2.3
|
|
2
|
+
|
|
3
|
+
* add support for Gmail bounces (@saghaulor, livebg/bounce_email#4)
|
|
4
|
+
|
|
5
|
+
## 0.2.2
|
|
6
|
+
|
|
7
|
+
* fix a failure when an email has no subject header
|
|
8
|
+
|
|
9
|
+
## 0.2.1
|
|
10
|
+
|
|
11
|
+
* fix Ruby 1.8.7 compatibility
|
|
12
|
+
|
|
13
|
+
## 0.2.0
|
|
14
|
+
|
|
15
|
+
* new versioning due to new gem being published
|
|
16
|
+
|
|
1
17
|
## 0.1.1 2011-09-01
|
|
18
|
+
|
|
2
19
|
* extended #bounced? to consider error_status and diagnostic_code as well
|
|
3
20
|
* updated external gems
|
|
4
21
|
|
data/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
This Ruby library is for determining the bounce type of an email message. It determines whether the bounce is hard or soft, if is an "out of office mail", etc.
|
|
4
4
|
|
|
5
|
+
[](https://travis-ci.org/livebg/bounce_email)
|
|
6
|
+
|
|
5
7
|
## SYNOPSIS:
|
|
6
8
|
|
|
7
9
|
Follow this tutorial to handle bounce-emails: [http://keakaj.com/wisdom/2007/08/08/verp-on-rails](http://keakaj.com/wisdom/2007/08/08/verp-on-rails/)
|
|
@@ -19,10 +21,19 @@ Basic usage:
|
|
|
19
21
|
bounce.type # "Permanent Failure", "Persistent Transient Failure", "Success" -- BounceEmail::TYPE_HARD_FAIL, TYPE_SOFT_FAIL, TYPE_SUCCESS
|
|
20
22
|
|
|
21
23
|
|
|
24
|
+
## Compatibility
|
|
25
|
+
|
|
26
|
+
Compatible with Ruby 1.9.x, 2.0.0, 2.1.0, and 2.2.0.
|
|
27
|
+
|
|
28
|
+
It is no longer tested under 1.8.7, but it should work there as well, if you use it with an older version of the `mime-types` gem (from the 1.x branch). `mime-types` is a dependency of the `mail` gem, which currently works with `mime-types` 1.6+, so it should be possible.
|
|
29
|
+
|
|
22
30
|
## REQUIREMENTS:
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
[mail](http://rubygems.org/gems/mail) gem is required with `bounce_email` gem.
|
|
33
|
+
The `mail` gem is used for primary bounce handling, which catches about 50% of
|
|
34
|
+
all bounces. `bounce_email` tries to catch remaining bounce emails.
|
|
35
|
+
|
|
36
|
+
See discussion here: [https://github.com/mikel/mail/issues/103](https://github.com/mikel/mail/issues/103)
|
|
26
37
|
|
|
27
38
|
## Other implementations:
|
|
28
39
|
|
|
@@ -31,11 +42,11 @@ For most other bounces, this gem comes in. See discussion here: [https://github.
|
|
|
31
42
|
|
|
32
43
|
## TODO:
|
|
33
44
|
|
|
34
|
-
* code cleanup
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
45
|
+
* Mode code cleanup.
|
|
46
|
+
* Don't hardcode comparison strings, move to external file which can be extended easily.
|
|
47
|
+
* More test: extend for more bounces.
|
|
48
|
+
* Is OUT of office type needed? If yes, implement as an optional part.
|
|
49
|
+
* Merge into Mail Gem?
|
|
39
50
|
|
|
40
51
|
## CONTRIBUTIONS:
|
|
41
52
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.3
|
data/bounce_email.gemspec
CHANGED
data/lib/bounce_email.rb
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
# encoding:
|
|
1
|
+
# encoding: utf-8
|
|
2
2
|
require 'mail'
|
|
3
3
|
|
|
4
4
|
module BounceEmail
|
|
5
5
|
TYPE_HARD_FAIL = 'Permanent Failure'
|
|
6
6
|
TYPE_SOFT_FAIL = 'Persistent Transient Failure'
|
|
7
7
|
TYPE_SUCCESS = 'Success'
|
|
8
|
+
INLINE_MESSAGE_BEGIN_DELIMITERS = [
|
|
9
|
+
'Original message',
|
|
10
|
+
'Below this line is a copy of the message.',
|
|
11
|
+
'Message header follows'
|
|
12
|
+
].map { |delimiter| Regexp.new(/^[-\s]*#{delimiter}[\s-]*$/) }
|
|
13
|
+
INLINE_MESSAGE_END_DELIMITER = /^[-\s]*End of message[\s-]*$/
|
|
8
14
|
|
|
9
15
|
#qmail
|
|
10
16
|
# Status codes are defined in rfc3463, http://www.ietf.org/rfc/rfc3463.txt
|
|
@@ -212,15 +218,24 @@ module BounceEmail
|
|
|
212
218
|
false
|
|
213
219
|
end
|
|
214
220
|
|
|
215
|
-
def get_original_mail(mail) #worked alright for me, for sure this
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
::Mail.new(mail.parts[2].body)
|
|
221
|
+
def get_original_mail(mail) #worked alright for me, for sure this has to be extended
|
|
222
|
+
if mail.multipart?
|
|
223
|
+
::Mail.new(mail.parts.last)
|
|
224
|
+
elsif i = index_of_original_message_delimiter(mail)
|
|
225
|
+
::Mail.new(extract_original_message_after_delimiter(mail, i))
|
|
221
226
|
end
|
|
222
227
|
rescue => e
|
|
223
228
|
nil
|
|
224
229
|
end
|
|
230
|
+
|
|
231
|
+
def index_of_original_message_delimiter(mail)
|
|
232
|
+
INLINE_MESSAGE_BEGIN_DELIMITERS.find_index { |delimiter| self.body.to_s.match delimiter }
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def extract_original_message_after_delimiter(mail, delimiter_index)
|
|
236
|
+
delimiter = INLINE_MESSAGE_BEGIN_DELIMITERS[delimiter_index]
|
|
237
|
+
message = mail.body.to_s.split(delimiter).last
|
|
238
|
+
message.split(INLINE_MESSAGE_END_DELIMITER).first.strip if message.match(INLINE_MESSAGE_END_DELIMITER)
|
|
239
|
+
end
|
|
225
240
|
end
|
|
226
|
-
end
|
|
241
|
+
end
|
data/test/bounce_email_test.rb
CHANGED
|
@@ -107,11 +107,27 @@ class BounceEmailTest < Test::Unit::TestCase
|
|
|
107
107
|
assert_not_nil bounce.original_mail
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
def test_original_message_with_multipart_mails
|
|
111
|
+
multipart_mails = %w(03 04 05 07 10 11 13 15 16 23 24)
|
|
112
|
+
multipart_mails.map do |file|
|
|
113
|
+
mail = File.join(File.dirname(__FILE__), 'bounces', "tt_bounce_#{file}.txt")
|
|
114
|
+
bounce = BounceEmail::Mail.new Mail.read(mail)
|
|
115
|
+
assert_not_nil bounce.original_mail
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def test_original_message_without_inline_original_message
|
|
120
|
+
bounce = test_bounce('tt_bounce_01')
|
|
121
|
+
assert_nil bounce.original_mail
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def test_original_message_with_inline_original_message
|
|
125
|
+
mails_with_inline_original_message = %w(06 08 09 12_soft 14 17 18 19 20 21 22 25)
|
|
126
|
+
mails_with_inline_original_message.map do |file|
|
|
127
|
+
mail = File.join(File.dirname(__FILE__), 'bounces', "tt_bounce_#{file}.txt")
|
|
128
|
+
bounce = BounceEmail::Mail.new Mail.read(mail)
|
|
129
|
+
assert_not_nil bounce.original_mail
|
|
130
|
+
end
|
|
115
131
|
end
|
|
116
132
|
|
|
117
133
|
private
|
metadata
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bounce_email
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 2
|
|
9
|
-
- 2
|
|
10
|
-
version: 0.2.2
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.3
|
|
11
5
|
platform: ruby
|
|
12
|
-
authors:
|
|
6
|
+
authors:
|
|
13
7
|
- Tobias Bielohlawek
|
|
14
8
|
- Agris Ameriks
|
|
15
9
|
- Pedro Visintin
|
|
@@ -17,34 +11,45 @@ authors:
|
|
|
17
11
|
autorequire:
|
|
18
12
|
bindir: bin
|
|
19
13
|
cert_chain: []
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
dependencies:
|
|
24
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
|
15
|
+
dependencies:
|
|
16
|
+
- !ruby/object:Gem::Dependency
|
|
25
17
|
name: mail
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
none: false
|
|
29
|
-
requirements:
|
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
|
19
|
+
requirements:
|
|
30
20
|
- - ">="
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
|
|
33
|
-
segments:
|
|
34
|
-
- 0
|
|
35
|
-
version: "0"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '0'
|
|
36
23
|
type: :runtime
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: rake
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
requirements:
|
|
34
|
+
- - ">="
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '0'
|
|
37
|
+
type: :development
|
|
38
|
+
prerelease: false
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
description: fork of whatcould/bounce-email incl. patches from wakiki, peterpunk,
|
|
45
|
+
agowan & rngtng
|
|
39
46
|
email: tobi@rngtng.com
|
|
40
47
|
executables: []
|
|
41
|
-
|
|
42
48
|
extensions: []
|
|
43
|
-
|
|
44
49
|
extra_rdoc_files: []
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
- .
|
|
50
|
+
files:
|
|
51
|
+
- ".gitignore"
|
|
52
|
+
- ".travis.yml"
|
|
48
53
|
- Gemfile
|
|
49
54
|
- HISTORY.md
|
|
50
55
|
- Manifest.txt
|
|
@@ -101,41 +106,30 @@ files:
|
|
|
101
106
|
- test/non_bounces/tt_1234211024.txt
|
|
102
107
|
- test/non_bounces/tt_1234241664.txt
|
|
103
108
|
- test/test_helper.rb
|
|
104
|
-
has_rdoc: true
|
|
105
109
|
homepage: http://github.com/mitio/bounce_email
|
|
106
110
|
licenses: []
|
|
107
|
-
|
|
111
|
+
metadata: {}
|
|
108
112
|
post_install_message:
|
|
109
113
|
rdoc_options: []
|
|
110
|
-
|
|
111
|
-
require_paths:
|
|
114
|
+
require_paths:
|
|
112
115
|
- lib
|
|
113
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
|
-
|
|
115
|
-
requirements:
|
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
|
+
requirements:
|
|
116
118
|
- - ">="
|
|
117
|
-
- !ruby/object:Gem::Version
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
version: "0"
|
|
122
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
|
-
none: false
|
|
124
|
-
requirements:
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
version: '0'
|
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
|
+
requirements:
|
|
125
123
|
- - ">="
|
|
126
|
-
- !ruby/object:Gem::Version
|
|
127
|
-
|
|
128
|
-
segments:
|
|
129
|
-
- 0
|
|
130
|
-
version: "0"
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '0'
|
|
131
126
|
requirements: []
|
|
132
|
-
|
|
133
127
|
rubyforge_project:
|
|
134
|
-
rubygems_version:
|
|
128
|
+
rubygems_version: 2.2.2
|
|
135
129
|
signing_key:
|
|
136
|
-
specification_version:
|
|
130
|
+
specification_version: 4
|
|
137
131
|
summary: Detect kind of bounced email
|
|
138
|
-
test_files:
|
|
132
|
+
test_files:
|
|
139
133
|
- test/bounce_email_test.rb
|
|
140
134
|
- test/bounces/malformed_bounce_01.txt
|
|
141
135
|
- test/bounces/tt_1234175799.txt
|