simplificator-tls-support 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,46 @@
1
+ == tls-support
2
+ = where does it come from ?
3
+
4
+ We did not write this code. We just gem-ified it!
5
+
6
+ We could not find out who's the original author of this piece of code.
7
+ Looks like everyone copied from everyone, pasted some code here and there and so on.
8
+ Here are some places where you can find this code (or similar)
9
+ * http://www.ruby-forum.com/topic/160724
10
+ * http://brunomiranda.com/past/2007/11/5/in_need_of_an_smtp/
11
+ * http://groups.google.co.jp/group/rubyonrails-talk/browse_thread/thread/ab5b79feea255f5b
12
+ * http://pastie.org/pastes/255293/edit
13
+
14
+ If you are the original author, please contact us so we can add proper credits (or remove the gem or ...)
15
+
16
+ = what is it
17
+ TLS Support for Ruby. We use it to connect to GMail from ActionMailer.
18
+
19
+
20
+ = Installation
21
+ sudo gem update --system (in case you are not yet on version 1.2.0 or higher)
22
+ sudo gem sources -a http://gems.github.com (only once)
23
+ sudo gem install simplificator-tls-support
24
+
25
+
26
+ = Usage
27
+ # require the libs
28
+ just require the gem
29
+
30
+ # Sample ActionMailer Config
31
+
32
+ DEFAULT_FROM_ADDRESS = 'Simplificator Notifier <notifier@simplificator.com>'
33
+ config.action_mailer.raise_delivery_errors = true
34
+ config.action_mailer.perform_deliveries = true
35
+ config.action_mailer.delivery_method = :smtp
36
+ ActionMailer::Base.smtp_settings = {
37
+ :address => 'smtp.gmail.com',
38
+ :port => 587,
39
+ :authentication => :plain,
40
+ :user_name => 'notifier@simplificator.com',
41
+ :password => 'XYZXYZXYZ'
42
+ }
43
+ # You can use these settings to create URLS with the rails helpers in your mails
44
+ ActionMailer::Base.default_url_options[:host] = 'localhost'
45
+ ActionMailer::Base.default_url_options[:port] = '3000'
46
+
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'tls-support'
@@ -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
@@ -0,0 +1 @@
1
+ require 'tls-support/tls-support'
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simplificator-tls-support
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Simplificator GmbH
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-22 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: adds tls support to ruby. this is a piece of code found on many different places on the web. we just gem-ified it for easier use.
17
+ email: info@simplificator.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - lib/tls-support.rb
26
+ - lib/tls-support/tls-support.rb
27
+ - README
28
+ - init.rb
29
+ has_rdoc: false
30
+ homepage: http://simplificator.com/
31
+ post_install_message:
32
+ rdoc_options: []
33
+
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: "0"
41
+ version:
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ requirements: []
49
+
50
+ rubyforge_project:
51
+ rubygems_version: 1.2.0
52
+ signing_key:
53
+ specification_version: 2
54
+ summary: adds tls support
55
+ test_files: []
56
+