View Issue Details

IDProjectCategoryView StatusLast Update
0013692mantisbtemailpublic2016-08-09 04:15
Reporterkkroflin Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Summary0013692: Extending e-mail notifications with a short summary of changed properties
Description

We've been using Mantis for our projects for several years now. We, developers, and our customers hadn't been satisfied with e-mail notification primary because it had been hard to quickly read changes. Recently, I've added a short summary of changed properties to the top of the e-mail notification so that it would be easy to find changes. Basically, to regular e-mail notification, new notes and new items in issue history have been added to the top.

If you want to include this in the Mantis source, I can submit a patch.

Additional Information

Example of an e-mail:

The following issue has been ASSIGNED.

Changed


(0000015) administrator (administrator) - 2011-12-21 19:06
https://<hostname>/mantis/view.php?id=1#c15


assigned!


2011-12-21 19:06 administrator Note Added: 0000015
2011-12-21 19:06 administrator Assigned To => administrator
2011-12-21 19:06 administrator Status new => assigned

Details

https://<hostname>/mantis/view.php?id=1
... (this part remains the same as it is in current e-mail notifications)

Tagsmantishub, patch

Relationships

related to 0000895 acknowledged bugzilla type diff email instead of full bug each time. 
has duplicate 0021094 closeddregad Notification mails: Only notify of what has changed 
related to 0012830 new new HTMLMail plugin v0.1 
related to 0010084 acknowledged Integration with jabber? 

Activities

dregad

dregad

2011-12-22 11:29

developer   ~0030672

Hello,

This sounds like a good idea.

Submitting a patch is always a good idea, as it increases the chance of an improvement eventually making it into Mantis.

Best option would be to send us a pull request on Github. Alternatively, please provide it as a git patch if possible, or at least as a unified diff (clearly specifying the base release used for the patch)

Thank you.

kkroflin

kkroflin

2012-03-22 06:08

reporter  

email_notifications.patch (10,355 bytes)   
From c39518ff6a5afc540892ba728b67dd775beb66f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kre=C5=A1imir=20Kroflin?= <kkroflin@gmail.com>
Date: Thu, 22 Mar 2012 10:32:55 +0100
Subject: [PATCH] Added short info of changed items in the e-mail
 notifications

---
 config_defaults_inc.php  |   11 ++++
 core/email_api.php       |  149 +++++++++++++++++++++++++++++++++------------
 lang/strings_english.txt |    2 +
 3 files changed, 122 insertions(+), 40 deletions(-)

diff --git a/config_defaults_inc.php b/config_defaults_inc.php
index 8c5df3d..a2d1a86 100644
--- a/config_defaults_inc.php
+++ b/config_defaults_inc.php
@@ -554,10 +554,21 @@
 	 */
 	$g_email_separator2		= str_pad('', 70, '-');
 	/**
+	 * email separator
+	 * @global string $g_email_separator3_char
+	 */
+	$g_email_separator3_char = "#";
+	/**
 	 * email separator and padding
 	 * @global int $g_email_padding_length
 	 */
 	$g_email_padding_length	= 28;
