smtp_tls 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +1 -0
- data/History.txt +6 -0
- data/Manifest.txt +5 -0
- data/README.txt +46 -0
- data/Rakefile +16 -0
- data/lib/smtp_tls.rb +119 -0
- metadata +106 -0
- metadata.gz.sig +3 -0
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
C�����%t4����,�(��I_�x�Ew�����T�%�f˜���4W���DR���� �
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
= smtp_tls
|
2
|
+
|
3
|
+
* http://seattlerb.rubyforge.org/smtp_tls
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Provides SMTP STARTTLS support for Ruby 1.8.6 (built-in for 1.8.7+). Simply
|
8
|
+
require 'smtp_tls' and use the Net::SMTP#enable_starttls method to talk to
|
9
|
+
servers that use STARTTLS.
|
10
|
+
|
11
|
+
require 'smtp_tls'
|
12
|
+
|
13
|
+
smtp = Net::SMTP.new address, port
|
14
|
+
smtp.enable_starttls
|
15
|
+
smtp.start Socket.gethostname, user, password, authentication do |server|
|
16
|
+
server.send_message message, from, to
|
17
|
+
end
|
18
|
+
|
19
|
+
== INSTALL:
|
20
|
+
|
21
|
+
sudo gem install smtp_tls
|
22
|
+
|
23
|
+
== LICENSE:
|
24
|
+
|
25
|
+
Original code believed public domain from ruby-talk or ruby-core email.
|
26
|
+
|
27
|
+
Modifications Copyright (c) 2009 Kyle Maxwell <kyle@kylemaxwell.com>
|
28
|
+
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
30
|
+
a copy of this software and associated documentation files (the
|
31
|
+
'Software'), to deal in the Software without restriction, including
|
32
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
33
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
34
|
+
permit persons to whom the Software is furnished to do so, subject to
|
35
|
+
the following conditions:
|
36
|
+
|
37
|
+
The above copyright notice and this permission notice shall be
|
38
|
+
included in all copies or substantial portions of the Software.
|
39
|
+
|
40
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
41
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
42
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
43
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
44
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
45
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
46
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
Hoe.plugin :seattlerb
|
7
|
+
|
8
|
+
Hoe.spec 'smtp_tls' do
|
9
|
+
developer 'Eric Hodel', 'drbrain@segment7.net'
|
10
|
+
developer 'Kyle Maxwell', ''
|
11
|
+
self.rubyforge_name = 'seattlerb'
|
12
|
+
|
13
|
+
spec_extras['required_ruby_version'] = '~> 1.8.6.0'
|
14
|
+
end
|
15
|
+
|
16
|
+
# vim: syntax=Ruby
|
data/lib/smtp_tls.rb
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
|
2
|
+
require 'openssl'
|
3
|
+
require 'net/smtp'
|
4
|
+
|
5
|
+
# :stopdoc:
|
6
|
+
|
7
|
+
class Net::SMTP
|
8
|
+
|
9
|
+
class SMTP_TLS
|
10
|
+
VERSION = '1.0'
|
11
|
+
end
|
12
|
+
|
13
|
+
class << self
|
14
|
+
send :remove_method, :start
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.default_ssl_context
|
18
|
+
OpenSSL::SSL::SSLContext.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.start(address, port = nil, helo = 'localhost.localdomain',
|
22
|
+
user = nil, secret = nil, authtype = nil, &block) # :yield: smtp
|
23
|
+
smtp = new address, port
|
24
|
+
smtp.start helo, user, secret, authtype, &block
|
25
|
+
end
|
26
|
+
|
27
|
+
def enable_starttls(context = Net::SMTP.default_ssl_context)
|
28
|
+
raise 'openssl library not installed' unless defined?(OpenSSL)
|
29
|
+
@starttls = :always
|
30
|
+
@ssl_context = context
|
31
|
+
end
|
32
|
+
|
33
|
+
alias tls_old_start start
|
34
|
+
|
35
|
+
def start(helo = 'localhost.localdomain',
|
36
|
+
user = nil, secret = nil, authtype = nil) # :yield: smtp
|
37
|
+
start_method = @starttls ? :do_tls_start : :do_start
|
38
|
+
|
39
|
+
if block_given?
|
40
|
+
begin
|
41
|
+
send start_method, helo, user, secret, authtype
|
42
|
+
return yield(self)
|
43
|
+
ensure
|
44
|
+
do_finish
|
45
|
+
end
|
46
|
+
else
|
47
|
+
send start_method, helo, user, secret, authtype
|
48
|
+
return self
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def starttls
|
53
|
+
getok 'STARTTLS'
|
54
|
+
end
|
55
|
+
|
56
|
+
alias tls_old_quit quit # :nodoc:
|
57
|
+
|
58
|
+
def quit
|
59
|
+
begin
|
60
|
+
getok 'QUIT'
|
61
|
+
rescue EOFError
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def do_tls_start(helodomain, user, secret, authtype)
|
68
|
+
raise IOError, 'SMTP session already started' if @started
|
69
|
+
check_auth_args user, secret, authtype if user or secret
|
70
|
+
|
71
|
+
sock = timeout(@open_timeout) { TCPSocket.open @address, @port }
|
72
|
+
@socket = Net::InternetMessageIO.new(sock)
|
73
|
+
@socket.read_timeout = 60 # @read_timeout
|
74
|
+
|
75
|
+
check_response(critical { recv_response() })
|
76
|
+
do_helo helodomain
|
77
|
+
|
78
|
+
raise 'openssl library not installed' unless defined?(OpenSSL)
|
79
|
+
starttls
|
80
|
+
ssl = OpenSSL::SSL::SSLSocket.new sock, @ssl_context
|
81
|
+
ssl.sync_close = true
|
82
|
+
ssl.connect
|
83
|
+
if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE then
|
84
|
+
ssl.post_connection_check(@address)
|
85
|
+
end
|
86
|
+
|
87
|
+
@socket = Net::InternetMessageIO.new ssl
|
88
|
+
@socket.read_timeout = 60 # @read_timeout
|
89
|
+
do_helo helodomain
|
90
|
+
|
91
|
+
authenticate user, secret, authtype if user
|
92
|
+
@started = true
|
93
|
+
ensure
|
94
|
+
unless @started then
|
95
|
+
# authentication failed, cancel connection.
|
96
|
+
@socket.close if not @started and @socket and not @socket.closed?
|
97
|
+
@socket = nil
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def do_helo(helodomain)
|
102
|
+
begin
|
103
|
+
if @esmtp then
|
104
|
+
ehlo helodomain
|
105
|
+
else
|
106
|
+
helo helodomain
|
107
|
+
end
|
108
|
+
rescue Net::ProtocolError
|
109
|
+
if @esmtp then
|
110
|
+
@esmtp = false
|
111
|
+
@error_occured = false
|
112
|
+
retry
|
113
|
+
end
|
114
|
+
raise
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
end unless Net::SMTP.method_defined? :starttls
|
119
|
+
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: smtp_tls
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "1.0"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric Hodel
|
8
|
+
- Kyle Maxwell
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain:
|
12
|
+
- |
|
13
|
+
-----BEGIN CERTIFICATE-----
|
14
|
+
MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMRAwDg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cq0OJNGEWBfgD9q7rrs/X8GGwUWqXb85RXnUVi/P8Up75E0ag
|
30
|
+
14jEc90kN+C7oI/AGCBN0j6JnEtYIEJZibjjDJTSMWlUKKkj30kq7hlUC2CepJ4v
|
31
|
+
x52qPcexcYZR7w==
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
|
34
|
+
date: 2009-06-24 00:00:00 -07:00
|
35
|
+
default_executable:
|
36
|
+
dependencies:
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: hoe
|
39
|
+
type: :development
|
40
|
+
version_requirement:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.3.0
|
46
|
+
version:
|
47
|
+
description: |-
|
48
|
+
Provides SMTP STARTTLS support for Ruby 1.8.6 (built-in for 1.8.7+). Simply
|
49
|
+
require 'smtp_tls' and use the Net::SMTP#enable_starttls method to talk to
|
50
|
+
servers that use STARTTLS.
|
51
|
+
|
52
|
+
require 'smtp_tls'
|
53
|
+
|
54
|
+
smtp = Net::SMTP.new address, port
|
55
|
+
smtp.enable_starttls
|
56
|
+
smtp.start Socket.gethostname, user, password, authentication do |server|
|
57
|
+
server.send_message message, from, to
|
58
|
+
end
|
59
|
+
email:
|
60
|
+
- drbrain@segment7.net
|
61
|
+
- ""
|
62
|
+
executables: []
|
63
|
+
|
64
|
+
extensions: []
|
65
|
+
|
66
|
+
extra_rdoc_files:
|
67
|
+
- History.txt
|
68
|
+
- Manifest.txt
|
69
|
+
- README.txt
|
70
|
+
files:
|
71
|
+
- History.txt
|
72
|
+
- Manifest.txt
|
73
|
+
- README.txt
|
74
|
+
- Rakefile
|
75
|
+
- lib/smtp_tls.rb
|
76
|
+
has_rdoc: true
|
77
|
+
homepage: http://seattlerb.rubyforge.org/smtp_tls
|
78
|
+
licenses: []
|
79
|
+
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options:
|
82
|
+
- --main
|
83
|
+
- README.txt
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.8.6.0
|
91
|
+
version:
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: "0"
|
97
|
+
version:
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project: seattlerb
|
101
|
+
rubygems_version: 1.3.4
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: Provides SMTP STARTTLS support for Ruby 1.8.6 (built-in for 1.8.7+)
|
105
|
+
test_files: []
|
106
|
+
|
metadata.gz.sig
ADDED