View Issue Details

IDProjectCategoryView StatusLast Update
0007787mantisbtfeaturepublic2008-10-27 14:53
ReporterbugmenotAssigned Togiallu  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Fixed in Version1.1.0rc2 
Summary0007787: Robust threading of e-mails using MIME headers
Description

Currently theading of e-mails sent by Mantis doesn't work in all e-mail clients and will break completly if e-mail subjects are made variable (0004708).

Proper threading that works in most e-mail clients and is not subject-dependent can be implemented by generating appropriate MIME headers (http://www.apps.ietf.org/rfc/rfc2076.html#sec-3.6)

TagsNo tags attached.
Attached Files
add-headers.patch (1,325 bytes)   
Index: core/email_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/email_api.php,v
retrieving revision 1.127
diff -u -r1.127 email_api.php
--- core/email_api.php	6 Mar 2007 05:51:22 -0000	1.127
+++ core/email_api.php	23 Mar 2007 11:07:23 -0000
@@ -907,9 +907,19 @@
 
 		$t_message .= email_format_bug_message(  $p_visible_bug_data );
 
+		# build headers
+		$t_bug_id = $p_visible_bug_data['email_bug'];
+		$t_message_md5 = md5( $t_bug_id . $p_visible_bug_data['email_date_submitted'] );
+		$t_mail_headers = array( 'keywords' => $p_visible_bug_data['set_category'] );
+		if ( $p_message_id == 'email_notification_title_for_action_bug_submitted' ) {
+			$t_mail_headers[] = array('Message-ID' => "<{$t_message_md5}>" );
+		} else {
+			$t_mail_headers[] = array('In-Reply-To' => "<{$t_message_md5}>" );
+		}
+
 		# send mail
 		# PRINT '<br />email_bug_info::Sending email to :'.$t_user_email;
-		$t_ok = email_store( $t_user_email, $t_subject, $t_message, array( 'keywords' => $p_visible_bug_data['set_category'] ) );
+		$t_ok = email_store( $t_user_email, $t_subject, $t_message, $t_mail_headers );
 
 		return $t_ok;
 	}
@@ -1137,4 +1147,5 @@
 
 		return $t_bug_data;
 	}
-?>
\ No newline at end of file
+# vim: noexpandtab tabstop=4 softtabstop=0:
+?>
add-headers.patch (1,325 bytes)   

Relationships

has duplicate 0005085 closedgiallu Add in-reply-to: and References: headers to notification e-mails 
related to 0004512 acknowledged Patch: Add X-Mantis-* Headers to E-Mail 

Activities

giallu

giallu

2007-03-22 05:01

reporter   ~0014227

I'd really like to push this forward, as it seems to not so hard and very useful.

I investigated the issue using bugzilla as reference (where threaded emails support was added in 2.20), and their "trick" is in this few lines of code:

if ($isnew) {
$threadingmarker = "Message-ID: <bug-$id-" . $user->id . "$sitespec>";
} else {
$threadingmarker = "In-Reply-To: <bug-$id-" . $user->id . "$sitespec>";
}

of course, $threadingmarker is added later to the mail headers

giallu

giallu

2007-03-22 08:04

reporter   ~0014228

I attached a small patch to add a new header on the generated emails with the same method as bugzilla.

Generated mails seems to be correctly threaded in Gmail, with the exception of when one changes the summary (though this could be different with other clients)

vboctor

vboctor

2007-03-23 00:07

manager   ~0014235

Following are my comments on the patch:

  1. Revert your changes relating to removing empty lines between "if" statements.
  2. The In-Reply-To header is missing the closing angle bracket.
  3. I would move the thread id calculation logic into a separate method. I would calculate it as follows: md5( issue_id . date_submitted ). The problem with the current hash is that the reporter can change. Also there can be two sites with same issues and reporter id. I also don't see the value in bug prefix or number being in the clear (since the bug id will be added as a separate header).

Thanks for your contribution. Please attach an updated patch.

giallu

giallu

2007-03-23 06:10

reporter   ~0014237

The patch was updated to address your comments.

I hope this is fine enough for inclusion

vboctor

vboctor

2007-10-15 01:16

manager   ~0015869

The change looks good. I have a couple of questions?

  1. 'email_notification_title_for_action_bug_submitted' - Do we only get this when a bug is newly submitted or do we also get it when a bug status is changed back to "New"?

  2. What would happen if an issue is created and certain users are notified, then a user senders a reminder to another, or a new user adds a note. In this case such new users, will get In-Reply-To without Message-ID. What would happen in this case? Will they get a new thread and messages will be threaded normally?

Other than that, I think it is a useful and a simple change.

vboctor

vboctor

2007-10-19 03:51

manager   ~0015907

If this is to make it into 1.1.x branch, then we better get it in before the rc2 release.

giallu

giallu

2007-10-21 18:26

reporter   ~0015934

In reply to your previous comment:

  1. I think the former, since email_notification_title_for_action_bug_submitted is used by email_new_bug, which in turn if called only by bug_report.php

  2. I get in that situation quite often with bugzilla generated mails but never seen threading issues.

giallu

giallu

2007-10-21 18:34

reporter   ~0015935

Committed in BRANCH_1_1_0 (will merge to HEAD later)

Victor, please drop me a note when you update this Mantis instance, I'd like to see how effective it is on gmail.

Related Changesets

MantisBT: master-1.1.x b6de7a7c

2007-10-21 18:30

giallu


Details Diff
Fix 7787: Robust threading of e-mails using MIME headers

git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/branches/BRANCH_1_1_0@4657 <a class="text" href="/?p=mantisbt.git;a=object;h=f5dc347c">f5dc347c</a>-c33d-0410-90a0-b07cc1902cb9
Affected Issues
0007787
mod - core/email_api.php Diff File