|||

Video Transcript

X

Tech: Sending email with Gmail

These days, it seems like almost all apps need to send email. And everyone has a gmail account. So why not have your app send email through Gmail? It’s fairly easy with just a few steps.

Heroku currently runs Ruby 1.8.6. This means you need to provide your own SMTP TLS library. Luckily, Adam has made that super easy with a quick little Rails plugin. Simply install the library, set a few config variables, and you’re good to go. Best of all, this simple plugin will work on any provider. Use it even if you’re not on Heroku. It’s just a fast way to make sure your SMTP connection to Gmail is setup correctly.

1. Install the plugin

$ script/plugin install git://github.com/adamwiggins/gmail_smtp.git

2. Setup your environment variables on your local dev machine for testing

$ export GMAIL_SMTP_USER=username@gmail.com
$ export GMAIL_SMTP_PASSWORD=yourpassword

3. Try sending mail with ActionMailer.

Normal process here. You don’t need to config ActionMailer anywhere, this plugin will do it for you. In fact, if you have a config file setting up ActionMailer, remove it!

4. Set your variables on Heroku

$ heroku config:add GMAIL_SMTP_USER=username@gmail.com
$ heroku config:add GMAIL_SMTP_PASSWORD=yourpassword

5. That’s it!

You’re running with Gmail and Heroku.

For those looking for something a little more industrial, we have a great option in our add-on catalog with SendGrid. No limits on from address, 200 emails/day free, and some amazing features in the higher levels such as bounce tracking and full stats.

Originally published: November 09, 2009

Browse the archives for news or all blogs Subscribe to the RSS feed for news or all blogs.