Sending out emails from your Rails app never felt so easy. Gave Heroku’s free sendgrid addon a try today since I have an app already hosted on the cloud platform that requires a Mailer functionality.
Sendgrid has generously partnered with Heroku to provide its users 200 emails/messages a day and the integration is so seamless that all you need to do is just to add the addon, create your Mailer models and you’re done. Without the need to setup your ActionMailer settings, this is the perfect dream for those quick low-volume emails that you need to send out on your app.
- Rails 3.x
- Heroku-powered app
$ heroku addons:add sendgrid:free Adding sendgrid:free to myapp...done.
And that’s it!
(I’m not kidding)
Just get your ActionMailer Models setup and you’re sending emails before you could even say, ‘SMTP”.
Just remember that when you’re sending out your mail() in your ActionMailer, remember to set your ‘from’ field and end it off with a .deliver! else your email may not be sent. I myself used to get stuck in trying to debug Actionmailer in Rails 3 and all because I forgot the need to put .deliver at the end of the mail method.
mail(:from => "[email protected]", :to => "[email protected]", :subject => "Test email").deliver!