View Issue Details

IDProjectCategoryView StatusLast Update
0012830mantisbtplug-inspublic2017-04-19 10:51
Reporterbarnabas.sudyAssigned To 
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status newResolutionopen 
Product Version1.2.4 
Target VersionFixed in Version 
Summary0012830: new HTMLMail plugin v0.1
Description

I'm working on a new HTMLMail plugin. The plugin is able to replace the content of the normal Mantis mail.
This plugin is developed for mantis 1.2.4.

Additional Information

For using you need to patch the mantis and install the plugin.
The email templates are written in php, so if you want to modify the content of the emails you must override the template files in the HTMLMail/templates directory. The email templates are indentified by the type of the message.

Tagsattachments, custom, email, html, HTMLmail, patch, plugin, template

Relationships

related to 0013692 new Extending e-mail notifications with a short summary of changed properties 
related to 0001400 assignedvboctor Feature to send HTML-formatted e-mail instead of text e-mail 
has duplicate 0014510 closedatrol Allowing Plugins to handle email sending 
has duplicate 0020586 closedatrol support html templates in email reporting 
related to 0009602 assignedvboctor Email Notification with Attachment 
related to 0010084 acknowledged Integration with jabber? 
related to 0012639 new Fields in email always display, despite the fact that they are not displayed anywhere in pages 
related to 0008986 new customized eMail subjects 
related to 0014006 closedatrol Impossibility to configure which fields are displayed in the email of notification 

Activities

barnabas.sudy

barnabas.sudy

2011-03-01 08:20

reporter  

HTMLMail0.1.zip (23,864 bytes)
econsor

econsor

2011-03-19 18:36

reporter   ~0028444

Thanks - working great here!

Just a small note: To use this on a Linux-based server I had to replace the windows-specific '\' in the function HTMLMailPlugin::html_mail_load_template():

$t_filename = config_get_global( 'plugin_path' ) . plugin_get_current() . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $p_message_id . ".tpl";

zdroyer

zdroyer

2011-07-15 10:06

reporter  

