Ruby – Notification emails not working on Redmine using SMTP and Gmail

gmailredminerubysmtp

I have Redmine 2.2.1 installed and running, but I can't get the notification emails to work. I keep getting the following error:

An error occurred while sending mail (getaddrinfo: Name or service not known)

I can't figure out what it is I'm missing. I followed these instructions to set up email notifications using Gmail, but it seems like no matter what changes I make to my configuration.yml file I still get the same error.

This is what my configuration.xml file looks like:

production:
email_delivery:
  delivery_method: :smtp
smtp_settings:
  tls: true
  enable_starttls_auto: true
  address: "smtp.gmail.com"
  port: 587
  domain: "smtp.gmail.com"
  authentication: :plain
  user_name: "email@mydomain.com"
  password: "mypassword"

Everything else is commented out.

I tried changing and removing both the tls and enable_starttls_auto options but changes to the configuration.yml file do not affect the error message.

I also checked for the common mistakes that I found on other forums, like tabs in the configuration file or the production: config being defined twice, etc.

I enabled SMTP on my Gmail account.

I also tried setting up ActionMailer, but I'm not sure what I'm supposed to do with it or if I even need to do that. There was no mention of that being required anywhere. I have it installed and set up but not sure if that's doing anything.

Redmine 2.2.1
ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]
Rails 3.2.11
gem version 1.8.24
Amazon AMI Linux

production.log:

Started GET "/redmine/admin/test_email" for 98.xxx.xx.xx at Wed Jan 16 12:28:23 -0800     2013
Processing by AdminController#test_email as HTML
  Current user: oscarm (id=3)
  Rendered mailer/test_email.text.erb within layouts/mailer (0.1ms)
Redirected to http://mydomain/redmine/settings   /edit?tab=notifications
Completed 302 Found in 35ms (ActiveRecord: 0.7ms)
Started GET "/redmine/settings/edit?tab=notifications" for 98.xxx.xx.xx at Wed Jan 16 12:28:23 -0800 2013
Processing by SettingsController#edit as HTML
Parameters: {"tab"=>"notifications"}
Current user: oscarm (id=3)
Rendered settings/_general.html.erb (6.8ms)
Rendered settings/_display.html.erb (9.0ms)
Rendered settings/_authentication.html.erb (5.9ms)
Rendered settings/_projects.html.erb (5.9ms)
Rendered queries/_columns.html.erb (6.5ms)
Rendered settings/_issues.html.erb (12.6ms)
Rendered settings/_notifications.html.erb (6.4ms)
Rendered settings/_mail_handler.html.erb (1.9ms)
Rendered settings/_repositories.html.erb (10.3ms)
Rendered common/_tabs.html.erb (66.2ms)
Rendered settings/edit.html.erb within layouts/admin (67.0ms)
Rendered admin/_menu.html.erb (5.6ms)
Rendered layouts/base.html.erb (19.3ms)
Completed 200 OK in 222ms (Views: 91.3ms | ActiveRecord: 4.3ms)

Best Answer

So I figured out what my issues were...

  1. I kept making modifications to the configuration.yml file and expecting redmine to read it every time I reloaded the page but that wasn't the case. Redmine only reads the configuration files on startup so I had to restart redmine every time I made a change to the config file.

  2. One of the things I tried was installing the action_mailer_optional_tls plugin in redmine/plugin but I finaly found out that this plugin only works for ruby 1.8.6 and I'm using ruby 1.8.7 which has this functionality built-in. After removing the action_mailer_optional_tls directory from redmine/plugin and restarting redmine I was able to send notification emails :-)

So here's my final configuration to make redmine work with gmail:

production:
  email_delivery:
    delivery_method: :smtp
  smtp_settings:
    address: "smtp.gmail.com"
    port: 587
    domain: "smtp.gmail.com"
    authentication: :plain
    user_name: "myemail@mydomain.com"
    password: "mypassword"
    enable_starttls_auto: true

Hope this helps someone out there having the same issue.