artofmission-action_mailer_tls 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.
@@ -0,0 +1,82 @@
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 => "noreply@gmail_or_your_google_domain.com",
72
+ :password => "chucknorris"
73
+ }
74
+
75
+
76
+
77
+ For more information on this feature, check out the [commit log](http://github.com/rails/rails/commit/732c724df61bc8b780dc42817625b25a321908e4)
78
+
79
+ Author
80
+ ------
81
+ * Marc Chung - marc [dot] chung [at] openrain [dot] com
82
+
@@ -0,0 +1,4 @@
1
+ ---
2
+ :patch: 3
3
+ :major: 1
4
+ :minor: 1
@@ -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,14 @@
1
+ # This file is automatically copied into RAILS_ROOT/initializers
2
+
3
+ require "smtp_tls"
4
+
5
+ config_file = "#{RAILS_ROOT}/config/smtp_gmail.yml"
6
+ raise "Sorry, you must have #{config_file}" unless File.exists?(config_file)
7
+
8
+ config_options = YAML.load_file(config_file)
9
+ ActionMailer::Base.smtp_settings = {
10
+ :address => "smtp.gmail.com",
11
+ :port => 587,
12
+ :authentication => :plain,
13
+ :enable_starttls_auto => true
14
+ }.merge(config_options) # Configuration options override default options
@@ -0,0 +1,3 @@
1
+ ---
2
+ :user_name: your_username@gmail.com
3
+ :password: h@ckme
@@ -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 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,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: artofmission-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 -05: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/config/initializers/smtp_gmail.rb
31
+ - generators/templates/config/smtp_gmail.yml.sample
32
+ - lib/smtp_tls.rb
33
+ has_rdoc: true
34
+ homepage: http://github.com/openrain/action_mailer_tls
35
+ licenses: []
36
+
37
+ post_install_message:
38
+ rdoc_options:
39
+ - --inline-source
40
+ - --charset=UTF-8
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project:
58
+ rubygems_version: 1.3.5
59
+ signing_key:
60
+ specification_version: 2
61
+ summary: Send Email via Gmail
62
+ test_files: []
63
+