ambethia-smtp-tls 1.0

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.
Files changed (2) hide show
  1. data/lib/smtp-tls.rb +65 -0
  2. metadata +53 -0
data/lib/smtp-tls.rb ADDED
@@ -0,0 +1,65 @@
1
+ require "openssl"
2
+ require "net/smtp"
3
+
4
+ Net::SMTP.class_eval do
5
+ private
6
+ def do_start(helodomain, user, secret, authtype)
7
+ raise IOError, 'SMTP session already started' if @started
8
+ check_auth_args user, secret, authtype if user or secret
9
+
10
+ sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
11
+ @socket = Net::InternetMessageIO.new(sock)
12
+ @socket.read_timeout = 60 #@read_timeout
13
+
14
+ check_response(critical { recv_response() })
15
+ do_helo(helodomain)
16
+
17
+ if starttls
18
+ raise 'openssl library not installed' unless defined?(OpenSSL)
19
+ ssl = OpenSSL::SSL::SSLSocket.new(sock)
20
+ ssl.sync_close = true
21
+ ssl.connect
22
+ @socket = Net::InternetMessageIO.new(ssl)
23
+ @socket.read_timeout = 60 #@read_timeout
24
+ do_helo(helodomain)
25
+ end
26
+
27
+ authenticate user, secret, authtype if user
28
+ @started = true
29
+ ensure
30
+ unless @started
31
+ # authentication failed, cancel connection.
32
+ @socket.close if not @started and @socket and not @socket.closed?
33
+ @socket = nil
34
+ end
35
+ end
36
+
37
+ def do_helo(helodomain)
38
+ begin
39
+ if @esmtp
40
+ ehlo helodomain
41
+ else
42
+ helo helodomain
43
+ end
44
+ rescue Net::ProtocolError
45
+ if @esmtp
46
+ @esmtp = false
47
+ @error_occured = false
48
+ retry
49
+ end
50
+ raise
51
+ end
52
+ end
53
+
54
+ def starttls
55
+ getok('STARTTLS') rescue return false
56
+ return true
57
+ end
58
+
59
+ def quit
60
+ begin
61
+ getok('QUIT')
62
+ rescue EOFError
63
+ end
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ambethia-smtp-tls
3
+ version: !ruby/object:Gem::Version
4
+ version: "1.0"
5
+ platform: ruby
6
+ authors:
7
+ - Unknown (gem packaged by Jason L Perry)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-05-21 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A gem package for the SMTP TLS code that's been floating around for years
17
+ email:
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - lib/smtp-tls.rb
26
+ has_rdoc: false
27
+ homepage:
28
+ post_install_message:
29
+ rdoc_options: []
30
+
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: "0"
38
+ version:
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ requirements: []
46
+
47
+ rubyforge_project:
48
+ rubygems_version: 1.0.1
49
+ signing_key:
50
+ specification_version: 2
51
+ summary: SMTP TLS (SSL) extension for Net::SMTP
52
+ test_files: []
53
+