mantis-1.2.5-patch-for-htmlmail-0.1.patch (5,423 bytes)
--- core/email_api.php	Thu Jan 15 09:14:12 1970
+++ core/email_api.php	Thu Jan 15 09:14:12 1970
@@ -447,7 +447,8 @@
 	# Send signup email regardless of mail notification pref
 	# or else users won't be able to sign up
 	if( !is_blank( $t_email ) ) {
-		email_store( $t_email, $t_subject, $t_message );
+		$t_params = array('admin_name' => $p_admin_name, 'user_id' => $p_user_id, 'confirm_hash' => $p_confirm_hash);
+		email_store( 'email_notification_signup', $t_email, $t_subject, $t_message, null, $t_params );
 		log_event( LOG_EMAIL, sprintf( 'Signup Email = %s, Hash = %s, User = @U%d', $t_email, $p_confirm_hash, $p_user_id ) );
 
 		if( OFF == config_get( 'email_send_using_cronjob' ) ) {
@@ -483,7 +484,8 @@
 	# Send password reset regardless of mail notification prefs
 	# or else users won't be able to receive their reset pws
 	if( !is_blank( $t_email ) ) {
-		email_store( $t_email, $t_subject, $t_message );
+		$t_params = array('user_id' => $p_user_id, 'confirm_hash' => $p_confirm_hash);
+		email_store('email_notification_forgotten_password', $t_email, $t_subject, $t_message, null, $t_params );
 		log_event( LOG_EMAIL, sprintf( 'Password reset for email = %s', $t_email ) );
 
 		if( OFF == config_get( 'email_send_using_cronjob' ) ) {
@@ -515,7 +517,7 @@
 		$t_message = lang_get( 'new_account_signup_msg' ) . "\n\n" . lang_get( 'new_account_username' ) . ' ' . $p_username . "\n" . lang_get( 'new_account_email' ) . ' ' . $p_email . "\n" . lang_get( 'new_account_IP' ) . ' ' . $_SERVER["REMOTE_ADDR"] . "\n" . $g_path . "\n\n" . lang_get( 'new_account_do_not_reply' );
 
 		if( !is_blank( $t_recipient_email ) ) {
-			email_store( $t_recipient_email, $t_subject, $t_message );
+			email_store( 'email_notification_new_account', $t_recipient_email, $t_subject, $t_message );
 			log_event( LOG_EMAIL, sprintf( 'New Account Notify for email = \'%s\'', $t_recipient_email ) );
 
 			if( OFF == config_get( 'email_send_using_cronjob' ) ) {
@@ -781,7 +783,7 @@
  * @param array $p_headers
  * @return int
  */
-function email_store( $p_recipient, $p_subject, $p_message, $p_headers = null ) {
+function email_store( $p_message_id, $p_recipient, $p_subject, $p_message, $p_headers = null, $p_params = null ) {
 	$t_recipient = trim( $p_recipient );
 	$t_subject = string_email( trim( $p_subject ) );
 	$t_message = string_email_links( trim( $p_message ) );
@@ -817,6 +819,8 @@
 	}
 	$t_email_data->metadata['hostname'] = $t_hostname;
 
+	$t_email_data = event_signal('EVENT_NOTIFY_EMAIL', $t_email_data, array( 'message_id' => $p_message_id, 'params' => $p_params,));
+	
 	$t_email_id = email_queue_add( $t_email_data );
 
 	return $t_email_id;
@@ -930,7 +934,7 @@
 			break;
 	}
 
-	$mail->IsHTML( false );              # set email format to plain text
+	$mail->IsHTML ( isset( $t_email_data->metadata['Content-Type'] ) && stripos( $t_email_data->metadata['Content-Type'], "text/html" ) !== false ) ;              # set email format to plain text
 	$mail->WordWrap = 80;              # set word wrap to 50 characters
 	$mail->Priority = $t_email_data->metadata['priority'];  # Urgent = 1, Not Urgent = 5, Disable = 0
 	$mail->CharSet = $t_email_data->metadata['charset'];
@@ -1126,8 +1130,10 @@
 		$t_header = "\n" . lang_get( 'on_date' ) . " $t_date, $t_sender $t_sender_email " . lang_get( 'sent_you_this_reminder_about' ) . ": \n\n";
 		$t_contents = $t_header . string_get_bug_view_url_with_fqdn( $p_bug_id, $t_recipient ) . " \n\n$p_message";
 
+		$t_params = array( 'message' => $p_message, 'bug_id' => $p_bug_id, 'recipient' => $t_recipient, 'sender' => $t_sender, 'sender_email' => $t_sender_email );
+		
 		if( ON == config_get( 'enable_email_notification' ) ) {
-			email_store( $t_email, $t_subject, $t_contents );
+			email_store( 'email_bug_reminder', $t_email, $t_subject, $t_contents, null, $t_params );
 		}
 
 		lang_pop();
@@ -1189,7 +1195,7 @@
 	}
 
 	# send mail
-	$t_ok = email_store( $t_user_email, $t_subject, $t_message, $t_mail_headers );
+	$t_ok = email_store( $p_message_id, $t_user_email, $t_subject, $t_message, $t_mail_headers, array_merge($p_visible_bug_data, array('header_optional_params' => $p_header_optional_params)));
 
 	return $t_ok;
 }
--- core/events_inc.php	Thu Jan 15 09:14:12 1970
+++ core/events_inc.php	Thu Jan 15 09:14:12 1970
@@ -108,6 +108,7 @@
 	# Email notification events
 	'EVENT_NOTIFY_USER_INCLUDE' => EVENT_TYPE_DEFAULT,
 	'EVENT_NOTIFY_USER_EXCLUDE' => EVENT_TYPE_DEFAULT,
+	'EVENT_NOTIFY_EMAIL' => EVENT_TYPE_CHAIN,
 
 	# Wiki events
 	'EVENT_WIKI_INIT' => EVENT_TYPE_FIRST,
--- manage_user_update.php	Thu Jan 15 09:14:12 1970
+++ manage_user_update.php	Thu Jan 15 09:14:12 1970
@@ -164,7 +164,7 @@
 			$t_subject = '[' . config_get( 'window_title' ) . '] ' . lang_get( 'email_user_updated_subject' );
 			$t_updated_msg = lang_get( 'email_user_updated_msg' );
 			$t_message = $t_updated_msg . "\n\n" . config_get( 'path' ) . 'account_page.php' . "\n\n" . $t_changes;
-			email_store( $t_email, $t_subject, $t_message );
+			email_store( 'email_notification_user_update', $t_email, $t_subject, $t_message, null, array( 'changes' => $t_changes ) );
 			log_event( LOG_EMAIL, sprintf( 'Account update notification sent to ' . $f_username . ' (' . $t_email . ')' ) );
 			if ( config_get( 'email_send_using_cronjob' ) == OFF ) {
 				email_send_all();
zdroyer

zdroyer

2011-07-15 10:22

reporter   ~0029176

Last edited: 2011-07-15 10:25

View 2 revisions

@barnabas.sudy, thanks a lot!

Since the old HTMLMail-0.0.7.pkg is no more compatible with Mantis 1.2.*, this "new" plugin is the only solution until Mantis 1.3 is not released.

I modified the patch included in the zip so the plugin can be now installed on 1.2.5. I installed it and as far as I see, it works!

If there is interest in development of this plugin and the templates, we can start a repo? Do you know the development status of email templates in 1.3?

zdroyer

zdroyer

2011-08-09 05:59

reporter   ~0029409

I can confirm that the patch I provided (mantis-1.2.5-patch-for-htmlmail-0.1.patch) and the plugin seem to be compatible with mantisbt 1.2.6
(patch can be applied flawlessly, some templates work)

zdroyer

zdroyer

2011-08-16 05:54

reporter   ~0029483

Currently I am working on adding to this plugin attachments. In my installation it email attachments work, but they needed some changes in the Mantis core. I will work on introducing this changes to the next (1.2.7 ?) stable release.

zdroyer

zdroyer

2011-10-06 07:57

reporter   ~0029924

currently this plugin works with 1.2.4-7 (I will upload patch for Mantis 1.2.7 soon)
I tried to push the patch to the mainstream of mantis development but the developers refused to incorporate the changes to the 1.2.*

Once I have some more time (read: I finally integrate FileMaker with Mantis), I will try to contribute to 1.3

zdroyer

zdroyer

2011-10-26 12:37

reporter  

01-1.2.7-patch-to-use-HTMLMail-0.1.patch (7,349 bytes)
	Index: core/email_api.php
===================================================================
--- a/core/email_api.php
+++ b/core/email_api.php
@@ -447,7 +447,8 @@ function email_signup( $p_user_id, $p_password, $p_confirm_hash, $p_admin_name =
 	# Send signup email regardless of mail notification pref
 	# or else users won't be able to sign up
 	if( !is_blank( $t_email ) ) {
-		email_store( $t_email, $t_subject, $t_message );
+		$t_params = array( 'admin_name' => $p_admin_name, 'user_id' => $p_user_id, 'confirm_hash' => $p_confirm_hash );
+		email_store( 'email_notification_signup', $t_email, $t_subject, $t_message, null, $t_params );
 		log_event( LOG_EMAIL, sprintf( 'Signup Email = %s, Hash = %s, User = @U%d', $t_email, $p_confirm_hash, $p_user_id ) );
 
 		if( OFF == config_get( 'email_send_using_cronjob' ) ) {
@@ -483,7 +484,8 @@ function email_send_confirm_hash_url( $p_user_id, $p_confirm_hash ) {
 	# Send password reset regardless of mail notification prefs
 	# or else users won't be able to receive their reset pws
 	if( !is_blank( $t_email ) ) {
-		email_store( $t_email, $t_subject, $t_message );
+		$t_params = array( 'user_id' => $p_user_id, 'confirm_hash' => $p_confirm_hash );
+		email_store( 'email_notification_forgotten_password', $t_email, $t_subject, $t_message, null, $t_params );
 		log_event( LOG_EMAIL, sprintf( 'Password reset for email = %s', $t_email ) );
 
 		if( OFF == config_get( 'email_send_using_cronjob' ) ) {
@@ -515,7 +517,7 @@ function email_notify_new_account( $p_username, $p_email ) {
 		$t_message = lang_get( 'new_account_signup_msg' ) . "\n\n" . lang_get( 'new_account_username' ) . ' ' . $p_username . "\n" . lang_get( 'new_account_email' ) . ' ' . $p_email . "\n" . lang_get( 'new_account_IP' ) . ' ' . $_SERVER["REMOTE_ADDR"] . "\n" . $g_path . "\n\n" . lang_get( 'new_account_do_not_reply' );
 
 		if( !is_blank( $t_recipient_email ) ) {
-			email_store( $t_recipient_email, $t_subject, $t_message );
+			email_store( 'email_notification_new_account', $t_recipient_email, $t_subject, $t_message );
 			log_event( LOG_EMAIL, sprintf( 'New Account Notify for email = \'%s\'', $t_recipient_email ) );
 
 			if( OFF == config_get( 'email_send_using_cronjob' ) ) {
@@ -781,7 +783,7 @@ function email_bug_deleted( $p_bug_id ) {
  * @param array $p_headers
  * @return int
  */
-function email_store( $p_recipient, $p_subject, $p_message, $p_headers = null ) {
+function email_store( $p_message_id, $p_recipient, $p_subject, $p_message, $p_headers = null, $p_params = null ) {
 	$t_recipient = trim( $p_recipient );
 	$t_subject = string_email( trim( $p_subject ) );
 	$t_message = string_email_links( trim( $p_message ) );
@@ -817,6 +819,8 @@ function email_store( $p_recipient, $p_subject, $p_message, $p_headers = null )
 	}
 	$t_email_data->metadata['hostname'] = $t_hostname;
 
+	$t_email_data = event_signal( 'EVENT_NOTIFY_EMAIL', $t_email_data, array( 'message_id' => $p_message_id, 'params' => $p_params ) );
+	
 	$t_email_id = email_queue_add( $t_email_data );
 
 	return $t_email_id;
@@ -930,7 +934,7 @@ function email_send( $p_email_data ) {
 			break;
 	}
 
-	$mail->IsHTML( false );              # set email format to plain text
+	$mail->IsHTML( isset( $t_email_data->metadata['Content-Type'] ) && stripos( $t_email_data->metadata['Content-Type'], "text/html" ) !== false );
 	$mail->WordWrap = 80;              # set word wrap to 50 characters
 	$mail->Priority = $t_email_data->metadata['priority'];  # Urgent = 1, Not Urgent = 5, Disable = 0
 	$mail->CharSet = $t_email_data->metadata['charset'];
@@ -1126,8 +1130,10 @@ function email_bug_reminder( $p_recipients, $p_bug_id, $p_message ) {
 		$t_header = "\n" . lang_get( 'on_date' ) . " $t_date, $t_sender $t_sender_email " . lang_get( 'sent_you_this_reminder_about' ) . ": \n\n";
 		$t_contents = $t_header . string_get_bug_view_url_with_fqdn( $p_bug_id, $t_recipient ) . " \n\n$p_message";
 
+		$t_params = array( 'message' => $p_message, 'bug_id' => $p_bug_id, 'recipient' => $t_recipient, 'sender' => $t_sender, 'sender_email' => $t_sender_email );
+		
 		if( ON == config_get( 'enable_email_notification' ) ) {
-			email_store( $t_email, $t_subject, $t_contents );
+			email_store( 'email_bug_reminder', $t_email, $t_subject, $t_contents, null, $t_params );
 		}
 
 		lang_pop();
@@ -1189,7 +1195,7 @@ function email_bug_info_to_one_user( $p_visible_bug_data, $p_message_id, $p_proj
 	}
 
 	# send mail
-	$t_ok = email_store( $t_user_email, $t_subject, $t_message, $t_mail_headers );
+	$t_ok = email_store( $p_message_id, $t_user_email, $t_subject, $t_message, $t_mail_headers, array_merge( $p_visible_bug_data, array( 'header_optional_params' => $p_header_optional_params ) ) );
 
 	return $t_ok;
 }
index: core/events_inc.php
===================================================================
--- a/core/events_inc.php
+++ b/core/events_inc.php
@@ -108,6 +108,7 @@ event_declare_many( array(
 	# Email notification events
 	'EVENT_NOTIFY_USER_INCLUDE' => EVENT_TYPE_DEFAULT,
 	'EVENT_NOTIFY_USER_EXCLUDE' => EVENT_TYPE_DEFAULT,
+	'EVENT_NOTIFY_EMAIL' => EVENT_TYPE_CHAIN,
 
 	# Wiki events
 	'EVENT_WIKI_INIT' => EVENT_TYPE_FIRST,
index: docbook/developers/en/event-reference-notify.sgml
===================================================================
--- a/docbook/developers/en/event-reference-notify.sgml
+++ b/docbook/developers/en/event-reference-notify.sgml
@@ -55,4 +55,31 @@
 
 	</sect2>
 
+	<sect2 id="dev.eventref.notify.email">
+		<title>Email notification </title>
+
+		<blockquote id="dev.eventref.notify.email">
+			<title>EVENT_NOTIFY_EMAIL (Chained)</title>
+
+			<blockquote>
+				<para>
+					This event allows a plugin to modify an email notification message before it is sent.
+				</para>
+
+				<itemizedlist>
+					<title>Parameters</title>
+					<listitem><para>&lt;Complex&gt;: email message to be sent, EmailData object (see core\email_queue_api.php)</para></listitem>
+					<listitem><para>&lt;String&gt;: message type identificator</para></listitem>
+					<listitem><para>&lt;Array&gt;: message parameters</para></listitem>
+
+				</itemizedlist>
+
+				<itemizedlist>
+					<title>Return Value</title>
+					<listitem><para>&lt;Complex&gt;: email message to be sent, EmailData object</para></listitem>
+				</itemizedlist>
+			</blockquote>
+		</blockquote>
+	</sect2>
+
 </sect1>
index: manage_user_update.php
===================================================================
--- a/manage_user_update.php
+++ b/manage_user_update.php
@@ -164,7 +164,7 @@ if ( $f_send_email_notification ) {
 			$t_subject = '[' . config_get( 'window_title' ) . '] ' . lang_get( 'email_user_updated_subject' );
 			$t_updated_msg = lang_get( 'email_user_updated_msg' );
 			$t_message = $t_updated_msg . "\n\n" . config_get( 'path' ) . 'account_page.php' . "\n\n" . $t_changes;
-			email_store( $t_email, $t_subject, $t_message );
+			email_store( 'email_notification_user_update', $t_email, $t_subject, $t_message, null, array( 'changes' => $t_changes ) );
 			log_event( LOG_EMAIL, sprintf( 'Account update notification sent to ' . $f_username . ' (' . $t_email . ')' ) );
 			if ( config_get( 'email_send_using_cronjob' ) == OFF ) {
 				email_send_all();
zdroyer

zdroyer

2011-10-26 12:37

reporter  

02-1.2.7-email_attachments.patch (4,154 bytes)
Index: core/email_api.php
===================================================================
--- a/core/email_api.php
+++ b/core/email_api.php
@@ -992,6 +992,17 @@
 		}
 	}
 
+	if( isset( $t_email_data->metadata['attachments'] ) && is_array( $t_email_data->metadata['attachments'] ) ) {
+		if( count( $t_email_data->metadata['attachments'] ) > 0 ){
+			log_event( LOG_EMAIL, 'Attachments: '.print_r($t_email_data->metadata['attachments'],true ) );
+			$t_files = file_get_attachments( $t_email_data->metadata['attachments'] );
+			log_event( LOG_EMAIL, 'Read '.count( $t_files ).' file(s) to be attached to the email' );
+			foreach( $t_files as $t_index => $t_file ) {
+				$mail->AddStringAttachment( $t_file['content'], $t_file['display_name']  );
+				log_event( LOG_EMAIL, 'Attachment '.$t_file['display_name'].', size = '.$t_file['size'].' added' );
+			}
+		}
+	}
 	try
 	{
 		if ( !$mail->Send() ) {
Index: core/email_queue_api.php
===================================================================
--- a/core/email_queue_api.php
+++ b/core/email_queue_api.php
@@ -34,6 +34,7 @@
 	var $body = '';
 	var $metadata = array(
 		'headers' => array(),
+		'attachments' => array(),
 	);
 
 	// auto-populated properties
Index: core/file_api.php
===================================================================
--- a/core/file_api.php
+++ b/core/file_api.php
@@ -435,6 +435,7 @@
 function file_ftp_get( $p_conn_id, $p_local_filename, $p_remote_filename ) {
 	helper_begin_long_process();
 	$download = ftp_get( $p_conn_id, $p_local_filename, $p_remote_filename, FTP_BINARY );
+	return $download;
 }
 
 # Delete a file from the ftp server
@@ -455,6 +456,61 @@
 	}
 }
 
+
+# --------------------
+# Gets an array of attachments whose ids are included in the passed array.
+# Content of the files are fetched basing on the 'file_upload_method' config value
+# Each element of the result array contains the following:
+# id - Id of the file in the database
+# bug_id - Id of the bug that the file is attached to
+# display_name - The attachment display name (i.e. file name dot extension)
+# size - The attachment size in bytes.
+# date_added - The date where the attachment was added.
+# content - content of the file
+# diskfile - The name of the file on disk.  Typically this is a hash without an extension.
+function file_get_attachments( $p_file_ids ) {
+	$t_result_array = array();
+	$t_ids = is_array( $p_file_ids ) ? $p_file_ids : array( $p_file_ids );
+	$t_ids = array_unique( $t_ids );
+	$t_bug_file_table = db_get_table( 'mantis_bug_file_table' );
+	$query = "SELECT id, bug_id, filename AS display_name, filesize AS size, date_added, content, diskfile
+		FROM $t_bug_file_table
+		WHERE id IN (" .implode( ",", $t_ids ).")";
+	$result = db_query_bound( $query );
+	$t_project_id = -1;
+	$t_bug_id = -1;
+	while ( $row = db_fetch_array( $result ) ) {
+		if( $t_bug_id != $row['bug_id'] ){
+			$t_bug_id = $row['bug_id'];
+			$t_project_id = bug_get_field( $t_bug_id, 'project_id' );
+		}
+		switch ( config_get( 'file_upload_method' ) ) {
+		case DISK:
+			$t_local_disk_file = file_normalize_attachment_path( $row['diskfile'], $t_project_id );
+			if ( file_exists( $t_local_disk_file ) )
+				$row['content'] = file_get_contents( $t_local_disk_file );
+			else
+				$row['content'] = "file [".$row['display_name']."] not found (disk)";
+			break;
+		case FTP:
+			$t_local_disk_file = file_normalize_attachment_path( $row['diskfile'], $t_project_id );
+			if ( !file_exists( $t_local_disk_file ) ) {
+				$t_ftp = file_ftp_connect();
+				$t_downloaded = file_ftp_get( $t_ftp, $t_local_disk_file, $row['diskfile'] );
+				file_ftp_disconnect( $ftp );
+				if( $downloaded )
+					$row['content'] = file_get_contents( $t_local_disk_file );
+				else
+					$row['content'] = "file [".$row['display_name']."] not found (ftp)";
+			} else {
+				$row['content'] = file_get_contents( $t_local_disk_file );
+			}
+		}
+		$t_result_array[] = $row;
+	}
+	return $t_result_array;
+}
+
 # Return the specified field value
 function file_get_field( $p_file_id, $p_field_name, $p_table = 'bug' ) {
 	$c_field_name = db_prepare_string( $p_field_name );
zdroyer

zdroyer

2011-10-26 12:37

reporter  

HTMLMail.php (6,560 bytes)
<?php
# MantisBT - a php based bugtracking system

# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.

/**
 * This plugin can reformat the mantis e-mails using the templates in the templates directory.
 *
 * @package BlackSun Plc.
 * @copyright Copyright (C) 2010 - 2011  Barnabas Sudy - bsudy@blacksunplc.com
 */
require_once( config_get( 'class_path' ) . 'MantisPlugin.class.php' );


class HTMLMailPlugin extends MantisPlugin {
	
	function register() {
		$this->name = "HTMLMail"; # Proper name of plugin
		$this->description = "HTML mail capability"; # Short description of the plugin
		$this->page = ""; # Default plugin page
		$this->version = "0.1"; # Plugin version string
		$this->requires = array( # Plugin dependencies, array of basename => version pairs
			'MantisCore' => '1.2', # Should always depend on an appropriate 
		);
		$this->author = "Black Sun Plc."; # Author/team name
		$this->contact = "bsudy@blacksunplc.com"; # Author/team e-mail address
		$this->url = ""; # Support webpage
	}
	
	function hooks() {
		return array(
			'EVENT_NOTIFY_EMAIL' => 'html_email_formatter',
		);
	}

	
	function html_email_formatter( $p_event, $p_email, $p_message_id, $p_params ) {
		if ( ( $t_template = $this->html_mail_load_template( $p_message_id ) ) !== false) { 
			
			
			$t_normal_date_format   = config_get( 'normal_date_format' );
			$t_complete_date_format = config_get( 'complete_date_format' );
			
			$t_message_title =  lang_get_defaulted( $p_message_id, null );
				# grab the project name
			$p_params['email_subject_bug_id_part'] = '[' . $p_params['email_project'] . ' ' . bug_format_id( $p_params['email_bug'] ) . '] ';
			$p_params['email_status_formatted']          = get_enum_element( 'status',          $p_params['email_status']          );
			$p_params['email_severity_formatted']        = get_enum_element( 'severity',        $p_params['email_severity']        );
			$p_params['email_priority_formatted']        = get_enum_element( 'priority',        $p_params['email_priority']        );
			$p_params['email_reproducibility_formatted'] = get_enum_element( 'reproducibility', $p_params['email_reproducibility'] );
			
			$p_params['email_date_submitted_formatted']  = date( $t_complete_date_format, $p_params['email_date_submitted'] );
			$p_params['email_last_modified_formatted']   = date( $t_complete_date_format, $p_params['email_last_modified']  );
			
			$t_params = array_merge( $p_params, array( 'message_title' => $t_message_title , 'message_id' => $p_message_id, ) );
			$p_email->body = $this->html_mail_format($t_template, $t_params);
			$p_email->metadata['Content-Type'] = 'text/html';
			log_event( LOG_EMAIL,'Before attaching file_id to EmailData');
			if( is_array( $p_params ) && is_array( $p_params['history'] ) ) {
				log_event( LOG_EMAIL,'Bug history defined' );
				bug_ensure_exists($p_params['email_bug']);
				$t_reporter_id = bug_get_field( $p_params['email_bug'], 'reporter_id' );
				$t_deleted = array();
				$t_added = array();
				//$t_assigned = config_get( 'bug_resolved_status_threshold' );
				log_event( LOG_EMAIL,'Bug ['.$p_params['email_bug'].'] exists, selecting files to attach' );
				$t_was_more_than_assigned = false;
				for( $i = count( $p_params['history'] ) - 1; $i>=0; $i-- ){
					if( $p_params['history'][$i]['type'] == NORMAL_TYPE 
					&& $p_params['history'][$i]['field'] == 'status' 
					&& $p_params['history'][$i]['new_value'] > ASSIGNED ) {
						if( $t_was_more_than_assigned )
							break;
						$t_was_more_than_assigned = true;
						continue;
					}
					if( $p_params['history'][$i]['type'] == FILE_DELETED ){
						$t_deleted[] = $p_params['history'][$i]['old_value'];
						continue;
					}
					if( $p_params['history'][$i]['type'] == FILE_ADDED 
					&& $p_params['history'][$i]['userid'] != $t_reporter_id ){
						if( in_array( $p_params['history'][$i]['old_value'], $t_deleted ) ){
							unset( $t_deleted[array_search( $p_params['history'][$i]['old_value'], $t_deleted )] );
						} else {
							$t_added[] = $p_params['history'][$i]['old_value'];
						}
					}
				}
				if( count( $t_added ) > 0 ){
					$t_files = bug_get_attachments( $p_params['email_bug'] );
					foreach( $t_files as $file ){
						if( in_array( $file['filename'], $t_added ) ){
							$p_email->metadata['attachments'][] = $file['id'];
						}
					}
				}
			} else {
				log_event( LOG_EMAIL,'Bug history not defined - no attachments added' );
			}
			log_event( LOG_EMAIL,'After attach_files_to_emaildata called' );
                        log_event( LOG_EMAIL,'HTML email body:\n '.$p_email->body );
                        log_event( LOG_EMAIL,'\n$params available for email template:\n '.print_r( $p_params ,true) );

		}
		return $p_email;
	}
	
	function html_mail_load_template($p_message_id) {
		$t_filename = config_get_global( 'plugin_path' ) . plugin_get_current() . '\\templates\\' . $p_message_id . ".tpl";
		if ( is_file( $t_filename ) && is_readable( $t_filename ) ) {
			$t_file = fopen( $t_filename, "r" );
			$t_content = fread( $t_file, filesize( $t_filename ) );
			fclose( $t_file );
			return $t_content;
		} else {
			return false;
		}
	}
	
	function array_to_table($array) {
		$paramtable = "<table>\n";
					
		foreach ($array as $key => $value) {
			$paramtable .= "<tr><td>$key</td><td>";
			if (is_array($value)) {
				$paramtable .= array_to_table($value);
			} else {
				$paramtable .= $value;
			}
			$paramtable .= "</td></tr>\n";
		}
		$paramtable .= "</table>\n";
		return $paramtable;
	}
	
	
	function html_mail_format($t_template, $parameters) {
		ob_start();
		$t_evalresult = eval("?>" . $t_template . "<?php ");
		$t_result = ob_get_contents();
		ob_end_clean();
		
		if ( $t_evalresult === false && ( $t_error = error_get_last() ) ) {
			return $t_template;
		} else {
			return $t_result;
		}
		
	}
}
HTMLMail.php (6,560 bytes)
zdroyer

zdroyer

2011-10-26 12:42

reporter   ~0030081

So, I've just uploaded the patches for 1.2.7 and modified plugin file that can send attachments.
This week I will move my local Mantis to 1.2.8 so expect new files for 1.2.8 soon

eejape

eejape

2011-11-04 09:03

reporter   ~0030170

Anxiously waiting for your patch... :)

zdroyer

zdroyer

2011-11-07 03:44

reporter   ~0030183

Last edited: 2011-11-07 03:45

View 2 revisions

Unfortunately, I had not had time so far to upgrade my local system, but I have checked today the my patches for 1.2.7 against 1.2.8 and they are at least syntactically compatible with the last, 1.2.8 release of Mantis so they can be applied without modifications.
I know that the 1.2.8 upgrade did not introduce any "significant" changes in the functionality, rather security updates so I expect the patches should not break you 1.2.8 installation.

zdroyer

zdroyer

2011-11-07 04:06

reporter   ~0030185

And just one note about attachments.
There is such a functionality in the uploaded of HTMLMail plugin that attaches to the notification emails all the files attached not by the (current) reporter. It is especially useful when reporters use only emails (EmailReporting) to interact with Mantis system.
There is no config option to turn the email attachments off (so far), but if there is more testers, I will try to introduce it.

clancy

clancy

2012-01-05 04:48

reporter   ~0030801

Last edited: 2012-01-05 11:11

View 11 revisions

Just installed on the latest Mantis (1.2.8) and HTML Mail works fine (Thanks for the patch).

In templates/template_body.tpl, had to change lines :

Line 55
<h2>Description:</h2>
-- <?php echo $parameters['email_description'] ?>
++ <?php echo nl2br($parameters['email_description']) ?>

Same on line 115, change

$t_bugnote->note
to
nl2br($t_bugnote->note)

This makes PHP convert every new line to a br /> and avoid having a huge block of text.

anybody got a tuto on how to set up the mail attachments ? still can't get it working properly.

slick

slick

2013-01-07 05:54

reporter   ~0034721

I would like to use this plugin with 1.2.12. Has anybody done this already?

andrea_chi

andrea_chi

2013-01-11 06:34

reporter   ~0034771

I would like to use this plugin with 1.2.12. Has anybody done this already?

shashi1

shashi1

2013-02-07 00:59

reporter   ~0035066

i am new to mantis can any one help me how to install this plugin ( i have unzip and putted this plugin in my mantis plugin folder ) but after installing from admin >> manger >> Manage Plugins i am getting warring message " APPLICATION WARNING #2400: Event "EVENT_NOTIFY_EMAIL" has not yet been declared. " .... also please help me how to install PATCH ..etc

shashi1

shashi1

2013-02-07 07:06

reporter   ~0035072

any one pls help me

cas

cas

2013-02-07 07:50

reporter   ~0035076

Last edited: 2013-02-07 07:50

View 2 revisions

You need to apply the patch which you can find inside the zipfile.
That will amongst other things define the missing event.

shashi1

shashi1

2013-02-07 08:01

reporter   ~0035077

In download folder there is mantis-1.2.4-patch-for-htmlmail-0.1 but in that on first line there is path for

--- core/email_api.php Thu Jan 15 09:14:12 1970
+++ core/email_api.php Thu Jan 15 09:14:12 1970

and 2 more path

which i cant found in the HTMLMail0.1zip folder .. hence its means i have to replace that patch code in my orignal mantis core folder file ??..

please help me

Thanks

cas

cas

2013-02-07 10:28

reporter   ~0035080

that is correct, that are changes on core scripts

arnofx

arnofx

2013-02-12 05:23

reporter   ~0035105

Hi,
I have juste install the HTML MAIL to a 1.2.12 .
I have done the modification on the first note (0028444)
I also check/agragate the differents patch files ,and applies the need modifications on the sources code.

And it woks on a 1.2.12 .

I have done to much modification on my mantis to provide a whole patch sorry !

Chewits

Chewits

2013-03-14 04:15

reporter   ~0035863

Last edited: 2013-03-14 04:16

View 2 revisions

Please help anyone. I'm trying to apply the patch for MantisBT 1.2.11 on Debian:

#patch -p0 -i 01-1.2.7-patch-to-use-HTMLMail-0.1.patch

but get the following:

(Stripping trailing CRs from patch.)
patching file b/core/email_api.php
Hunk 1 FAILED at 447.
Hunk 2 FAILED at 483.
Hunk 3 FAILED at 515.
Hunk 4 FAILED at 781.
Hunk 5 FAILED at 817.
Hunk 6 FAILED at 930.
Hunk 7 FAILED at 1126.
Hunk 8 FAILED at 1189.
8 out of 8 hunks FAILED -- saving rejects to file b/core/email_api.php.rej
(Stripping trailing CRs from patch.)
patching file b/core/events_inc.php
Hunk 1 FAILED at 108.
1 out of 1 hunk FAILED -- saving rejects to file b/core/events_inc.php.rej
(Stripping trailing CRs from patch.)
patching file b/docbook/developers/en/event-reference-notify.sgml
Hunk 1 FAILED at 55.
1 out of 1 hunk FAILED -- saving rejects to file b/docbook/developers/en/event-reference-notify.sgml.rej
(Stripping trailing CRs from patch.)
patching file b/manage_user_update.php
Hunk 1 FAILED at 164.
1 out of 1 hunk FAILED -- saving rejects to file b/manage_user_update.php.rej

What am I doing wrong?

zdroyer

zdroyer

2013-03-14 05:54

reporter   ~0035866

Chewits

the pathfile 01-1.2.7-patch-to-use-HTMLMail-0.1.patch works with MantisBT 1.2.7

for MantisBT 1.2.11 you have to apply the changes manually :-(

syiu

syiu

2013-05-03 11:54

reporter   ~0036782

Last edited: 2013-05-03 11:55

View 2 revisions

Hello,

I have install this plugin and it works but i don't have the link to configure in the plugin manager.

Do you know why ?

My Mantis is 1.2.14

syiu

syiu

2013-05-15 10:10

reporter   ~0036864

Hello,

There is a 'bug' in HTMLMail.php (line:121), '\templates\' must be replaced by '/templates/' if the server is a linux.

bkraul

bkraul

2014-03-13 07:39

reporter   ~0039663

Last edited: 2014-03-13 11:36

View 3 revisions

I was able to make it work fine with 1.2.17. Naturally, I had to manually apply all the patches. It was pretty much the same, except for a line in email_api.php that was slightly different in 1.2.17, in which email_store is actually assigned to a variable, but it is easy to spot.

As far as manager configuration page, I don't think there is one at all (I could be wrong).

Everything works, except one thing.

I have a custom status enum string as follows:

$g_status_enum_string = "10:new,20:feedback,30:acknowledged,40:confirmed,50:assigned,60:active,70:on hold,80:resolved,90:closed";

The email notification event gets triggered by all of the status changes but the 2 extra I added: 60:active, and 70:on hold. Mantis does send an email, but it is the old, plain text one. Any help on how to get mantis to trigger the same event that ends up calling the HTMLMail plugin?

Once I get that set up, this plugin will work 100% on my environment.

bkraul

bkraul

2014-03-13 11:10

reporter   ~0039664

Last edited: 2014-03-13 13:45

View 2 revisions

Just a followup (I hate when people ask questions, then solve it themselves and never come back to write their solution). I was able to solve my problem by creating the correct template files for my 2 custom statuses, in this case:

email_notification_title_for_status_bug_active.tpl
email_notification_title_for_status_bug_on_hold.tpl

Thanks for this plugin! Adds such power to my old, clanky bug tracking system.

vovella

vovella

2015-03-12 07:28

reporter   ~0049190

Hello!

Plugin was installed, patch was applied, but notification continue receive in plain text format.

Mantis ver. 1.2.15

Anybody know, what to do yet that notification receive in html format?

vovella

vovella

2015-03-12 08:32

reporter   ~0049191

Sorry, resolve problem.

in HTMLMail.php (line:121), '\templates\' must be replaced by '/templates/' if the server is a linux.

vovella

vovella

2015-03-12 11:09

reporter   ~0049193

I have one question! Anybody know how I can make language strings?!

zdroyer

zdroyer

2015-03-12 11:30

reporter   ~0049194

It's standard:
-in the plugin dir create subdir lang
-create language files (php syntax), for english "strings_english.txt", for german "strings_german.txt" ...
-dont forget about <?php , ?> enclosing in the language files
-define the strings inside the files:
$s_plugin_HTMLMail_the_issue_s_has_been_closed = "Nous vous informons que le cas %s a été clos.";
$s_plugin_HTMLMail_issue_details = "Détails du cas";
-use the string in the .tpl template files by calling "plugin_lang_get":
printf( plugin_lang_get( 'the_issue_s_has_been_closed' ), $parameters['email_bug'] );
plugin_lang_get( 'issue_details' )

vovella

vovella

2015-03-12 12:40

reporter   ~0049197

Thank you for explain.

Unfortunately, it did not work.

I trying to add one string from your example and get error.

http://mantis/admin/test_langs.php

Trying to find+check plugin language files...

Checking language files for plugin HTMLMail:
Testing English language file...
Testing language file 'strings_english.txt' (phase 1)...
ERROR: Language strings should be single-quoted (line 2)
Testing language file 'strings_english.txt' (phase 2)...
Retrieved 1 languages
Testing language file 'strings_russian.txt' (phase 1)...
ERROR: Whitespace in language file outside of PHP code block (line 1)
ERROR: Language strings should be single-quoted (line 2)
FAILED: Language file 'strings_russian.txt' failed at phase 1.
Testing language file 'strings_russian.txt' (phase 2)...
FAILED: Language file 'strings_russian.txt' failed at require_once (data output: '')

vovella

vovella

2015-03-12 12:56

reporter   ~0049198

Perhaps it makes sense to release a plug-in version 0.2? :)

Adding the language support and a color stain status as well as the system itself.

zdroyer

zdroyer

2015-03-12 13:14

reporter   ~0049202

yeah, but I thing the error messages are quite clear:
change the double quotes into single ones and remove everything from outside the the PHP code in the language files and it will work
good luck - fingers crossed

deserteagle

deserteagle

2015-07-09 04:19

reporter   ~0051040

My version is mantisbt-1.2.10, I applied the patch one by one and it work, the notification email come with jpg/png attachment.

But recently the email was sent out without attachment, I tried another smtp server, it's still no attachment with email, I turn the debug on but can not find out what's the problem.

2015-07-09 16:13 CST mail Issue = #123, Type = new, Msg = 'email_notification_title_for_action_bug_submitted', User = @U8, Email = 'knowledge@chn.mycompany.com'.
2015-07-09 16:13 CST mail Before attaching file_id to EmailData
2015-07-09 16:13 CST mail Bug history defined
2015-07-09 16:13 CST mail Bug [123] exists, selecting files to attach
2015-07-09 16:13 CST mail After attach_files_to_emaildata called
2015-07-09 16:13 CST mail HTML email body:\n <html>
<body>
<h3>The following issue has been SUBMITTED.</h3>
<a href="http://chinash2012/bugtrack/view.php?id=123"><span>http://chinash2012/bugtrack/view.php?id=123</span></a>



<h2>Informations:</h2>
<table>
<tr><td>Reported By</td><td>cnkb</td></tr>
<tr><td>Assigned To</td><td>cnzhangji</td></tr>
<tr><td></td><td></td></tr>
<tr><td>Project</td><td>Sales Square</td></tr>
<tr><td>Issue ID</td><td>123</td></tr>
<tr><td>Category</td><td>Website</td></tr>
<tr><td>Reproducibility</td><td>always</td></tr>
<tr><td>Severity </td><td>minor</td></tr>
<tr><td>Priority </td><td>normal</td></tr>
<tr><td>Status </td><td>assigned</td></tr>

    <tr>
        <td>Sub System</td>
        <td> Both</td>
    </tr>

<tr><td></td><td></td></tr>
<tr><td>Date Submitted</td><td>2015-07-09 16:13 CST</td></tr>
<tr><td>Last Modified</td><td>2015-07-09 16:13 CST</td></tr>

<tr><td>Reported By</td><td>cnkb</td></tr>

</table>

<h2>Summary:</h2>
test email notification
<h2>Description:</h2>
chinash2912.dc01.mycompany

<h2>History:</h2>
<table>
    <tr>
        <th>Date modified</th>
        <th>Username</th>
        <th>Field</th>
        <th>Change</th>
    </tr>

        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>New Issue</td>
        <td></td>
        </tr>
        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>Status</td>
        <td>new => assigned</td>
        </tr>
        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>Assigned To</td>
        <td> => cnzhangji</td>
        </tr>
        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>File Added: 96DPI.png</td>
        <td></td>
        </tr>
</table>





</body>
</html>
2015-07-09 16:13 CST mail \n$params available for email template:\n Array
(
[email_bug] => 123
[email_bug_view_url] => http://chinash2012/bugtrack/view.php?id=123
[email_handler] => cnzhangji
[email_reporter] => cnkb
[email_project_id] => 1
[email_project] => Sales Square
[email_category] => Website
[email_date_submitted] => 1436429600
[email_last_modified] => 1436429600
[email_status] => 50
[email_severity] => 50
[email_priority] => 30
[email_reproducibility] => 10
[email_resolution] => 10
[email_fixed_in_version] =>
[email_summary] => test email notification
[email_description] => chinash2912.dc01.mycompany
[email_additional_information] =>
[email_steps_to_reproduce] =>
[set_category] => [Sales Square] Website
[custom_fields] => Array
(
[Sub System] => Array
(
[type] => 9
[value] => Both
[access_level_r] => 25
)

    )

[bugnotes] => Array
    (
    )

[history] => Array
    (
        [0] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => 
                [type] => 1
                [old_value] => 
                [new_value] => 
            )

        [1] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => status
                [type] => 0
                [old_value] => 10
                [new_value] => 50
            )

        [2] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => handler_id
                [type] => 0
                [old_value] => 0
                [new_value] => 2
            )

        [3] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => 
                [type] => 9
                [old_value] => 96DPI.png
                [new_value] => 
            )

    )

[relations] => 
[header_optional_params] => 
[email_subject_bug_id_part] => [Sales Square 0000123] 
[email_status_formatted] => assigned
[email_severity_formatted] => minor
[email_priority_formatted] => normal
[email_reproducibility_formatted] => always
[email_date_submitted_formatted] => 2015-07-09 16:13 CST
[email_last_modified_formatted] => 2015-07-09 16:13 CST

)

2015-07-09 16:13 CST mail Issue = #123, Type = new, Msg = 'email_notification_title_for_action_bug_submitted', User = @U2, Email = 'david.li@dc01.mycompany'.
2015-07-09 16:13 CST mail Before attaching file_id to EmailData
2015-07-09 16:13 CST mail Bug history defined
2015-07-09 16:13 CST mail Bug [123] exists, selecting files to attach
2015-07-09 16:13 CST mail After attach_files_to_emaildata called
2015-07-09 16:13 CST mail HTML email body:\n <html>
<body>
<h3>The following issue has been SUBMITTED.</h3>
<a href="http://chinash2012/bugtrack/view.php?id=123"><span>http://chinash2012/bugtrack/view.php?id=123</span></a>



<h2>Informations:</h2>
<table>
<tr><td>Reported By</td><td>cnkb</td></tr>
<tr><td>Assigned To</td><td>cnzhangji</td></tr>
<tr><td></td><td></td></tr>
<tr><td>Project</td><td>Sales Square</td></tr>
<tr><td>Issue ID</td><td>123</td></tr>
<tr><td>Category</td><td>Website</td></tr>
<tr><td>Reproducibility</td><td>always</td></tr>
<tr><td>Severity </td><td>minor</td></tr>
<tr><td>Priority </td><td>normal</td></tr>
<tr><td>Status </td><td>assigned</td></tr>

    <tr>
        <td>Sub System</td>
        <td> Both</td>
    </tr>

<tr><td></td><td></td></tr>
<tr><td>Date Submitted</td><td>2015-07-09 16:13 CST</td></tr>
<tr><td>Last Modified</td><td>2015-07-09 16:13 CST</td></tr>

<tr><td>Reported By</td><td>cnkb</td></tr>

</table>

<h2>Summary:</h2>
test email notification
<h2>Description:</h2>
chinash2912.dc01.mycompany

<h2>History:</h2>
<table>
    <tr>
        <th>Date modified</th>
        <th>Username</th>
        <th>Field</th>
        <th>Change</th>
    </tr>

        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>New Issue</td>
        <td></td>
        </tr>
        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>Status</td>
        <td>new => assigned</td>
        </tr>
        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>Assigned To</td>
        <td> => cnzhangji</td>
        </tr>
        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>File Added: 96DPI.png</td>
        <td></td>
        </tr>
</table>





</body>
</html>
2015-07-09 16:13 CST mail \n$params available for email template:\n Array
(
[email_bug] => 123
[email_bug_view_url] => http://chinash2012/bugtrack/view.php?id=123
[email_handler] => cnzhangji
[email_reporter] => cnkb
[email_project_id] => 1
[email_project] => Sales Square
[email_category] => Website
[email_date_submitted] => 1436429600
[email_last_modified] => 1436429600
[email_status] => 50
[email_severity] => 50
[email_priority] => 30
[email_reproducibility] => 10
[email_resolution] => 10
[email_fixed_in_version] =>
[email_summary] => test email notification
[email_description] => chinash2912.dc01.mycompany
[email_additional_information] =>
[email_steps_to_reproduce] =>
[set_category] => [Sales Square] Website
[custom_fields] => Array
(
[Sub System] => Array
(
[type] => 9
[value] => Both
[access_level_r] => 25
)

    )

[bugnotes] => Array
    (
    )

[history] => Array
    (
        [0] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => 
                [type] => 1
                [old_value] => 
                [new_value] => 
            )

        [1] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => status
                [type] => 0
                [old_value] => 10
                [new_value] => 50
            )

        [2] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => handler_id
                [type] => 0
                [old_value] => 0
                [new_value] => 2
            )

        [3] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => 
                [type] => 9
                [old_value] => 96DPI.png
                [new_value] => 
            )

    )

[relations] => 
[header_optional_params] => 
[email_subject_bug_id_part] => [Sales Square 0000123] 
[email_status_formatted] => assigned
[email_severity_formatted] => minor
[email_priority_formatted] => normal
[email_reproducibility_formatted] => always
[email_date_submitted_formatted] => 2015-07-09 16:13 CST
[email_last_modified_formatted] => 2015-07-09 16:13 CST

)

2015-07-09 16:13 CST mail Issue = #123, Type = new, Msg = 'email_notification_title_for_action_bug_submitted', User = @U6, Email = 'Jacky.Lu@chn.mycompany.com'.
2015-07-09 16:13 CST mail Before attaching file_id to EmailData
2015-07-09 16:13 CST mail Bug history defined
2015-07-09 16:13 CST mail Bug [123] exists, selecting files to attach
2015-07-09 16:13 CST mail After attach_files_to_emaildata called
2015-07-09 16:13 CST mail HTML email body:\n <html>
<body>
<h3>下列问题已经提交</h3>
<a href="http://chinash2012/bugtrack/view.php?id=123"><span>http://chinash2012/bugtrack/view.php?id=123</span></a>



<h2>Informations:</h2>
<table>
<tr><td>报告员</td><td>cnkb</td></tr>
<tr><td>处理员</td><td>cnzhangji</td></tr>
<tr><td></td><td></td></tr>
<tr><td>项目</td><td>Sales Square</td></tr>
<tr><td>问题编号</td><td>123</td></tr>
<tr><td>分类</td><td>Website</td></tr>
<tr><td>出现频率</td><td>总是</td></tr>
<tr><td>严重性 </td><td>小错误</td></tr>
<tr><td>优先级 </td><td>中</td></tr>
<tr><td>状态 </td><td>已分派</td></tr>

    <tr>
        <td>Sub System</td>
        <td> Both</td>
    </tr>

<tr><td></td><td></td></tr>
<tr><td>报告日期</td><td>2015-07-09 16:13 CST</td></tr>
<tr><td>最后更新</td><td>2015-07-09 16:13 CST</td></tr>

<tr><td>报告员</td><td>cnkb</td></tr>

</table>

<h2>Summary:</h2>
test email notification
<h2>Description:</h2>
chinash2912.dc01.mycompany

<h2>History:</h2>
<table>
    <tr>
        <th>Date modified</th>
        <th>Username</th>
        <th>Field</th>
        <th>Change</th>
    </tr>

        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>新建问题</td>
        <td></td>
        </tr>
        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>状态</td>
        <td>新建 => 已分派</td>
        </tr>
        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>分派给</td>
        <td> => cnzhangji</td>
        </tr>
        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>添加了以下文件:: 96DPI.png</td>
        <td></td>
        </tr>
</table>





</body>
</html>
2015-07-09 16:13 CST mail \n$params available for email template:\n Array
(
[email_bug] => 123
[email_bug_view_url] => http://chinash2012/bugtrack/view.php?id=123
[email_handler] => cnzhangji
[email_reporter] => cnkb
[email_project_id] => 1
[email_project] => Sales Square
[email_category] => Website
[email_date_submitted] => 1436429600
[email_last_modified] => 1436429600
[email_status] => 50
[email_severity] => 50
[email_priority] => 30
[email_reproducibility] => 10
[email_resolution] => 10
[email_fixed_in_version] =>
[email_summary] => test email notification
[email_description] => chinash2912.dc01.mycompany
[email_additional_information] =>
[email_steps_to_reproduce] =>
[set_category] => [Sales Square] Website
[custom_fields] => Array
(
[Sub System] => Array
(
[type] => 9
[value] => Both
[access_level_r] => 25
)

    )

[bugnotes] => Array
    (
    )

[history] => Array
    (
        [0] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => 
                [type] => 1
                [old_value] => 
                [new_value] => 
            )

        [1] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => status
                [type] => 0
                [old_value] => 10
                [new_value] => 50
            )

        [2] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => handler_id
                [type] => 0
                [old_value] => 0
                [new_value] => 2
            )

        [3] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => 
                [type] => 9
                [old_value] => 96DPI.png
                [new_value] => 
            )

    )

[relations] => 
[header_optional_params] => 
[email_subject_bug_id_part] => [Sales Square 0000123] 
[email_status_formatted] => 已分派
[email_severity_formatted] => 小错误
[email_priority_formatted] => 中
[email_reproducibility_formatted] => 总是
[email_date_submitted_formatted] => 2015-07-09 16:13 CST
[email_last_modified_formatted] => 2015-07-09 16:13 CST

)

2015-07-09 16:13 CST mail Issue = #123, Type = new, Msg = 'email_notification_title_for_action_bug_submitted', User = @U9, Email = 'rayna.wei@chn.mycompany.com'.
2015-07-09 16:13 CST mail Before attaching file_id to EmailData
2015-07-09 16:13 CST mail Bug history defined
2015-07-09 16:13 CST mail Bug [123] exists, selecting files to attach
2015-07-09 16:13 CST mail After attach_files_to_emaildata called
2015-07-09 16:13 CST mail HTML email body:\n <html>
<body>
<h3>下列问题已经提交</h3>
<a href="http://chinash2012/bugtrack/view.php?id=123"><span>http://chinash2012/bugtrack/view.php?id=123</span></a>



<h2>Informations:</h2>
<table>
<tr><td>报告员</td><td>cnkb</td></tr>
<tr><td>处理员</td><td>cnzhangji</td></tr>
<tr><td></td><td></td></tr>
<tr><td>项目</td><td>Sales Square</td></tr>
<tr><td>问题编号</td><td>123</td></tr>
<tr><td>分类</td><td>Website</td></tr>
<tr><td>出现频率</td><td>总是</td></tr>
<tr><td>严重性 </td><td>小错误</td></tr>
<tr><td>优先级 </td><td>中</td></tr>
<tr><td>状态 </td><td>已分派</td></tr>

    <tr>
        <td>Sub System</td>
        <td> Both</td>
    </tr>

<tr><td></td><td></td></tr>
<tr><td>报告日期</td><td>2015-07-09 16:13 CST</td></tr>
<tr><td>最后更新</td><td>2015-07-09 16:13 CST</td></tr>

<tr><td>报告员</td><td>cnkb</td></tr>

</table>

<h2>Summary:</h2>
test email notification
<h2>Description:</h2>
chinash2912.dc01.mycompany

<h2>History:</h2>
<table>
    <tr>
        <th>Date modified</th>
        <th>Username</th>
        <th>Field</th>
        <th>Change</th>
    </tr>

        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>新建问题</td>
        <td></td>
        </tr>
        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>状态</td>
        <td>新建 => 已分派</td>
        </tr>
        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>分派给</td>
        <td> => cnzhangji</td>
        </tr>
        <tr>
        <td>2015-07-09 16:13</td>
        <td>cnkb</td>
        <td>添加了以下文件:: 96DPI.png</td>
        <td></td>
        </tr>
</table>





</body>
</html>
2015-07-09 16:13 CST mail \n$params available for email template:\n Array
(
[email_bug] => 123
[email_bug_view_url] => http://chinash2012/bugtrack/view.php?id=123
[email_handler] => cnzhangji
[email_reporter] => cnkb
[email_project_id] => 1
[email_project] => Sales Square
[email_category] => Website
[email_date_submitted] => 1436429600
[email_last_modified] => 1436429600
[email_status] => 50
[email_severity] => 50
[email_priority] => 30
[email_reproducibility] => 10
[email_resolution] => 10
[email_fixed_in_version] =>
[email_summary] => test email notification
[email_description] => chinash2912.dc01.mycompany
[email_additional_information] =>
[email_steps_to_reproduce] =>
[set_category] => [Sales Square] Website
[custom_fields] => Array
(
[Sub System] => Array
(
[type] => 9
[value] => Both
[access_level_r] => 25
)

    )

[bugnotes] => Array
    (
    )

[history] => Array
    (
        [0] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => 
                [type] => 1
                [old_value] => 
                [new_value] => 
            )

        [1] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => status
                [type] => 0
                [old_value] => 10
                [new_value] => 50
            )

        [2] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => handler_id
                [type] => 0
                [old_value] => 0
                [new_value] => 2
            )

        [3] => Array
            (
                [date] => 1436429600
                [userid] => 8
                [username] => cnkb
                [field] => 
                [type] => 9
                [old_value] => 96DPI.png
                [new_value] => 
            )

    )

[relations] => 
[header_optional_params] => 
[email_subject_bug_id_part] => [Sales Square 0000123] 
[email_status_formatted] => 已分派
[email_severity_formatted] => 小错误
[email_priority_formatted] => 中
[email_reproducibility_formatted] => 总是
[email_date_submitted_formatted] => 2015-07-09 16:13 CST
[email_last_modified_formatted] => 2015-07-09 16:13 CST

)

AlexeiK

AlexeiK

2016-02-09 13:36

reporter   ~0052496

Please write about this plugin somewhere on main site.

AlexeiK

AlexeiK

2016-02-10 01:44

reporter   ~0052497

update for 1.3.0 rc1



HTMLMail_1.3.0.rc1.rar (20,552 bytes)
AlexeiK

AlexeiK

2016-02-10 01:48

reporter   ~0052498

update for 1.3.0 rc1 with overwrite files.



HTMLMail_1.3.0.rc1_plus_overwrite.rar (39,355 bytes)
AlexeiK

AlexeiK

2016-02-10 01:54

reporter   ~0052499

i mean for 1.3.0-rc.2-dev master-9d8d010

atrol

atrol

2016-02-10 02:22

developer   ~0052501

Last edited: 2016-02-10 03:01

View 2 revisions

Please write about this plugin somewhere on main site.

It's no good idea to tell users to install a 3rd party plugin which is not maintained.
Furthermore users are told to change original source of Mantis.
Such kind of changes can introduce side effects and are lost when upgrading.
Most of our users are not able to deal with such kind of problems, thus the small Mantis core team would waste some of their limited time.

AlexeiK

AlexeiK

2016-02-10 02:54

reporter   ~0052502

what is good or not?
is bulk of text good?
is nice html good?

as for me : bulk text is not good, nice html is good.
if so, i will go for html way and start to write about this, start to search this:)
i understand u dont want comments about installing and run this plugin from customers. ok.
but for developers as customers its ok to apply this plugin on mantis.

i check this plugin and it works good for mantis 1.3.0 rc2.
but it requiers new code for core part of mantis.

vovella

vovella

2016-03-26 09:02

reporter   ~0052869

Please tell me how to make attachments were sent only when it is added, but not in all further email?

deserteagle

deserteagle

2016-04-22 04:07

reporter   ~0053004

hi, AlexeiK

I upgrade my installation from 1.2.8 to 1.3.1 the implemented with HTMLMail_1.3.0.rc1_plus_overwrite.rar, the email notification work but the attachment (jpg) did not attached with the email.

I also tried implemented it on a new installation of 1.3.0rc1, still no attachment with email.

want to try 1.3.0rc2 but can not find where to download it.

akimeu007

akimeu007

2016-06-24 21:14

reporter   ~0053446

I applied this to 1.3.0 rc2. The emails do come out as HTML, nicely formatted. The only thing not working is the manage_user_update.php. The minute I add the line with email_notification_user_update, the system fails. AlexeiK- how did you get to work? Did I miss a step?

AlexeiK

AlexeiK

2017-01-10 07:16

reporter   ~0055018

akimeu007,
no way to help to you.
dump error or something.

i will move to mantis 2 and check how it goes there.

DjBend

DjBend

2017-02-07 06:24

reporter   ~0055526

Hello, AlexeiK
I tried to use your plug-in for MantisBT version 2.1.0
In HTMLMail.php file replacement conditions
'MantisCore' => '1.3' to 'MantisCore' => '2.0'
Edit all 3 file from instructions by .patch files.
But when I replace email_api.php and events_inc.php files, I get an error when adding a comment.
APPLICATION ERROR # 11
A necessary field "Body" was empty. Please recheck your inputs.
But the comment has successfully added.
Perhaps there are other ways to cause this error. I have not yet checked.

You managed to adapt it to new versions 2.x?



HTMLMail_2.1_notwork.zip (43,752 bytes)
AlexeiK

AlexeiK

2017-02-07 06:49

reporter   ~0055529

DjBend, i didnt move to mantis 2.0.
it has awful design that breaks eyes.
So, i cant help u to make a mod for that files (email_api, events_inc).

gdicesare

gdicesare

2017-02-21 15:34

reporter   ~0055732

Hi, AlexeiK
You will be launching a release for mantis 2.x?
I was using this plugin with mantis 1.2.19 and no problems. I have to move to mantis 2.x now and there is no way to make it work.
Any news on this?
Thanks

mjaq

mjaq

2017-04-03 06:21

reporter   ~0056343

Hello,

@AlexeiK, @gdicesare, @or_anyone :)
Did you implemented 'htmlmail plugin' in Mantis 2.x successfully? If yes, could you paste a snippet of modified code (especially email_api and events_inc)? I also tried change some piece of code, but unfortunately without a positive effect.

Thank you for any help.

Regards.

gdicesare

gdicesare

2017-04-03 11:27

reporter   ~0056352

Hi @mjaq
I try to edit the email_api and no succed.
I didn't dedicate a lot of time on it, because what we need is to not send de notes in a mail.
I solve that by commenting some core lines in email_api where the bugnote is formatted.
Hope I can be of any help.

Regards.

mjaq

mjaq

2017-04-04 07:05

reporter   ~0056369

Hi,

@gdicesare,
We want to use this plugin to exchange data between second bugnote system. That's why we must sending e-mail with attachments.

@AlexeiK,
You are our last hope. ;)

