I have seen many articles in the web that explain how to send an email with a Google account from a Ruby On Rails application.
However, I believe there are several faulty or incomplete examples around.
That’s why I decided to share a working solution that I used in various projects.
The main problem with Gmail (or with an address linked to Google Apps) is that prompts for an SSL connection.
As often happens with Ruby On Rails, the solution is quite simple.
You just need to install the gem tlsmail with the command:
gem install tlsmail
After that, just set the parameters for the desired mailbox, for example within the mail.rb initializer or where you think is better for you, taking care to add the line
and to set the :tls => true parameter.
Here’s the full snippet:
#Configure mail ony for production mode
You can see how, using the gem tlsmail, configure your Google mail account become very simple.