A solution for: An error occurred while sending mail (SSL_connect returned=1 errno=0 state=unknown state: unknown protocol) in Redmine 2.0 / Rails 3.2.3

Being a Drupal developer I do use magnificent redmine (http://redmine.org) to manage my tasks and projects. If you don't know, Redmine is a Rails-based application so from time to time I have my hands dirty with ruby code (it doesn't hurt at all ;)).

Today I decided to upgrade our internal redmine installation from version 1.4 to 2.0. The upgrade process went very smooth, but in the end I encountered a problem with mail sending. Every attempt to send an email from redmine installation led to the error message: An error occurred while sending mail (SSL_connect returned=1 errno=0 state=unknown state: unknown protocol). I use Google Apps SMTP servers for mail, so my configuration file looked something like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  1. production:
  2. email_delivery:
  3. delivery_method: :smtp
  4. smtp_settings:
  5. tls: true
  6. enable_starttls_auto: true
  7. address: "smtp.gmail.com"
  8. port: 587
  9. domain: "smtp.gmail.com" # 'your.domain.com' for GoogleApps
  10. authentication: :plain
  11. user_name: "your_email@gmail.com"
  12. password: "your_password"
With redmine 1.4 these settings worked just fine, but redmine 2.0 made a major jump from Rails 2.3.x to rails 3.2.x and, as it usually happens in the Rails world, something has changed in the internals. In the end it turned out that you can't have both tls: true and enable_starttls_auto: true in your settings, so you need to comment tls: true setting and your redmine will be able to send email messages via Google's SMTP. Hope this will be helpful to someone.