Rails + GMail = Simple Email Delivery
Want to send email from your gmail account on your Rails site? Using this simple method you will be able to quickly achieve reliable email in your Rails app and not have to worry about maintaining multiple email configurations for every environment!
Start off by installing the action_mailer_tls plugin:
cd vendor/plugins/
svn export https://openrain.com/opensource/public/rails/plugins/action_mailer_tls action_mailer_tls
Now setup your environment.rb.
require "smtp_tls"
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.server_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'yourdomain.com',
:user_name => "you@yourdomain.com",
:password => "password",
:authentication => :plain
}
That's it!
Now you'll be able to send email through your GMail account while running in development, test, or production modes.
- Login or register to post comments
- 5522 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)










Comments
Jason Palmer replied on Wed, 2008/02/13 - 10:10am
I would highly recommend that you switch raise_delivery_errors to false when you open your application to the public.
Jason Palmer
Web Developer & Zone Leader
http://www.fanboom.com/
m3talsmith replied on Wed, 2008/10/15 - 8:12pm
A quick fix. The current SVN REPO is not valid. Use:
svn export http://code.openrain.com/rails/action_mailer_tls action_mailer_tls
instead.