Howto Setup Gmail SMTP on Rails
So now that I've configured this domain on Google Apps, how can I make use of the free e-mail service that Google is providing on my rails application?
Gmail SMTP server works with TLS and on a different port number, which threw me off at first, until I found this quick snipplet of code that does the trick.
Now this only works on Rails 2.2 and above as well as Ruby 1.8.7 and above. If you're using an older version of either Rails or Ruby (which I hope you're not), you have to install this plugin by Ambethia.
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'example.com',
:authentication => :plain,
:user_name => 'user',
:password => 'secret'
}
Also, a handy tip to check for SMTP errors is to set raise_delivery_errors to true in your config/environment.rb or mail initializer script. Like this:
ActionMailer::Base.raise_delivery_errors = true