Regards.

AlexeiK

AlexeiK

2017-04-05 02:27

reporter   ~0056386

i cant let myself use mantis 2.0 - why? it has ugly interface and not usable for me anymore.
my eyes only wants with 1.x branch

so im not interested .
only if mantis 2.0 will have 1.3 UI i will adapt this plugin.

atrol

atrol

2017-04-05 05:42

developer   ~0056390

@ users who want to use this plugin, read 0012830:0052501 before installation.

yanual

yanual

2017-04-11 10:27

reporter   ~0056494

I'm basically in agreement with you.
That said, could you tell us what is the procedure for requesting evolutions in the original core.
This is to be able to develop plugins for embellish your product of which I am a fan.
It seems that we need an event that can be hook with the transmission of the structure allowing to identify the origin of the request of the mail (message_id in email_api.php) and the informations already established during the constitution of the native mail (now email_store in email_api.php).

Best regards.

yanual

yanual

2017-04-11 11:15

reporter   ~0056495

@atrol
We also need to set $email-> IsHTML to true on a condition of a data accessible by the callback of the plugin.
Thank you in advance for your help, this for the encouragement of the community of fervent defenders of MantisBt.

atrol

atrol

2017-04-17 08:03

developer   ~0056599

could you tell us what is the procedure for requesting evolutions in the original core.

