Trying to use GMail SMTP (or some other SMTP authenticated with TLS) with ActiveRecord to send email in Ruby on Rails? Up till now this involved requiring smtp_tls.rb in your environment.
Thankfully, Kyle Maxwell has come up with a neater solution.
Install
It’s a plugin, which you can get with this command in your Rails root…
./script/plugin install http://svn.kylemaxwell.com/rails_plugins/action_mailer_optional_tls/trunk/
Due to continued downtime of Kyle’s site please use the following URl:
./script/plugin install http://svn.douglasfshearer.com/rails/plugins/action_mailer_optional_tls
Setup
You can turn TLS authentication on and off as you need in your environment with a new key that is added to the smtp config, tls. To use with gmail, the following should be in your environment.rb...
ActionMailer::Base.smtp_settings = {
:tls => true,
:address => "smtp.gmail.com",
:port => "587",
:domain => "YOURDOMAIN",
:authentication => :plain,
:user_name => "GOOGLEUSERNAME",
:password => "GOOGLEPASSWORD"
}
And that’s it. Enjoy.
Tags
Ruby on rails, Smtp, Plugin, Gmail, Actionmailer.
Related Posts
- Acts_As_Indexed now on GitHub
- JQuery on Rails
- Mod_Rails aka Passenger Migration and Review
- Scotland On Rails 2008 - Day Two
- Scotland On Rails 2008 - Day One





