smtp-patch 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/README.md +2 -2
- data/lib/smtp/patch/smtp.rb +39 -0
- data/lib/smtp/patch/version.rb +1 -1
- data/smtp-patch.gemspec +2 -2
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9a236576a470e62f3c55419720b537f2934229c54d420ae2ac83753a93aa953
|
4
|
+
data.tar.gz: d45e7ee02959c8a98000043641276c56f3d7ef634e8612573dab70be3972e399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dc1735f637de4c0c4eb21a5200835b9b6b5bd3133969cf537cbc403db912a2a44d944cf0348a0000202876ecedc98ef49fe3325dc024efe0732ec35fbb24681
|
7
|
+
data.tar.gz: e31b44db4091fc9f11670d91f61c200eb04af65eabd15f6b4948248ea705549710d0a9680136b8fd92194919cee36bfa1a3791ca77704402b13a8da97b8ca89a
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
## SMTP Patch
|
2
2
|
|
3
|
-
Enhance Ruby net/smtp library to
|
3
|
+
Enhance Ruby net/smtp library to be never interrupted by errors while mail sending to multiple recipients.
|
4
4
|
|
5
5
|
### Installation
|
6
6
|
|
@@ -14,7 +14,7 @@ Install the gem with bundler:
|
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
-
By default, the mail will always be sent when you are sending a mail to multiple
|
17
|
+
By default, the mail will always be sent when you are sending a mail to multiple recipients. However, during the sending, if there are errors happened, the errors will not raise at once but raise after email sent out. You can catch the errors like below:
|
18
18
|
|
19
19
|
```ruby
|
20
20
|
begin
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Net
|
2
|
+
class SMTPErrors < ProtoAuthError
|
3
|
+
include SMTPError
|
4
|
+
|
5
|
+
attr_reader :errors
|
6
|
+
|
7
|
+
def initialize(errors)
|
8
|
+
@errors = errors
|
9
|
+
super message
|
10
|
+
end
|
11
|
+
|
12
|
+
def message
|
13
|
+
"failed to deliver for #{errors}."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class SMTP
|
18
|
+
alias original_rcptto_list rcptto_list
|
19
|
+
|
20
|
+
def rcptto_list(to_addrs)
|
21
|
+
raise ArgumentError, 'mail destination not given' if to_addrs.empty?
|
22
|
+
ok_users = []
|
23
|
+
errors = {}
|
24
|
+
to_addrs.flatten.each do |addr|
|
25
|
+
begin
|
26
|
+
rcptto addr
|
27
|
+
rescue SMTPError
|
28
|
+
errors[addr] = $!
|
29
|
+
else
|
30
|
+
ok_users << addr
|
31
|
+
end
|
32
|
+
end
|
33
|
+
raise ArgumentError, 'mail destination not given' if ok_users.empty?
|
34
|
+
ret = yield
|
35
|
+
raise SMTPErrors, errors if errors.any?
|
36
|
+
ret
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/smtp/patch/version.rb
CHANGED
data/smtp-patch.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Charles Koyeung"]
|
10
10
|
spec.email = ["cenxky@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = "Enhance Ruby net/smtp library to
|
13
|
-
spec.description = "Enhance Ruby net/smtp library to
|
12
|
+
spec.summary = "Enhance Ruby net/smtp library to be never interrupted by errors while mail sending to multiple recipients."
|
13
|
+
spec.description = "Enhance Ruby net/smtp library to be never interrupted by errors while mail sending to multiple recipients."
|
14
14
|
spec.homepage = "https://github.com/cenxky/smtp-patch"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smtp-patch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Koyeung
|
@@ -52,8 +52,8 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
description: Enhance Ruby net/smtp library to
|
56
|
-
|
55
|
+
description: Enhance Ruby net/smtp library to be never interrupted by errors while
|
56
|
+
mail sending to multiple recipients.
|
57
57
|
email:
|
58
58
|
- cenxky@gmail.com
|
59
59
|
executables: []
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- bin/console
|
71
71
|
- bin/setup
|
72
72
|
- lib/smtp/patch.rb
|
73
|
+
- lib/smtp/patch/smtp.rb
|
73
74
|
- lib/smtp/patch/version.rb
|
74
75
|
- smtp-patch.gemspec
|
75
76
|
homepage: https://github.com/cenxky/smtp-patch
|
@@ -94,6 +95,6 @@ requirements: []
|
|
94
95
|
rubygems_version: 3.0.3
|
95
96
|
signing_key:
|
96
97
|
specification_version: 4
|
97
|
-
summary: Enhance Ruby net/smtp library to
|
98
|
-
|
98
|
+
summary: Enhance Ruby net/smtp library to be never interrupted by errors while mail
|
99
|
+
sending to multiple recipients.
|
99
100
|
test_files: []
|