• Home »
  • Insights »
  • Redmine: The following error occured while sending email notification: 530 5.7.0 Must issue a STARTTLS command first.

Redmine: The following error occured while sending email notification: 530 5.7.0 Must issue a STARTTLS command first.

Recently while working on a CentOS Linux server I downgraded Ruby version 1.8.7 p302 to Ruby version 1.8.6 p399 because of a project that was built for Ruby 1.8.6. The server is a development CentOS Linux server with numerous other projects already operational on it and so downgrading Ruby caused a couple issues one of which was with Redmine project management software. The issue was with sending email notifications for things such as file uploads, added issues, issue updates, etc. Below I describe the error in more detail, the reason for the error, and how to resolve the error sending email notifications.

Redmine Email Notification Sent Through Gmail Error:

bash

  1. Processing FilesController#new (for 192.168.33.111 at 2010-12-10 19:12:36) [POST]
  2.   Parameters: {"commit"=>"Add", "action"=>"new", "authenticity_token"=>"PuUCYzvUiAoRqMxM/QUiIEMAUFCqHbMJ5MvlsqsLkBU=", "id"=>"project1", "controller"=>"files", "version_id"=>"", "attachments"=>{"1"=>{"description"=>"test", "file"=>#<File:/tmp/RackMultipart.30276.1>
  3. }}}
  4. Sending email notification to: alex@example.com
  5. The following error occured while sending email notification: "530 5.7.0 Must issue a STARTTLS command first. x4sm34445550icr.10
  6. ". Check your configuration in config/email.yml.
  7. Redirected to https://redmine.example.com/projects/project1/files
  8. Completed in 178ms (DB: 43) | 302 Found [https://redmine.example.com/projects/project1/files/new]

As you can see above the production.log file provides details about the error stating that a STARTTLS command must be issued before the notifications can be sent. On this server we send all Redmine notifications through Gmail. At first I was confused because this had previously been working fine but then I remembered I had to change some things related to Redmine email notification when I had upgraded to Ruby 1.8.7.

Redmine Email Notifications Via Gmail Using Ruby 1.8.6 & Using Ruby 1.8.7 Explained:

The issue is that Ruby 1.8.7 has enable_starttls_auto built in but Ruby 1.8.6 does not. After refreshing my memory I remembered that when using Redmine with Ruby 1.8.6 you are required to install a plugin called action_mailer_optional_tls to get email notifications through Gmail to function properly. Once I had upgraded to Ruby 1.8.7 I removed the action_mailer_optional_tls because it was no longer needed because of the addition of enable_starttls_auto. Since I downgraded Ruby to version 1.8.6 I had to also reinstall action_mailer_optional_tls and modify the email.yml file to get email notifications through Gmail to function properly again.

Redmine Email Notifications Through Gmail With Ruby 1.8.6:

First you need to install the action_mailer_optional_tls Redmine plugin which can be done using the below command from the Redmine Ruby project’s root directory.

Install Redmine action_mailer_optional_tls Plugin:

bash

  1. ruby script/plugin install git://github.com/collectiveidea/action_mailer_optional_tls.git

The above command will install action_mailer_optional_tls into “redmine-project-root/vendor/plugins”. Once this is installed modify your email.yml to be similar to the below example email.yml but obviously changing the specifics to your own. The email.yml file is located in the config directory underneath the Redmine projects root directory.

Example email.yml For Ruby Version 1.8.6:

ruby

  1. # Outgoing email settings
  2. production:
  3.   delivery_method: :smtp
  4.   smtp_settings:
  5.     tls: true
  6.     address: "smtp.gmail.com"
  7.     port: '587'
  8.     domain: "DOMAIN"
  9.     authentication: :plain
  10.     user_name: "GMAIL USERNAME (ex: user@domain.com)"
  11.     password: "CHANGE PASSWORD"
  12.  
  13. production:
  14.   delivery_method: :smtp
  15.   smtp_settings:
  16.     tls: true
  17.     address: "smtp.gmail.com"
  18.     port: '587'
  19.     domain: "DOMAIN"
  20.     authentication: :plain
  21.     user_name: "GMAIL USERNAME (ex: user@domain.com)"
  22.     password: "CHANGE PASSWORD"

If you do not have a domain pointed to Google for email then just use smtp.gmail.com for the domain settings.

Redmine Email Notifications Through Gmail With Ruby 1.8.7:

With Ruby 1.8.7 the configuration is a little bit easier since you do not have to install a plugin to have it function properly. If you have Ruby 1.8.7 or any version of Ruby greater than 1.8.7 then the example email.yml file should work properly for you. If you previously had the action_mailer_optional_tls plugin installed it can now be removed.

Example email.yml For Ruby Version 1.8.6:

ruby

  1. # Outgoing email settings
  2.  
  3. production:
  4.   delivery_method: :smtp
  5.   smtp_settings:
  6.     tls: true
  7.     enable_starttls_auto: true
  8.     address: smtp.gmail.com
  9.     port: 587
  10.     domain: "GMAIL DOMAIN"
  11.     authentication: :login
  12.     user_name: "GMAIL USERNAME (ex: redmine@example.com)"
  13.     password: "GMAIL PASSWORD"
  14.  
  15. production:
  16.   delivery_method: :smtp
  17.   smtp_settings:
  18.     tls: true
  19.     enable_starttls_auto: true
  20.     address: smtp.gmail.com
  21.     port: 587
  22.     domain: "GMAIL DOMAIN"
  23.     authentication: :login
  24.     user_name: "GMAIL USERNAME (ex: redmine@example.com)"
  25.     password: "GMAIL PASSWORD"

Once the email.yml file has been modified on either version of Ruby simply restart your web server and then test. You can tail the production.log file to verify the notifications are being sent properly.

Beginning Ruby: From Novice to Professional (Expert’s Voice in Open Source) (Paperback)


List Price: $39.99 USD
New From: $23.00 USD In Stock
Used from: $16.49 USD In Stock

The Ruby Programming Language (Paperback)


List Price: $39.99 USD
New From: $14.47 USD In Stock
Used from: $8.66 USD In Stock

Share