Using gmail to send email in Ruby on Rails

Bookmark and Share

Emails can be sent from you Rails application through many services like mandril, sendgrid, amazon SES. In this article, we would be explaining how we can send email using a Gmail credentials. Even though we can’t use it in production scenario due to the 500 email per day limitation, it would help us in prototyping an application quickly and also for cases where you want to send actual email in your development environment. Action Mailer is the ruby library in rails that will help us to do this.

Action Mailer allows you to send emails from your application using mailer classes and views. Mailers work very similarly to controllers. They inherit from ActionMailer::Base and live in app/mailers, and they have associated views that appear in app/views.To setup action mailer, must do the following:

1. Configuring the mailer in your environment file
2. Generating the mailer
3. Defining mailer action
4. Generating the mailer view
5. Delivering the email

Action Mailer Configuration

To configure action mailer add the following to your appropriate config/environments/$RAILS_ENV.rb file:


Generating the mailer

As you generate a controller for your application, you can …

Read More