A collection of computer systems and programming tips that you may find useful.
 
Brought to you by Craic Computing LLC, a bioinformatics consulting company.

Tuesday, June 2, 2009

Sending Email from Rails via Gmail

Sending email from a Rails application requires you to configure ActionMailer to use a SMTP mail server that is willing to handle your messages.

Using Google's Gmail is a good way to do this - reliable, free and likely to be around for a while. But going that route you need a slightly non-standard configuration and another gem as ActionMailer does not support the SSL/TLS (Transport Layer Security) that Gmail uses.

Various ways to do this show up in a web search but some of these seem a little outdated (Please add publication dates to your technical web posts!).

As of June 2009 with Rails 2.2.2, this post from Sam Pierson works for me.

1: sudo gem install tlsmail
2: Add the block he shows to the end of your environment.rb file (after the end of the Rails::Initializer.run block)

I use Gmail as part of Google Apps and in this case you want your gmail username to be your Google Apps email address (e.g. myname@mydomain.com and not just myname).


 

No comments:

Archive of Tips