Thursday, July 2, 2009

Sending Email on Rails via Gmail

If you need to send an email via Gmail on a Rails application ( and if you are running Rails >= 2.2.1 with Ruby 1.8.6 )

1) Register a gmail account

2) Install the ActionMailer_tls gem from http://github.com/openrain/action_mailer_tls/tree/master

3) Follow the instruction on the readme of the Gem,

  • To install the gem (the preferred way):1. `sudo gem install openrain-action_mailer_tls -s http://gems.github.com`
    2. `./script/generate action_mailer_tls`
    3. Copy RAILS_ROOT/config/smtp_gmail.yml.sample to RAILS_ROOT/config/smtp_gmail.yml
    4. Update the configuration file with your settings by keying in your gmail username and password on smtp_gmail.yml


Make sure the username includes @gmail.com in the smtp_gmail.yml file
:user_name: testing123@gmail.com
:password: thisisatestpassword

And you are good to go, in order to test if the mail is actually sent, follow the testing instruction in the README.

Thanks to http://www.justinball.com/2009/06/25/sending-email-with-ruby-on-rails-2-3-2-and-gmail/

0 comments:

Post a Comment