+	/**
+	 * Specifies whether bug details should be sent as an e-mail signature or as
+	 * normal text
+	 * @global boolean $g_email_bug_details_as_signature
+	 */
+	$g_email_bug_details_as_signature = ON;
 
 	/***************************
 	 * MantisBT Version String *
diff --git a/core/email_api.php b/core/email_api.php
index 59bb51c..44d7211 100644
--- a/core/email_api.php
+++ b/core/email_api.php
@@ -1206,10 +1206,15 @@ function email_format_bug_message( $p_visible_bug_data ) {
 
 	$t_email_separator1 = config_get( 'email_separator1' );
 	$t_email_separator2 = config_get( 'email_separator2' );
+	$t_email_separator3_char = config_get( 'email_separator3_char' );
 	$t_email_padding_length = config_get( 'email_padding_length' );
 
+	$t_email_bug_details_as_signature = config_get( 'email_bug_details_as_signature' );
+
 	$t_status = $p_visible_bug_data['email_status'];
 
+	$t_summary_for_date = $p_visible_bug_data['email_last_modified'];
+
 	$p_visible_bug_data['email_date_submitted'] = date( $t_complete_date_format, $p_visible_bug_data['email_date_submitted'] );
 	$p_visible_bug_data['email_last_modified'] = date( $t_complete_date_format, $p_visible_bug_data['email_last_modified'] );
 
@@ -1218,7 +1223,19 @@ function email_format_bug_message( $p_visible_bug_data ) {
 	$p_visible_bug_data['email_priority'] = get_enum_element( 'priority', $p_visible_bug_data['email_priority'] );
 	$p_visible_bug_data['email_reproducibility'] = get_enum_element( 'reproducibility', $p_visible_bug_data['email_reproducibility'] );
 
-	$t_message = $t_email_separator1 . " \n";
+	# format changed
+	$t_message .= "\n";
+	$t_message .= utf8_str_pad( "{$t_email_separator3_char}{$t_email_separator3_char}{$t_email_separator3_char} " . lang_get( 'email_changed' ) . " ", 70, $t_email_separator3_char, STR_PAD_RIGHT );
+	$t_message .= "\n";
+	$t_message .= email_format_bugnotes( $p_visible_bug_data, $t_summary_for_date );
+	$t_message .= email_format_history( $p_visible_bug_data, $t_summary_for_date );
+
+	# format details
+	if( $t_email_bug_details_as_signature == ON || $t_email_bug_details_as_signature == AUTO ) {
+	    $t_message .= "-- \n";
+	}
+	$t_message .= utf8_str_pad( "{$t_email_separator3_char}{$t_email_separator3_char}{$t_email_separator3_char} " . lang_get( 'email_details' ) . " ", 70, $t_email_separator3_char, STR_PAD_RIGHT );
+	$t_message .= "\n";
 
 	if( isset( $p_visible_bug_data['email_bug_view_url'] ) ) {
 		$t_message .= $p_visible_bug_data['email_bug_view_url'] . " \n";
@@ -1294,47 +1311,10 @@ function email_format_bug_message( $p_visible_bug_data ) {
 	$t_message .= $t_email_separator1 . " \n\n";
 
 	# format bugnotes
-	foreach( $p_visible_bug_data['bugnotes'] as $t_bugnote ) {
-		$t_last_modified = date( $t_normal_date_format, $t_bugnote->last_modified );
-
-		$t_formatted_bugnote_id = bugnote_format_id( $t_bugnote->id );
-		$t_bugnote_link = string_process_bugnote_link( config_get( 'bugnote_link_tag' ) . $t_bugnote->id, false, false, true );
-
-		if( $t_bugnote->time_tracking > 0 ) {
-			$t_time_tracking = ' ' . lang_get( 'time_tracking' ) . ' ' . db_minutes_to_hhmm( $t_bugnote->time_tracking ) . "\n";
-		} else {
-			$t_time_tracking = '';
-		}
-
-		if( user_exists( $t_bugnote->reporter_id ) ) {
-			$t_access_level = access_get_project_level( $p_visible_bug_data['email_project_id'] , $t_bugnote->reporter_id );
-			$t_access_level_string = ' (' . get_enum_element( 'access_levels', $t_access_level ) . ') - ';
-		} else {
-			$t_access_level_string = '';
-		}
-
-		$t_string = ' (' . $t_formatted_bugnote_id . ') ' . user_get_name( $t_bugnote->reporter_id ) . $t_access_level_string . $t_last_modified . "\n" . $t_time_tracking . ' ' . $t_bugnote_link;
-
-		$t_message .= $t_email_separator2 . " \n";
-		$t_message .= $t_string . " \n";
-		$t_message .= $t_email_separator2 . " \n";
-		$t_message .= $t_bugnote->note . " \n\n";
-	}
+	$t_message .= email_format_bugnotes( $p_visible_bug_data );
 
 	# format history
-	if( array_key_exists( 'history', $p_visible_bug_data ) ) {
-		$t_message .= lang_get( 'bug_history' ) . " \n";
-		$t_message .= utf8_str_pad( lang_get( 'date_modified' ), 17 ) . utf8_str_pad( lang_get( 'username' ), 15 ) . utf8_str_pad( lang_get( 'field' ), 25 ) . utf8_str_pad( lang_get( 'change' ), 20 ) . " \n";
-
-		$t_message .= $t_email_separator1 . " \n";
-
-		foreach( $p_visible_bug_data['history'] as $t_raw_history_item ) {
-			$t_localized_item = history_localize_item( $t_raw_history_item['field'], $t_raw_history_item['type'], $t_raw_history_item['old_value'], $t_raw_history_item['new_value'], false );
-
-			$t_message .= utf8_str_pad( date( $t_normal_date_format, $t_raw_history_item['date'] ), 17 ) . utf8_str_pad( $t_raw_history_item['username'], 15 ) . utf8_str_pad( $t_localized_item['note'], 25 ) . utf8_str_pad( $t_localized_item['change'], 20 ) . "\n";
-		}
-		$t_message .= $t_email_separator1 . " \n\n";
-	}
+	$t_message .= email_format_history( $p_visible_bug_data );
 
 	return $t_message;
 }
@@ -1355,6 +1335,95 @@ function email_format_attribute( $p_visible_bug_data, $attribute_id ) {
 }
 
 /**
+ * Build the bug notes part of the message
+ * @param array $p_visible_bug_data
+ * @param integer $p_summary_for_date
+ * @return string
+ */
+function email_format_bugnotes( $p_visible_bug_data, $p_summary_for_date = null ) {
+	$t_message = '';
+
+	$t_normal_date_format = config_get( 'normal_date_format' );
+	$t_email_separator2 = config_get( 'email_separator2' );
+
+	# format bugnotes
+	foreach( $p_visible_bug_data['bugnotes'] as $t_bugnote ) {
+	    if( $p_summary_for_date ) {
+	        if( $p_summary_for_date != $t_bugnote->last_modified ) {
+	            continue;
+	        }
+	    }
+
+	    $t_last_modified = date( $t_normal_date_format, $t_bugnote->last_modified );
+
+	    $t_formatted_bugnote_id = bugnote_format_id( $t_bugnote->id );
+	    $t_bugnote_link = string_process_bugnote_link( config_get( 'bugnote_link_tag' ) . $t_bugnote->id, false, false, true );
+
+	    if( $t_bugnote->time_tracking > 0 ) {
+	        $t_time_tracking = ' ' . lang_get( 'time_tracking' ) . ' ' . db_minutes_to_hhmm( $t_bugnote->time_tracking ) . "\n";
+	    } else {
+	        $t_time_tracking = '';
+	    }
+
+	    if( user_exists( $t_bugnote->reporter_id ) ) {
+	        $t_access_level = access_get_project_level( $p_visible_bug_data['email_project_id'] , $t_bugnote->reporter_id );
+	        $t_access_level_string = ' (' . get_enum_element( 'access_levels', $t_access_level ) . ') - ';
+	    } else {
+	        $t_access_level_string = '';
+	    }
+
+	    $t_string = ' (' . $t_formatted_bugnote_id . ') ' . user_get_name( $t_bugnote->reporter_id ) . $t_access_level_string . $t_last_modified . "\n" . $t_time_tracking . ' ' . $t_bugnote_link;
+
+	    $t_message .= $t_email_separator2 . " \n";
+	    $t_message .= $t_string . " \n";
+	    $t_message .= $t_email_separator2 . " \n";
+	    $t_message .= $t_bugnote->note . " \n\n";
+	}
+
+	return $t_message;
+}
+
+/**
+ * Build the bug history part of the message
+ * @param array $p_visible_bug_data
+ * @param integer $p_summary_for_date
+ * @return string
+ */
+function email_format_history( $p_visible_bug_data, $p_summary_for_date = null ) {
+	$t_message = '';
+
+	$t_normal_date_format = config_get( 'normal_date_format' );
+
+	$t_email_separator1 = config_get( 'email_separator1' );
+	$t_email_separator2 = config_get( 'email_separator1' );
+
+	# format history
+	if( array_key_exists( 'history', $p_visible_bug_data ) ) {
+	    if( $p_summary_for_date ) {
+	        $t_message .= $t_email_separator2 . " \n";
+	    } else {
+	        $t_message .= lang_get( 'bug_history' ) . " \n";
+	        $t_message .= utf8_str_pad( lang_get( 'date_modified' ), 17 ) . utf8_str_pad( lang_get( 'username' ), 15 ) . utf8_str_pad( lang_get( 'field' ), 25 ) . utf8_str_pad( lang_get( 'change' ), 20 ) . " \n";
+
+	        $t_message .= $t_email_separator1 . " \n";
+	    }
+
+	    foreach( $p_visible_bug_data['history'] as $t_raw_history_item ) {
+	        if( $p_summary_for_date && $p_summary_for_date != $t_raw_history_item['date']) {
+	            continue;
+	        }
+
+	        $t_localized_item = history_localize_item( $t_raw_history_item['field'], $t_raw_history_item['type'], $t_raw_history_item['old_value'], $t_raw_history_item['new_value'], false );
+
+	        $t_message .= utf8_str_pad( date( $t_normal_date_format, $t_raw_history_item['date'] ), 17 ) . utf8_str_pad( $t_raw_history_item['username'], 15 ) . utf8_str_pad( $t_localized_item['note'], 25 ) . utf8_str_pad( $t_localized_item['change'], 20 ) . "\n";
+	    }
+	    $t_message .= $t_email_separator1 . " \n\n";
+	}
+
+	return $t_message;
+}
+
+/**
  * Build the bug raw data visible for specified user to be translated and sent by email to the user
  * (Filter the bug data according to user access level)
  * return array with bug data. See usage in email_format_bug_message(...)
diff --git a/lang/strings_english.txt b/lang/strings_english.txt
index bf638cb..2bd858c 100644
--- a/lang/strings_english.txt
+++ b/lang/strings_english.txt
@@ -401,6 +401,8 @@ $s_email_summary = 'Summary';
 $s_email_description = 'Description';
 $s_email_additional_information = 'Additional Information';
 $s_email_steps_to_reproduce = 'Steps to Reproduce';
+$s_email_changed = 'Changed';
+$s_email_details = 'Details';
 
 # account_delete.php
 $s_account_protected_msg = 'Account protected. Cannot change settings...';
-- 
1.7.7

email_notifications.patch (10,355 bytes)   
kkroflin

kkroflin

2012-03-22 06:14

reporter  

email_example.png (21,692 bytes)   
email_example.png (21,692 bytes)   
kkroflin

kkroflin

2012-03-22 06:15

reporter   ~0031508

Sorry for taking so long to create the patch. The patch is for current master-1.2.x branch.

A sample of e-mail notification is also attached.

laoli4121

laoli4121

2014-02-04 20:55

reporter   ~0039316

Thanks for this, it works for me and really utility

Shifter7

Shifter7

2014-05-20 12:17

reporter   ~0040601

Has this been successfully implemented with 1.2.15 or 1.2.17?

grangeway

grangeway

2014-05-20 13:08

reporter   ~0040603

Shifter,

We are planning on updating and improving the notifications support in a few months time.

After the 1.3 release, we are going to be doing a 2.0 shortly afterwards with a new DB Layer to improve support for other database engines, and then spending some time on improving the notifications within Mantis.

Shifter7

Shifter7

2014-05-20 13:20

reporter   ~0040605

grangeway,

Thanks for the response.
Will something similar to the functionality of this patch be included with 1.3 or 2.0? I have a lot of users asking for more streamlined/less redundant email notifications and this seemed like a good start. If the later releases have something like it (or better), I can make the case for them to wait a bit so we don't have to patch.

grangeway

grangeway

2014-05-20 15:20

reporter   ~0040606

Victor / myself both had functionality for email notifications. I said on mailing list I'd work on pulling together email notification stuff I had as soon as DB Layer changes were in.

The aim in both cases is to allow a lot more control over the templating of email notifications. In Victor's guess, where he has been promoting his personal project of MantisHub, he'd like Avatar's and simpler notifications. In my personal case at work, I'm OK with detailed notifications of the current state of an issue, but would like to pretty-fy it with HTML.

In any case, personally, the goal would be to allow a lot more flexibility in what an email notification would look like - whilst also considering other notification types. For example, Twitter seems to be quite popular place for posting everything that one does ;)

In your case,
a) what would your ideal notification look like?
b) Apart from emails, would you like notifications over any other medium?

Shifter7

Shifter7

2014-05-21 14:47

reporter   ~0040610

grangeway,

I'm hearing three main email notification requests from my users:

1) limit email notifications to only items that have changed on a bug. One exception would be if there was a new note, you would want to see the previous one, too, for context. If a user wants to see the whole note trail, they can go to the bug report itself.

2) Include the Category in the subject line of notifications to allow to allow users to use email filters/rules to watch for specific issues.

3) allow users to not get bombarded with notifications of new "monitors" on a bug.

I'm waiting on input from a couple more people and will let you know if they come up with anything significantly different

kkroflin

kkroflin

2014-05-22 08:41

reporter   ~0040622

Additionally to what Shifter7 said, we would like to have important information on the top of the email. In most cases these are:

  • Category
  • Summary
  • Description for new issue / Note
  • Status / Resolution
  • Reporter / Assignee
  • Short list of changed properites
  • URL to the issue

We don't need full info about issue in every e-mail. However, if the full info is in the e-mail, it should be visually divided from the short info so it can be quickly skipped as receivers usually already know what's happening. Our users usually don't like to scroll or go through big table to find the most important information.

With my patch we have similar functionality. It would be better if each line of full info is indented with "> " (e-mail quote) instead of using "-- " (signature) but that would require more changes.

Others might have different list of important properties from the issue so mentioned possibility to create e-mail template per MantisBT installation or even per Project would be much appreciated.

Issue History

Date Modified Username Field Change
2011-12-22 05:30 kkroflin New Issue
2011-12-22 11:29 dregad Note Added: 0030672
2012-01-27 03:08 vboctor Relationship added related to 0012830
2012-01-27 03:08 vboctor Relationship added related to 0010084
2012-03-22 06:08 kkroflin File Added: email_notifications.patch
2012-03-22 06:14 kkroflin File Added: email_example.png
2012-03-22 06:15 kkroflin Note Added: 0031508
2012-03-22 11:15 dregad Tag Attached: patch
2012-04-08 16:51 dregad Relationship added related to 0000895
2014-02-04 20:55 laoli4121 Note Added: 0039316
2014-05-20 12:17 Shifter7 Note Added: 0040601
2014-05-20 13:08 grangeway Note Added: 0040603
2014-05-20 13:20 Shifter7 Note Added: 0040605
2014-05-20 15:20 grangeway Note Added: 0040606
2014-05-21 14:47 Shifter7 Note Added: 0040610
2014-05-22 08:41 kkroflin Note Added: 0040622
2016-06-12 13:13 dregad Relationship added has duplicate 0021094
2016-06-12 21:39 vboctor Tag Attached: mantishub