jigfox-action_mailer_tls 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,9 @@
1
+ == 1.1.3 / 2009-02-11
2
+ * Updated LICENSE and NOTICE to Apache 2.0
3
+
4
+ == 1.1.0 / 2009-02-10
5
+ * Converted plugin into a Rubygem with a Rails generator.
6
+ * Updated README with installation details.
7
+
8
+ == 1.0.0 / 2009-02-09
9
+ * Tagging original SVN migration.
data/README.markdown ADDED
@@ -0,0 +1,80 @@
1
+ ActionMailerTLS
2
+ ===============
3
+
4
+ Background
5
+ ----------
6
+
7
+ This gem makes it trivial to send email through a Gmail account or a Google Apps for business email account.
8
+
9
+ This gem will only work on Ruby 1.8.6. If you're on Ruby 1.8.7 and Rails >= 2.2.1, you don't need this gem. See Notes below.
10
+
11
+ Installation
12
+ ------------
13
+
14
+
15
+ To install the gem (the preferred way):
16
+
17
+ 1. `sudo gem install openrain-action_mailer_tls -s http://gems.github.com`
18
+ 2. `./script/generate action_mailer_tls`
19
+ 3. Copy RAILS_ROOT/config/smtp_gmail.yml.sample to RAILS_ROOT/config/smtp_gmail.yml
20
+ 4. Update the configuration file with your settings
21
+
22
+ To (optionally) vendor this gem:
23
+
24
+ 1. Add the following entry to config/environment.rb
25
+ * config.gem "openrain-action_mailer_tls", :lib => "smtp_tls.rb", :source => "http://gems.github.com"
26
+ 2. rake gems:unpack
27
+
28
+ To install the plugin (the old way):
29
+
30
+ 1. `./script/plugin install git://github.com/openrain/action_mailer_tls.git -r 'tag v1.0.0'`
31
+ 2. Copy vendor/plugins/action_mailer_tls/sample/smtp_gmail.rb to config/
32
+ 3. Copy vendor/plugins/action_mailer_tls/sample/mailer.yml.sample to config/
33
+ 4. Update the configuration file with your settings
34
+
35
+ Testing it out
36
+ --------------
37
+
38
+ 1. `./script/generate mailer Notifier hello_world`
39
+ 2. Add the following lines to config/environments/development.rb
40
+ * config.action_mailer.raise_delivery_errors = true
41
+ * config.action_mailer.perform_deliveries = true
42
+ * config.action_mailer.delivery_method = :smtp
43
+ 3. Update the recipients and from fields in app/models/notifier.rb
44
+ 4. `./script/console `
45
+ 5. `Notifier.deliver_hello_world!`
46
+
47
+ Resources
48
+ ---------
49
+
50
+ Blog posts
51
+
52
+ * [How to use Gmail's SMTP server with Rails](http://www.rubyinside.com/how-to-use-gmails-smtp-server-with-rails-394.html)
53
+ * [Configuring Rails to use Gmail's SMTP server](http://www.prestonlee.com/2007/02/20/configuring-rails-to-use-gmails-smtp-server/63/)
54
+
55
+ Books
56
+
57
+ * This gem was also featured in Advanced Rails Recipes pg. 238, Recipe #47.
58
+
59
+ Notes
60
+ -----
61
+
62
+ If you're running Rails >= 2.2.1 [RC2] and Ruby 1.8.7, you don't need this gem. Ruby 1.8.7 supports
63
+ SMTP TLS and Rails 2.2.1 ships with an option to enable it if you're running Ruby 1.8.7.
64
+
65
+ To set it all up, in config/initializers/smtp_gmail.rb, make sure to set `:enable_starttls_auto` to `true`.
66
+ ActionMailer::Base.smtp_settings = {
67
+ :address => "smtp.gmail.com",
68
+ :port => 587,
69
+ :authentication => :plain,
70
+ :enable_starttls_auto => true,
71
+ :user_name => 'your_username@gmail.com',
72
+ :password => 'h@ckme'
73
+ }
74
+
75
+ For more information on this feature, check out the [commit log](http://github.com/rails/rails/commit/732c724df61bc8b780dc42817625b25a321908e4)
76
+
77
+ Author
78
+ ------
79
+ * Marc Chung - marc [dot] chung [at] openrain [dot] com
80
+
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :patch: 3
3
+ :major: 1
4
+ :minor: 1
data/generators/USAGE ADDED
@@ -0,0 +1,16 @@
1
+ Description:
2
+ The action_mailer_tls generator adds smtp-tls support to your Rails projects.
3
+
4
+ The generator takes no arguments and only needs to be run once. It will create
5
+ a Rails initializer for Gmail, and a sample YAML configuration file.
6
+
7
+ Modify the contents of the configuration file with your Gmail username and
8
+ password
9
+
10
+ Example:
11
+ ./script/generate action_mailer_tls
12
+
13
+ This will create the following files:
14
+ Initializer: config/initializers/smtp_gmail.rb
15
+ Config: config/smtp_gmail.yml.sample
16
+
@@ -0,0 +1,11 @@
1
+ # This generator intalls ActionMailerTLS into a Rails project
2
+ class ActionMailerTlsGenerator < Rails::Generator::Base
3
+
4
+ def manifest
5
+ record do |m|
6
+ m.file "config/smtp_gmail.yml.sample", "config/smtp_gmail.yml.sample"
7
+ m.file "config/initializers/smtp_gmail.rb", "config/initializers/smtp_gmail.rb"
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,20 @@
1
+ # This file is automatically copied into RAILS_ROOT/initializers
2
+
3
+ require "smtp_tls"
4
+
5
+ ActionMailer::Base.smtp_settings = {
6
+ :address => "smtp.gmail.com",
7
+ :port => 587,
8
+ :authentication => :plain,
9
+ :enable_starttls_auto => true
10
+ }
11
+
12
+ unless ENV['GMAIL_USER'] && ENV['GMAIL_PASS']
13
+ config_file = "#{RAILS_ROOT}/config/smtp_gmail.yml"
14
+ raise "Sorry, you must have #{config_file}" unless File.exists?(config_file) || ENV['EMAIL']
15
+
16
+ config_options = YAML.load_file(config_file)
17
+ ActionMailer::Base.smtp_settings.merge(config_options) # Configuration options override default options
18
+ else
19
+ ActionMailer::Base.smtp_settings.merge({:user_name => ENV['GMAIL_USER'], :password => ENV['GMAIL_PASS']})
20
+ end
@@ -0,0 +1,3 @@
1
+ ---
2
+ :user_name: your_username@gmail.com
3
+ :password: h@ckme
data/lib/smtp_tls.rb ADDED
@@ -0,0 +1,72 @@
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
+ if user or secret
9
+ case method(:check_auth_args).arity
10
+ when 3
11
+ check_auth_args user, secret, authtype
12
+ when 2
13
+ check_auth_args user, secret
14
+ end
15
+ end
16
+
17
+ sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
18
+ @socket = Net::InternetMessageIO.new(sock)
19
+ @socket.read_timeout = 60 #@read_timeout
20
+
21
+ check_response(critical { recv_response() })
22
+ do_helo(helodomain)
23
+
24
+ if starttls
25
+ raise 'openssl library not installed' unless defined?(OpenSSL)
26
+ ssl = OpenSSL::SSL::SSLSocket.new(sock)
27
+ ssl.sync_close = true
28
+ ssl.connect
29
+ @socket = Net::InternetMessageIO.new(ssl)
30
+ @socket.read_timeout = 60 #@read_timeout
31
+ do_helo(helodomain)
32
+ end
33
+
34
+ authenticate user, secret, authtype if user
35
+ @started = true
36
+ ensure
37
+ unless @started
38
+ # authentication failed, cancel connection.
39
+ @socket.close if not @started and @socket and not @socket.closed?
40
+ @socket = nil
41
+ end
42
+ end
43
+
44
+ def do_helo(helodomain)
45
+ begin
46
+ if @esmtp
47
+ ehlo helodomain
48
+ else
49
+ helo helodomain
50
+ end
51
+ rescue Net::ProtocolError
52
+ if @esmtp
53
+ @esmtp = false
54
+ @error_occured = false
55
+ retry
56
+ end
57
+ raise
58
+ end
59
+ end
60
+
61
+ def starttls
62
+ getok('STARTTLS') rescue return false
63
+ return true
64
+ end
65
+
66
+ def quit
67
+ begin
68
+ getok('QUIT')
69
+ rescue EOFError
70
+ end
71
+ end
72
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jigfox-action_mailer_tls
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Marc Chung
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-02-11 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Conveniently send emails through Google's Hosted App service
17
+ email: marc.chung@openrain.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - History.txt
26
+ - README.markdown
27
+ - VERSION.yml
28
+ - generators/USAGE
29
+ - generators/action_mailer_tls_generator.rb
30
+ - generators/templates
31
+ - generators/templates/config
32
+ - generators/templates/config/initializers
33
+ - generators/templates/config/initializers/smtp_gmail.rb
34
+ - generators/templates/config/smtp_gmail.yml.sample
35
+ - lib/smtp_tls.rb
36
+ has_rdoc: true
37
+ homepage: http://github.com/openrain/action_mailer_tls
38
+ licenses:
39
+ post_install_message:
40
+ rdoc_options:
41
+ - --inline-source
42
+ - --charset=UTF-8
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ requirements: []
58
+
59
+ rubyforge_project:
60
+ rubygems_version: 1.3.5
61
+ signing_key:
62
+ specification_version: 2
63
+ summary: Send Email via Gmail
64
+ test_files: []
65
+