Using Gmail with Rails
Posted: 03/29/2009
To send email from Rails using your Google Apps account, you will need TLS support:
sudo gem install tlsmail
Next, edit environment.rb to look like this:
Rails::Initializer.run do |config| config.gem "tlsmail" ... end Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
Then add this to environments/development.rb:
config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :address => "smtp.gmail.com", :port => "25", :domain => "your_domain.com", :user_name => "your_login@your_domain.com", :password => "your_password", :authentication => :login }
Test it out by sending an email to yourself, create the model mailer.rb:
class Mailer < ActionMailer::Base def test from "your name <your_login@your_domain.com>" recipients ["your_login@your_domain.com"] subject "working?" body "sending from rails" end end
Finally, from script/console:
Mailer.deliver_test
I'm a skier, web developer, entrepreneur, freelancer, and all around stand-up guy living in Manhattan. This is me, repping one of my favorite shirts...