https://mantisbt.org/docs/master/en-US/Developers_Guide/html-desktop/#dev.contrib.submit

yanual

yanual

2017-04-19 10:51

reporter   ~0056621

@atrol
Thanks a lot.
I will have to make an effort to follow your process. But, this is legitimate for inter-acting with the main trunk.
I will work to acquire your prerequisites and submit you in the best conditions my requests for evolutions.
This will take me a little bit time, just like you this activity is not my main job.

@contributor
May be some goodwills could also participate in the evolution request. Thus the plugin could be develop and install without recurring patch.

I'm not familiar with:
Github Pull Requests
Git repository
Git Formatted patches

Sorry for my english (DIY with google). I'm French with only the necessary bases to evolve in the computing developments.

Issue History

Date Modified Username Field Change
2011-03-01 08:20 barnabas.sudy New Issue
2011-03-01 08:20 barnabas.sudy File Added: HTMLMail0.1.zip
2011-03-01 14:22 vboctor Tag Attached: plugin
2011-03-01 14:22 vboctor Tag Attached: patch
2011-03-19 18:36 econsor Note Added: 0028444
2011-07-15 10:06 zdroyer File Added: mantis-1.2.5-patch-for-htmlmail-0.1.patch
2011-07-15 10:22 zdroyer Note Added: 0029176
2011-07-15 10:25 zdroyer Note Edited: 0029176 View Revisions
2011-08-09 05:59 zdroyer Note Added: 0029409
2011-08-16 05:54 zdroyer Note Added: 0029483
2011-08-16 06:08 zdroyer Tag Attached: attachments
2011-08-16 06:08 zdroyer Tag Attached: custom
2011-08-16 06:08 zdroyer Tag Attached: email
2011-08-16 06:08 zdroyer Tag Attached: html
2011-08-16 06:08 zdroyer Tag Attached: HTMLmail
2011-08-16 06:08 zdroyer Tag Attached: notification
2011-08-16 06:08 zdroyer Tag Attached: template
2011-10-06 07:57 zdroyer Note Added: 0029924
2011-10-26 12:37 zdroyer File Added: 01-1.2.7-patch-to-use-HTMLMail-0.1.patch
2011-10-26 12:37 zdroyer File Added: 02-1.2.7-email_attachments.patch
2011-10-26 12:37 zdroyer File Added: HTMLMail.php
2011-10-26 12:42 zdroyer Note Added: 0030081
2011-11-04 09:03 eejape Note Added: 0030170
2011-11-07 03:44 zdroyer Note Added: 0030183
2011-11-07 03:45 zdroyer Note Edited: 0030183 View Revisions
2011-11-07 04:06 zdroyer Note Added: 0030185
2011-11-07 04:54 atrol Relationship added related to 0009602
2012-01-05 04:48 clancy Note Added: 0030801
2012-01-05 04:49 clancy Note Edited: 0030801 View Revisions
2012-01-05 04:50 clancy Note Edited: 0030801 View Revisions
2012-01-05 04:52 clancy Note Edited: 0030801 View Revisions
2012-01-05 04:56 clancy Note Edited: 0030801 View Revisions
2012-01-05 04:57 clancy Note Edited: 0030801 View Revisions
2012-01-05 04:58 clancy Note Edited: 0030801 View Revisions
2012-01-05 04:59 clancy Note Edited: 0030801 View Revisions
2012-01-05 05:01 clancy Note Edited: 0030801 View Revisions
2012-01-05 05:01 clancy Note Edited: 0030801 View Revisions
2012-01-05 11:11 clancy Note Edited: 0030801 View Revisions
2012-01-27 03:01 vboctor Relationship added related to 0010084
2012-01-27 03:08 vboctor Relationship added related to 0013692
2012-03-05 14:22 atrol Relationship added related to 0012639
2012-03-05 14:25 atrol Relationship added related to 0008986
2012-03-05 14:26 atrol Relationship added related to 0014006
2012-03-05 15:41 atrol Relationship added related to 0001400
2012-07-26 03:39 atrol Relationship added has duplicate 0014510
2013-01-07 05:54 slick Note Added: 0034721
2013-01-11 06:34 andrea_chi Note Added: 0034771
2013-02-07 00:59 shashi1 Note Added: 0035066
2013-02-07 07:06 shashi1 Note Added: 0035072
2013-02-07 07:50 cas Note Added: 0035076
2013-02-07 07:50 cas Note Edited: 0035076 View Revisions
2013-02-07 08:01 shashi1 Note Added: 0035077
2013-02-07 10:28 cas Note Added: 0035080
2013-02-12 05:23 arnofx Note Added: 0035105
2013-03-14 04:15 Chewits Note Added: 0035863
2013-03-14 04:16 Chewits Note Edited: 0035863 View Revisions
2013-03-14 05:54 zdroyer Note Added: 0035866
2013-05-03 11:54 syiu Note Added: 0036782
2013-05-03 11:55 syiu Note Edited: 0036782 View Revisions
2013-05-15 10:10 syiu Note Added: 0036864
2014-02-02 05:54 atrol Severity minor => feature
2014-02-02 05:54 atrol Category email => plug-ins
2014-03-13 07:39 bkraul Note Added: 0039663
2014-03-13 11:10 bkraul Note Added: 0039664
2014-03-13 11:36 bkraul Note Edited: 0039663 View Revisions
2014-03-13 11:36 bkraul Note Edited: 0039663 View Revisions
2014-03-13 13:45 bkraul Note Edited: 0039664 View Revisions
2015-03-12 07:28 vovella Note Added: 0049190
2015-03-12 08:32 vovella Note Added: 0049191
2015-03-12 11:09 vovella Note Added: 0049193
2015-03-12 11:30 zdroyer Note Added: 0049194
2015-03-12 12:40 vovella Note Added: 0049197
2015-03-12 12:56 vovella Note Added: 0049198
2015-03-12 13:14 zdroyer Note Added: 0049202
2015-07-09 04:19 deserteagle Note Added: 0051040
2016-02-09 07:47 atrol Relationship added has duplicate 0020586
2016-02-09 13:36 AlexeiK Note Added: 0052496
2016-02-10 01:44 AlexeiK File Added: HTMLMail_1.3.0.rc1.rar
2016-02-10 01:44 AlexeiK Note Added: 0052497
2016-02-10 01:48 AlexeiK File Added: HTMLMail_1.3.0.rc1_plus_overwrite.rar
2016-02-10 01:48 AlexeiK Note Added: 0052498
2016-02-10 01:54 AlexeiK Note Added: 0052499
2016-02-10 02:22 atrol Note Added: 0052501
2016-02-10 02:54 AlexeiK Note Added: 0052502
2016-02-10 03:01 atrol Note Edited: 0052501 View Revisions
2016-03-26 09:02 vovella Note Added: 0052869
2016-04-22 04:07 deserteagle Note Added: 0053004
2016-06-24 21:14 akimeu007 Note Added: 0053446
2016-07-20 17:10 atrol Tag Detached: notification
2017-01-10 07:16 AlexeiK Note Added: 0055018
2017-02-07 06:24 DjBend File Added: HTMLMail_2.1_notwork.zip
2017-02-07 06:24 DjBend Note Added: 0055526
2017-02-07 06:49 AlexeiK Note Added: 0055529
2017-02-21 15:34 gdicesare Note Added: 0055732
2017-04-03 06:21 mjaq Note Added: 0056343
2017-04-03 11:27 gdicesare Note Added: 0056352
2017-04-04 07:05 mjaq Note Added: 0056369
2017-04-05 02:27 AlexeiK Note Added: 0056386
2017-04-05 05:42 atrol Note Added: 0056390
2017-04-11 10:27 yanual Note Added: 0056494
2017-04-11 11:15 yanual Note Added: 0056495
2017-04-17 08:03 atrol Note Added: 0056599
2017-04-19 10:51 yanual Note Added: 0056621