messaliberty

about hulor and us

How To Use Email To Create And Reply To Forums on Redmine

Redmine

Redmine

We’re using Redmine not only as a BTS (Bug Tracking System), but also as a project management tool. We used combination of Basecamp and Trac until  October but now we’re trying to decide on a single tool to manage projects and issues. Of course we’ll keep using Basecamp for some projects but it seems better to use only one tool to reduce management costs. Redmine is my answer. It’s a BTS and a collaboration tool.

One huge disadvantage of Redmine when I compare it with Basecamp was email updating feature. There is no good solution on Redmine to create and reply to forum messages. Email discussions are important for messaliberty. So I wrote some code to use the email – forum messages feature on Redmine 0.8.5.

First of all, I found this patch. Cool, try it.

Redmine – Patch #1616: Allow email to create and reply to forum messages – Redmine

But it seems to have some problems. It doesn’t seem to work well with recent versions.  So here’s how to fix that.

Apply the patch first

cd REDMINE_ROOT
wget http://www.redmine.org/attachments/download/753/feature_277_mailing_list_forum_integration_with_test_fixtures.diff
sudo patch -p0 -d . < feature_277_mailing_list_forum_integration_with_test_fixtures.diff

Then see ‘config/settings.yml.rej’ and apply the changes to ‘config/settings.yml’ manually.

***************
*** 44,49 ****
    default: '25,50,100'
  mail_from:
    default: redmine@somenet.foo
  bcc_recipients:
    default: 1
  text_formatting:
--- 44,51 ----
    default: '25,50,100'
  mail_from:
    default: redmine@somenet.foo
+ forum_mail_from:
+   default: ""
  bcc_recipients:
    default: 1
  text_formatting:

Fix some part of code

Fix ‘app/models/mail_handler.rb’.

Download: mail_handler.rb.diff

--- mail_handler.rb.orig	(original file)
+++ mail_handler.rb	        (working copy)
@@ -119,12 +119,12 @@
   # Creates a new forum message
   def receive_forum_message
     project = target_project
-    board = target_board
+    board = target_board(project)
     # check permission
     raise UnauthorizedAction unless user.allowed_to?(:edit_messages, project)
     message = Message.new(:author => user, :board => board)
     message.subject = email.subject.split(FORUM_MESSAGE_SUBJECT_SPLIT)[6].strip
-    message.content = email.plain_text_body.chomp
+    message.content = plain_text_body.chomp
     message.save!
     logger.info "MailHandler: message ##{message.id} - #{message.subject} created by #{user}" if logger && logger.info
     #Mailer.deliver_message_posted(message) if Setting.notified_events.include?('message_posted')
@@ -134,7 +134,7 @@
   # Creates a reply to an existing forum message
   def receive_forum_message_reply
     project = target_project
-    board = target_board
+    board = target_board(project)
     # check permission
     raise UnauthorizedAction unless user.allowed_to?(:edit_messages, project)
     message = Message.new(:author => user, :board => board)
@@ -144,7 +144,8 @@
                                      board, subject ],
                                      :order => "created_on DESC").id
     message.subject = "Re: " + subject
-    message.content = email.plain_text_body.chomp
+    # message.content = email.plain_text_body.chomp
+    message.content = plain_text_body.chomp
     message.save!
     logger.info "MailHandler: message ##{message.id} - #{message.subject} created by #{user} in reply to message ##{message.parent_id}" if logger && logger.info
     #Mailer.deliver_message_posted(message) if Setting.notified_events.include?('message_posted')
@@ -162,8 +163,10 @@
     target
   end

-  def target_board
-    target = Board.find_by_name(email.subject.split(FORUM_MESSAGE_SUBJECT_SPLIT)[4].strip)
+  def target_board(project)
+    target =  Board.find(:first,
+                         :conditions => [ "project_id = ? AND name = ?",
+                         project.id, email.subject.split(FORUM_MESSAGE_SUBJECT_SPLIT)[4].strip ])
     raise MissingInformation.new('Unable to determine target board/forum') if target.nil?
     target
   end

OK, now you can fetch emails from your email server. We’re using an IMAP access feature with a cron task. See the official documentation or the patch description page for more details.

And then we need to update a theme to make it like Basecamp.

Basecamp theme for Redmine

Good. But if you use the forums a lot, you should add CSS code below to see reply areas better.

h4 {background-color: #EDF3FE;}
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • Reddit
  • StumbleUpon
  • Technorati
  • MySpace
  • Tumblr
  • Yahoo! Buzz
  • Twitter

Related posts:

  1. 2 Keyboard Shortcuts You Must Know For Google Wave We’re using Google Wave for our internal text meetings. And...
  2. [Ruby on Rails] uninitialized constant ActiveSupport::~::ForRspec Today I got an error below with rake. What happened?...
  3. [Rails] use DataTime class with ActiveRecord column ActiveRecord’s :datetime corresponds to ruby Time class. But Time class...
  4. [Ruby] How to use RSpec – 01 QuickStart RSpec is one of ruby’s testing frameworks for BDD(Behavior Driven...

Related posts brought to you by Yet Another Related Posts Plugin.

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes