net-smtp-proxy 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Rakefile +12 -0
- data/lib/net/smtp-proxy.rb +9 -0
- data/lib/net/smtp-proxy/delivery_method.rb +42 -0
- data/lib/net/smtp-proxy/proxy.rb +22 -0
- data/lib/net/smtp-proxy/version.rb +5 -0
- data/net-smtp-proxy.gemspec +26 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1b21b652bd81a297ede1bf7d17f5d0cf905defc5c371ede6c9f43e0480e8118f
|
4
|
+
data.tar.gz: 861663272537d7d5ef072dec5d593235424d7ebbe6d96e042a4d435797a7acfe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b53016b660aa90d84f020b2c44920124a467e84016f4cc5eb82d223c4c638724573e3420b61a8125241b74cd4fac6a20d01a0fd80cb6c1336a05e9c5abfad06a
|
7
|
+
data.tar.gz: 1fe4d577140248f324305d3e21665059c54a8b50722b8275c2a4a3e49c320f178aa15daf96dcf8bdcb81e01aa6554c496f1197b67a1857ba6950950d4f50ddd9
|
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
begin
|
2
|
+
require 'mail'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'The mail gem is required to use the DeliveryMethod class.'
|
5
|
+
end
|
6
|
+
|
7
|
+
module Net
|
8
|
+
module SMTPProxy
|
9
|
+
# for use with the mail gem
|
10
|
+
class DeliveryMethod < ::Mail::SMTP
|
11
|
+
private
|
12
|
+
|
13
|
+
# adapted from
|
14
|
+
# https://github.com/mikel/mail/blob/6bc16b4bce4fe280b19523c939b14a30e32a8ba4/lib/mail/network/delivery_methods/smtp.rb#L112
|
15
|
+
def build_smtp_session
|
16
|
+
init_params = [
|
17
|
+
settings[:address], settings[:port],
|
18
|
+
settings[:proxy_address], settings[:proxy_port]
|
19
|
+
]
|
20
|
+
|
21
|
+
Net::SMTPProxy::Proxy.new(*init_params).tap do |smtp|
|
22
|
+
if settings[:tls] || settings[:ssl]
|
23
|
+
if smtp.respond_to?(:enable_tls)
|
24
|
+
smtp.enable_tls(ssl_context)
|
25
|
+
end
|
26
|
+
elsif settings[:enable_starttls]
|
27
|
+
if smtp.respond_to?(:enable_starttls)
|
28
|
+
smtp.enable_starttls(ssl_context)
|
29
|
+
end
|
30
|
+
elsif settings[:enable_starttls_auto]
|
31
|
+
if smtp.respond_to?(:enable_starttls_auto)
|
32
|
+
smtp.enable_starttls_auto(ssl_context)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
smtp.open_timeout = settings[:open_timeout] if settings[:open_timeout]
|
37
|
+
smtp.read_timeout = settings[:read_timeout] if settings[:read_timeout]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'net/smtp'
|
2
|
+
require 'proxifier'
|
3
|
+
|
4
|
+
module Net
|
5
|
+
module SMTPProxy
|
6
|
+
class Proxy < SMTP
|
7
|
+
attr_reader :proxy_address, :proxy_port
|
8
|
+
|
9
|
+
def initialize(address, port, proxy_address, proxy_port)
|
10
|
+
super(address, port)
|
11
|
+
@proxy_address = proxy_address
|
12
|
+
@proxy_port = proxy_port
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def tcp_socket(address, port)
|
18
|
+
Proxifier::Proxy("#{proxy_address}:#{proxy_port}").open(address, port)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
|
2
|
+
require 'net/smtp-proxy/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'net-smtp-proxy'
|
6
|
+
s.version = ::Net::SMTPProxy::VERSION
|
7
|
+
s.authors = ['Cameron Dutro']
|
8
|
+
s.email = ['camertron@gmail.com']
|
9
|
+
s.homepage = 'http://github.com/camertron'
|
10
|
+
|
11
|
+
s.description = s.summary = "Proxy support for Ruby's Net::SMTP."
|
12
|
+
|
13
|
+
s.platform = Gem::Platform::RUBY
|
14
|
+
s.has_rdoc = true
|
15
|
+
|
16
|
+
s.add_dependency 'proxifier', '~> 1.0'
|
17
|
+
|
18
|
+
s.add_development_dependency 'rake', '~> 12'
|
19
|
+
s.add_development_dependency 'rspec', '~> 3.5'
|
20
|
+
|
21
|
+
s.require_path = 'lib'
|
22
|
+
s.files = Dir[
|
23
|
+
'{lib,spec}/**/*', 'Gemfile', 'README.md',
|
24
|
+
'Rakefile', 'net-smtp-proxy.gemspec'
|
25
|
+
]
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: net-smtp-proxy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cameron Dutro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: proxifier
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.5'
|
55
|
+
description: Proxy support for Ruby's Net::SMTP.
|
56
|
+
email:
|
57
|
+
- camertron@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- Gemfile
|
63
|
+
- Rakefile
|
64
|
+
- lib/net/smtp-proxy.rb
|
65
|
+
- lib/net/smtp-proxy/delivery_method.rb
|
66
|
+
- lib/net/smtp-proxy/proxy.rb
|
67
|
+
- lib/net/smtp-proxy/version.rb
|
68
|
+
- net-smtp-proxy.gemspec
|
69
|
+
homepage: http://github.com/camertron
|
70
|
+
licenses: []
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.7.6
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Proxy support for Ruby's Net::SMTP.
|
92
|
+
test_files: []
|