View Issue Details

IDProjectCategoryView StatusLast Update
0004512mantisbtemailpublic2012-04-03 00:48
Reporterchipux Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status acknowledgedResolutionopen 
Summary0004512: Patch: Add X-Mantis-* Headers to E-Mail
Description

This patch adds X-Mantis-* Headers to E-Mails to make it easier to sort incoming emails with any mail client.

http://www.carroll.edu/~chip/mantis_email_headers.patch

Tagspatch
Attached Files
add_email_headers.patch (1,823 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	22 Mar 2007 17:15:44 -0000
@@ -843,6 +843,9 @@
 		$t_subject = email_build_subject( $p_bug_id );
 		$t_date = date( config_get( 'normal_date_format' ) );
 		
+		# @@@ Iwao AVE! : Create custom headers for reminder email.
+		$t_custom_header_list = array( 'X-Mantis-Site' => config_get( 'path' ), 'X-Mantis-Action' => 'reminder', 'X-Mantis-Project' => $t_project_id, 'X-Mantis-Bugid' => $p_bug_id );
+		
 		$result = array();
 		foreach ( $p_recipients as $t_recipient ) {
 			lang_push( user_pref_get_language( $t_recipient, $t_project_id ) );
@@ -862,7 +865,7 @@
 							" \n\n$p_message";
 
 			if( ON == config_get( 'enable_email_notification' ) ) {
-				email_store( $t_email, $t_subject, $t_contents );
+				email_store( $t_email, $t_subject, $t_contents, $t_custom_header_list );
 			}
 
 			lang_pop();
@@ -907,9 +910,12 @@
 
 		$t_message .= email_format_bug_message(  $p_visible_bug_data );
 
+		# @@@ Iwao AVE! : Create custom headers for bug info email.
+		$t_custom_header_list = array( 'keywords' => $p_visible_bug_data['set_category'], 'X-Mantis-Site' => config_get( 'path' ), 'X-Mantis-Action' => 'info', 'X-Mantis-Project' => $p_project_id, 'X-Mantis-Bugid' => $p_visible_bug_data['email_bug'] );
+		
 		# 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_custom_header_list );
 
 		return $t_ok;
 	}
add_email_headers.patch (1,823 bytes)   
add_email_headers_20070323.patch (3,049 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 14:27:35 -0000
@@ -839,10 +839,23 @@
 		$t_project_id = bug_get_field( $p_bug_id, 'project_id' );
 		$t_sender_id = auth_get_current_user_id();
 		$t_sender = user_get_name( $t_sender_id );
+		$t_reporter = user_get_field( bug_get_field( $p_bug_id, 'reporter_id' ), 'username' );
+		$t_handler_id = bug_get_field( $p_bug_id, 'handler_id' );
+		if ( $t_handler_id != 0 ) {
+			$t_handler = user_get_field( $t_handler_id, 'username' );
+		} else {
+			$t_handler = '';
+		}
 
 		$t_subject = email_build_subject( $p_bug_id );
 		$t_date = date( config_get( 'normal_date_format' ) );
-		
+
+		# @@@ Iwao AVE! : Create custom headers for reminder email.
+		$t_custom_header_list = array();
+		$t_custom_header_list['X-Mantis-Site'] = config_get( 'path' );
+		$t_custom_header_list['X-Mantis-Type'] = 'reminder';
+		$t_custom_header_list['X-Mantis-Reporter'] = $t_reporter;
+
 		$result = array();
 		foreach ( $p_recipients as $t_recipient ) {
 			lang_push( user_pref_get_language( $t_recipient, $t_project_id ) );
@@ -855,6 +868,12 @@
 			} else {
 				$t_sender_email = '';
 			}
+			# @@@ Iwao AVE! : Check if handler exists and the recipient can see his/her name.
+			if ( $t_handler_id != 0 && access_has_project_level( config_get( 'view_handler_threshold' ), $t_project_id, $t_recipient ) ) {
+				$t_custom_header_list['X-Mantis-Owner'] = $t_handler;
+			} else {
+				$t_custom_header_list['X-Mantis-Owner'] = '';
+			}
 			$t_header = "\n" . lang_get( 'on' ) . " $t_date, $t_sender $t_sender_email " .
 						lang_get( 'sent_you_this_reminder_about' ) . ": \n\n";
 			$t_contents = $t_header .
@@ -862,7 +881,7 @@
 							" \n\n$p_message";
 
 			if( ON == config_get( 'enable_email_notification' ) ) {
-				email_store( $t_email, $t_subject, $t_contents );
+				email_store( $t_email, $t_subject, $t_contents, $t_custom_header_list );
 			}
 
 			lang_pop();
@@ -907,9 +926,17 @@
 
 		$t_message .= email_format_bug_message(  $p_visible_bug_data );
 
+		# @@@ Iwao AVE! : Create custom headers for bug info email.
+		$t_custom_header_list = array();
+		$t_custom_header_list['keywords'] = $p_visible_bug_data['set_category'];
+		$t_custom_header_list['X-Mantis-Site'] = config_get( 'path' );
+		$t_custom_header_list['X-Mantis-Type'] = 'notification';
+		$t_custom_header_list['X-Mantis-Reporter'] = $p_visible_bug_data['email_reporter'];
+		$t_custom_header_list['X-Mantis-Owner'] = $p_visible_bug_data['email_handler'];
+
 		# 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_custom_header_list );
 
 		return $t_ok;
 	}

Relationships

related to 0007787 closedgiallu Robust threading of e-mails using MIME headers 
has duplicate 0001569 closedvboctor [PATCH] Feature: add mantis-headers to sent mails 

Activities

vboctor

vboctor

2004-09-08 16:50

manager   ~0007502

chipux, thanks for the patch. Please check 0001569 to see if your patch covers points mentioned there.

ave

ave

2007-03-22 12:29

reporter   ~0014231

Uploaded a patch against revision 1.127 (1.1.0a3-CVS).
It appends four additional headers.

  • X-Mantis-Site : URL to your mantis (see issue:1569).
  • X-Mantis-Action : 'reminder' for reminder email; 'info' for bug info email.
  • X-Mantis-Project : ID of the project.
  • X-Mantis-Bugid : ID of the issue.

Note that I use project id instead of project name because I don't like multi byte characters to be in header. But it won't be difficult to change this behavior.

It would be better to merge this with issue:7787.

vboctor

vboctor

2007-03-23 00:24

manager   ~0014236

Thanks for your contribution. Following are my comments:

  1. Rename X-Mantis-Action to X-Mantis-Type, since this is the type of the email rather than the action the user took. I would also use "notification" rather than "info".

  2. Add X-Mantis-Owner and set to Handler Name (not real name).

  3. Add X-Mantis-Reporter and set to Reporter Name (not real name).

  4. Rename X-Mantis-Bugid to X-Mantis-IssueId. -- what is the use case for this? Do you expect users will build rules around issue id?

  5. Rename X-Mantis-Project to X-Mantis-ProjectId. -- I agree about your concern for including multi-byte chars in headers, but I don't like ProjectId as well. At the moment, users can build rules based on project name in the subject. I don't see when they will use a project id.

My recommendation is to drop 4 and 5 for now. Maybe one day we should introduce project short name like the unix name for projects hosted on sourceforge. This can then be added in the headers.

ave

ave

2007-03-23 09:41

reporter   ~0014238

Thanks for following up.
I have updated my patch as you suggested (add_email_headers_20070323.patch).

  • X-Mantis-Site : URL to your mantis.
  • X-Mantis-Type : 'reminder' for reminder email; 'notification' for others.
  • X-Mantis-Reporter : Reporter's short name (username).
  • X-Mantis-Owner : Handler's short name (username).

The project short name sounds better than id.
I look forward to see it's implemented :)

comargo

comargo

2012-04-03 00:48

reporter   ~0031589

Is there any chance that this patch will come to any release?