View Issue Details

IDProjectCategoryView StatusLast Update
0004286Plugin - EmailReportingGeneralpublic2016-07-21 15:17
Reporterindy Assigned ToSL-Gundam  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Summary0004286: Solution for reporting via E-Mail
Description

Maybe somebody is interested in, I have written a script for receiving bug reports through a POP3 E-Mail account.
It is based on the file bug_report.php and works this time.

Tagsadmin, email
Attached Files
Mantis.tgz (2,101 bytes)
mantis-working.patch (23,038 bytes)   
diff -rNu mantis.orig/README.bug_report_mail mantis/README.bug_report_mail
--- mantis.orig/README.bug_report_mail	Thu Jan  1 01:00:00 1970
+++ mantis/README.bug_report_mail	Mon Aug  9 23:26:21 2004
@@ -0,0 +1,54 @@
+The current version of bug_report_mail only support plain text e-mails
+and POP3 Mailaccounts with PEAR's Net_POP3 packge.
+
+bug_report_mail is able to recognize if mail is a reply to an already opened
+bug and adds the content as a bugnote.
+
+If you are alway running Mantis you have to alter you projects table
+with the sql/bug_report_mail.sql script.
+If not, you can create the database tables in the way described in
+the doc/INSTALL file.
+
+This patch changes the following files:
+    core/user_api.php
+    manage_proj_edit_page.php
+    config_inc.php.sample
+These files are new:
+    core/mail_api.php
+    sql/bug_report_mail.php
+    bug_report_mail.php
+    manage_proj_mail_delete.php
+    manage_proj_mail_update.php
+
+After installing this patch, you can add a POP3 server's hostname
+and authentication data for each of your projects with the
+project edit form.
+
+There are two ways to receive mail with bug_report_mail:
+The secure way is to use a standard reporting user:
+You have to create a reporter account, for example 'Mail'.
+The name for this reporter account you have to write in your config_inc.php file:
+	$g_mail_reporter = "Mail";
+and then, bug_report_mail must be informed to behave like this:
+    $g_mail_use_reporter = ON;
+
+The other way is to signup new user accounts automatically.
+For using this, you have to change this
+    $g_mail_auto_signup     = OFF;
+from OFF to ON.
+Now, bug_report_mail will look for an user named like the mail's sender
+or an user which mail adress is identical.
+If no user is found, then a new account will be created.
+The new user's name will be the mail address.
+
+This could be used for attacks, but there is no other way in the moment.
+
+After this, bug_report_mail can be used via cron like this:
+
+*/5 *   *   *   * lynx --dump http://mantis.homepage.com/bug_report_mail.php
+
+This line uses lynx to fetch bug reports from via POP3 every 5 minutes. 
+
+This addon is distributed under the same condition as Mantis itself.
+
+Gerrit Beine, August 2004
diff -rNu mantis.orig/bug_report_mail.php mantis/bug_report_mail.php
--- mantis.orig/bug_report_mail.php	Thu Jan  1 01:00:00 1970
+++ mantis/bug_report_mail.php	Mon Aug  9 23:24:27 2004
@@ -0,0 +1,37 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+    # Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+    # Copyright (C) 2004  pitcom GmbH, Plauen, Germany
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+?>
+<?php
+	# This page receives an E-Mail via POP3 and generates an Report
+    header("Content-type: text/plain");
+?>
+<?php
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path.'string_api.php' );
+	require_once( $t_core_path.'bug_api.php' );
+	require_once( $t_core_path.'mail_api.php' );
+?>
+<?php
+	$t_projects = mail_project_get_all_rows();
+	foreach ($t_projects as $t_project) {
+		$t_mails = mail_get_all_mails($t_project);
+        foreach ($t_mails as $t_mail)
+        {
+            mail_add_bug($t_mail, $t_project);
+        }
+	}
+?>
+
diff -rNu mantis.orig/config_inc.php mantis/config_inc.php
--- mantis.orig/config_inc.php	Thu Jan  1 01:00:00 1970
+++ mantis/config_inc.php	Mon Aug  9 22:27:31 2004
@@ -0,0 +1,78 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id: config_inc.php.sample,v 1.12 2004/02/08 13:16:57 vboctor Exp $
+	# --------------------------------------------------------
+	
+	# This sample file contains the essential files that you MUST
+	# configure to your specific settings.  You may override settings
+	# from config_defaults_inc.php by assigning new values in this file
+
+	# Rename this file to config_inc.php after configuration.
+
+	###########################################################################
+	# CONFIGURATION VARIABLES
+	###########################################################################
+
+	# In general the value OFF means the feature is disabled and ON means the
+	# feature is enabled.  Any other cases will have an explanation.
+
+	# Look in http://www.mantisbt.org/manual or config_defaults_inc.php for more
+	# detailed comments.
+
+	# --- database variables ---------
+
+	# set these values to match your setup
+	$g_hostname      = "localhost";
+	$g_port          = 3306;         # 3306 is default
+	$g_db_username   = "root";
+	$g_db_password   = "root";
+	$g_database_name = "mantis";
+
+	# --- email variables -------------
+	$g_administrator_email  = 'administrator@example.com';
+	$g_webmaster_email      = 'webmaster@example.com';
+
+	# the "From: " field in emails
+	$g_from_email           = 'noreply@example.com';
+
+	# the "To: " address all emails are sent.  This can be a mailing list or archive address.
+	# Actual users are emailed via the bcc: fields
+	$g_to_email             = 'nobody@example.com';
+
+	# the return address for bounced mail
+	$g_return_path_email    = 'admin@example.com';
+
+	# --- login method ----------------
+	# CRYPT or PLAIN or MD5 or LDAP or BASIC_AUTH
+	$g_login_method = MD5;
+
+	# --- email vars ------------------
+	# set to OFF to disable email check
+	# These should be OFF for Windows installations
+	$g_validate_email            = OFF;
+	$g_check_mx_record           = OFF;
+
+	# --- file upload settings --------
+	# This is the master setting to disable *all* file uploading functionality
+	#
+	# The default value is ON but you must make sure file uploading is enabled
+	#  in PHP as well.  You may need to add "file_uploads = TRUE" to your php.ini.
+	$g_allow_file_upload	= ON;
+
+    # --- mail reporting settings -----
+    # This tells Mantis to report all the Mail with only one account
+    $g_mail_use_reporter    = OFF;
+    
+    # The account's name for mail reporting
+    $g_mail_reporter        = 'Mail';
+    
+    # Signup new users automatically (possible security risk!)
+    # Default is OFF, only works if mail_use_reporter is OFF
+    $g_mail_auto_signup     = ON;
+?>
diff -rNu mantis.orig/config_inc.php.sample mantis/config_inc.php.sample
--- mantis.orig/config_inc.php.sample	Sun Feb  8 14:16:56 2004
+++ mantis/config_inc.php.sample	Mon Aug  9 18:32:00 2004
@@ -64,4 +64,15 @@
 	# The default value is ON but you must make sure file uploading is enabled
 	#  in PHP as well.  You may need to add "file_uploads = TRUE" to your php.ini.
 	$g_allow_file_upload	= ON;
+    
+    # --- mail reporting settings -----
+    # This tells Mantis to report all the Mail with only one account
+    $g_mail_use_reporter    = ON;
+    
+    # The account's name for mail reporting
+    $g_mail_reporter        = 'Mail';
+    
+    # Signup new users automatically (possible security risk!)
+    # Default is OFF, only works if mail_use_reporter is OFF
+    $g_mail_auto_signup     = OFF;
 ?>
diff -rNu mantis.orig/core/mail_api.php mantis/core/mail_api.php
--- mantis.orig/core/mail_api.php	Thu Jan  1 01:00:00 1970
+++ mantis/core/mail_api.php	Mon Aug  9 23:22:29 2004
@@ -0,0 +1,212 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+    # Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+    # Copyright (C) 2004  pitcom GmbH, Plauen, Germany
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
+	
+	require_once( $t_core_dir . 'bug_api.php' );
+	require_once( $t_core_dir . 'bugnote_api.php' );
+	require_once( $t_core_dir . 'user_api.php' );
+	require_once( $t_core_dir . 'project_api.php' );
+?>
+<?php
+	# This page receives an E-Mail via POP3 and generates an Report
+?>
+<?php
+	require_once( 'Net/POP3.php' );
+    
+	# --------------------
+	# Update the mail account data
+	function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$c_project_id	= db_prepare_int( $p_project_id );
+		$c_pop3_host	= db_prepare_string( $p_pop3_host );
+		$c_pop3_user	= db_prepare_string( $p_pop3_user );
+		$c_pop3_pass	= db_prepare_string( $p_pop3_pass );
+		
+        $t_project_table = config_get( 'mantis_project_table' );
+        
+		$query = "UPDATE $t_project_table 
+				  SET pop3_host='$c_pop3_host',
+					pop3_user='$c_pop3_user',
+					pop3_pass='$c_pop3_pass'
+				  WHERE id='$c_project_id'";
+		db_query( $query );
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data
+	function mail_delete( $p_project_id ) {
+		$c_project_id	= db_prepare_int( $p_project_id );
+		
+        $t_project_table = config_get( 'mantis_project_table' );
+        
+		$query = "UPDATE $t_project_table 
+				  SET pop3_host=NULL,
+					pop3_user=NULL,
+					pop3_pass=NULL
+				  WHERE id='$c_project_id'";
+		db_query( $query );
+		return true;
+	}
+
+	#===================================
+	# Data Access
+	#===================================
+
+	# --------------------
+	# Return all versions for the specified project
+	function mail_get_account_data( $p_project_id ) {
+		$c_project_id = db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass
+				  FROM $t_project_table 
+				  WHERE id='$c_project_id'";
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# return all projects with valid data for mail access
+	#  return an empty array if there are no such projects
+	function mail_project_get_all_rows() {
+		$m_projects = array();
+		$t_projects = project_get_all_rows();
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_host']) {
+				array_push($m_projects, $t_project);
+			}
+		}
+		return $m_projects;
+	}
+
+	# --------------------
+	# return all mails for a project
+	#  return an empty array if there are no new mails
+	function mail_get_all_mails($p_project) {
+		$t_mails = array();
+		$pop3 = &new Net_POP3();
+		$t_pop3_host = $p_project['pop3_host'];
+		$t_pop3_user = $p_project['pop3_user'];
+		$t_pop3_password = $p_project['pop3_pass'];
+		$pop3->connect($t_pop3_host, 110);
+		$pop3->login($t_pop3_user, $t_pop3_password);
+		for ($i = 1; $i <= $pop3->numMsg(); $i++) {
+			$mail = $pop3->getParsedHeaders($i);
+			$mail['X-Mantis-Body'] = $pop3->getBody($i);
+			$mail['X-Mantis-Complete'] = $pop3->getMsg($i);
+			array_push($t_mails, $mail);
+			$pop3->deleteMsg($i);
+		}
+		$pop3->disconnect();
+		return $t_mails;
+	}
+    
+	# --------------------
+	# return the a valid username from an email address
+    function mail_user_name_from_address ($p_mailaddress) {
+        $t_mailaddress = $p_mailaddress;
+        if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) {
+            $t_mailaddress = $matches[1];
+        }
+        return preg_replace("/[@\.-]/",'_',$t_mailaddress);
+    }
+
+	# --------------------
+	# return true if there is a valid mantis bug referernce in subject
+    function mail_is_a_bugnote ($p_subject) {
+        return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_subject);
+    }
+    
+	# --------------------
+	# return the bug's id from the subject
+    function mail_get_bug_id_from_subject ($p_subject) {
+        preg_match("/\[([A-Za-z0-9-_\.]*\s([0-9]{7}?))\]/", $p_subject, $matches);
+        return $matches[2];
+    }
+	# --------------------
+	# return the user id for the mail reporting user
+	#  return false if no username can be found
+    function mail_get_user ($p_mail) {
+        $t_mail_use_reporter = config_get( 'mail_use_reporter' );
+        $t_mail_auto_signup = config_get( 'mail_auto_signup' );
+        if ($t_mail_use_reporter) {
+            $t_mail_reporter = config_get( 'mail_reporter' );
+            $t_reporter_id = user_get_id_by_name($t_mail_reporter);
+        }
+        else {
+            $t_user_name = mail_user_name_from_address($p_mail['From']);
+            $t_reporter_id = user_get_id_by_name($t_user_name);
+            if (!$t_reporter_id) { // try to get the user's id searching for mail address
+                $t_reporter_id = user_get_id_by_mail($p_mail['From']);
+            }
+            if (!$t_reporter_id && $t_mail_auto_signup) { // try to signup the user
+                user_signup($t_user_name, $p_mail['From']);
+                $t_reporter_id = user_get_id_by_name($t_user_name);
+            }
+        }
+        return $t_reporter_id;
+    }
+    
+    # --------------------
+    # Adds a bug reported via email
+    # Todo: If there is already a bug, add it as a bug note
+    function mail_add_bug($p_mail, $p_project) {
+		$f_build				= gpc_get_string( 'build', '' );
+		$f_platform				= gpc_get_string( 'platform', '' );
+		$f_os					= gpc_get_string( 'os', '' );
+		$f_os_build				= gpc_get_string( 'os_build', '' );
+		$f_product_version		= gpc_get_string( 'product_version', '' );
+		$f_profile_id			= gpc_get_int( 'profile_id', 0 );
+		$f_handler_id			= gpc_get_int( 'handler_id', 0 );
+		$f_view_state			= gpc_get_int( 'view_state', 0 );
+
+		$f_category				= gpc_get_string( 'category', '' );
+		$f_priority				= gpc_get_int( 'priority', NORMAL );
+		$f_steps_to_reproduce	= gpc_get_string( 'steps_to_reproduce', '' );
+
+        $f_reproducibility		= 10;
+        $f_severity				= 50;
+        $f_summary				= $p_mail['Subject'];
+        $f_description			= $p_mail['X-Mantis-Body'];
+        $f_additional_info		= $p_mail['X-Mantis-Complete'];
+        $f_project_id			= $p_project['id'];
+        $t_reporter_id		    = mail_get_user($p_mail);
+
+        if (mail_is_a_bugnote($p_mail['Subject']))
+        {
+            # Add a bug note
+            $t_bug_id = mail_get_bug_id_from_subject($p_mail['Subject']);
+            bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] );
+            email_bugnote_add ( $t_bug_id );
+        }
+        else
+        {
+	        # Create the bug
+	        $t_bug_id = bug_create( $f_project_id,
+		    	            $t_reporter_id, $f_handler_id,
+                            $f_priority,
+				            $f_severity, $f_reproducibility,
+					        $f_category,
+					        $f_os, $f_os_build,
+					        $f_platform, $f_product_version,
+					        $f_build,
+					        $f_profile_id, $f_summary, $f_view_state,
+					        $f_description, $f_steps_to_reproduce, $f_additional_info );
+            email_new_bug( $t_bug_id );
+        }
+
+    }
+
+?>
diff -rNu mantis.orig/core/user_api.php mantis/core/user_api.php
--- mantis.orig/core/user_api.php	Sun Jan 11 08:16:10 2004
+++ mantis/core/user_api.php	Sun Aug  8 20:08:38 2004
@@ -413,6 +413,26 @@
 	}
 
 	# --------------------
+	# get a user id from an mail address
+	#  return false if the mail address does not exist
+	function user_get_id_by_mail( $p_mailadress ) {
+		$c_mailadress = db_prepare_string( $p_mailadress );
+
+		$t_user_table = config_get( 'mantis_user_table' );
+
+		$query = "SELECT id
+				  FROM $t_user_table
+				  WHERE email='$c_mailadress'";
+		$result = db_query( $query );
+
+		if ( 0 == db_num_rows( $result ) ) {
+			return false;
+		} else {
+			return db_result( $result );
+		}
+	}
+
+	# --------------------
 	# return all data associated with a particular user name
 	#  return false if the username does not exist
 	function user_get_row_by_name( $p_username ) {
diff -rNu mantis.orig/manage_proj_edit_page.php mantis/manage_proj_edit_page.php
--- mantis.orig/manage_proj_edit_page.php	Sun Jan 11 08:16:06 2004
+++ mantis/manage_proj_edit_page.php	Mon Aug  9 21:37:44 2004
@@ -18,6 +18,7 @@
 	require_once( $t_core_path . 'version_api.php' );
 	require_once( $t_core_path . 'custom_field_api.php' );
 	require_once( $t_core_path . 'icon_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
 ?>
 <?php
 	$f_project_id = gpc_get_int( 'project_id' );
@@ -25,6 +26,7 @@
 	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
 
 	$row = project_get_row( $f_project_id );
+    $mail = mail_get_account_data( $f_project_id );
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -524,6 +526,57 @@
 	}  # end for
 ?>
 	</table>
+</div>
+
+<!-- MAIL ACCOUNT RESET -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
 </div>
 
 <?php html_page_bottom1( __FILE__ ) ?>
diff -rNu mantis.orig/manage_proj_mail_delete.php mantis/manage_proj_mail_delete.php
--- mantis.orig/manage_proj_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis/manage_proj_mail_delete.php	Mon Aug  9 21:25:02 2004
@@ -0,0 +1,45 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+?>
+<?php
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path.'mail_api.php' );
+?>
+<?php
+	$f_project_id	= gpc_get_int( 'project_id' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_delete( $f_project_id );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+?>
+<?php
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -rNu mantis.orig/manage_proj_mail_update.php mantis/manage_proj_mail_update.php
--- mantis.orig/manage_proj_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis/manage_proj_mail_update.php	Mon Aug  9 21:35:44 2004
@@ -0,0 +1,60 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+?>
+<?php
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path.'mail_api.php' );
+?>
+<?php
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+	}
+
+	mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+?>
+<?php
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -rNu mantis.orig/sql/bug_report_mail.sql mantis/sql/bug_report_mail.sql
--- mantis.orig/sql/bug_report_mail.sql	Thu Jan  1 01:00:00 1970
+++ mantis/sql/bug_report_mail.sql	Fri Aug  6 15:14:24 2004
@@ -0,0 +1,5 @@
+
+ALTER TABLE `mantis_project_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ;
diff -rNu mantis.orig/sql/db_generate.sql mantis/sql/db_generate.sql
--- mantis.orig/sql/db_generate.sql	Fri Feb  6 20:44:24 2004
+++ mantis/sql/db_generate.sql	Mon Aug  9 18:16:44 2004
@@ -306,6 +306,9 @@
   access_min int(2) NOT NULL default '10',
   file_path varchar(250) NOT NULL default '',
   description text NOT NULL,
+  pop3_host varchar(255) default NULL,
+  pop3_user varchar(255) default NULL,
+  pop3_pass varchar(255) default NULL,
   PRIMARY KEY  (id),
   UNIQUE KEY name (name),
   KEY id (id)
mantis-working.patch (23,038 bytes)   
mantis-0.19.0.patch (42,781 bytes)   
diff -Nru mantis-0.19.0.orig/bug_report_mail.php mantis-0.19.0/bug_report_mail.php
--- mantis-0.19.0.orig/bug_report_mail.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/bug_report_mail.php	Wed Sep 15 17:29:41 2004
@@ -0,0 +1,33 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	# This page receives an E-Mail via POP3 and generates an Report
+	header("Content-type: text/plain");
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'string_api.php' );
+	require_once( $t_core_path . 'bug_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$t_projects = mail_project_get_all_rows();
+	
+	foreach ($t_projects as $t_project) {
+		$t_mails = mail_get_all_mails($t_project);
+		foreach ($t_mails as $t_mail)
+		{
+			mail_add_bug($t_mail, $t_project);
+		}
+	}
+?>
+
diff -Nru mantis-0.19.0.orig/config_defaults_inc.php mantis-0.19.0/config_defaults_inc.php
--- mantis-0.19.0.orig/config_defaults_inc.php	Sun Sep 12 14:12:30 2004
+++ mantis-0.19.0/config_defaults_inc.php	Wed Sep 15 17:27:55 2004
@@ -1335,4 +1335,20 @@
 	# Enable support for bug relationships where a bug can be a related, dependent on, or duplicate of another.
 	# See relationship_api.php for more details.
 	$g_enable_relationship = ON;
+
+	######################
+	# Mail Reporting
+	######################
+
+	# --- mail reporting settings -----
+	# This tells Mantis to report all the Mail with only one account
+	$g_mail_use_reporter    = ON;
+
+	# The account's name for mail reporting
+	# Also used for fallback if a user is not found in database
+	$g_mail_reporter        = 'Mail';
+
+	# Signup new users automatically (possible security risk!)
+	# Default is OFF, ignored if mail_use_reporter is ON
+	$g_mail_auto_signup	= OFF;
 ?>
diff -Nru mantis-0.19.0.orig/config_inc.php mantis-0.19.0/config_inc.php
--- mantis-0.19.0.orig/config_inc.php	Sun Sep 12 16:03:14 2004
+++ mantis-0.19.0/config_inc.php	Wed Sep 15 17:28:04 2004
@@ -49,4 +49,17 @@
 	# The default value is ON but you must make sure file uploading is enabled
 	#  in PHP as well.  You may need to add "file_uploads = TRUE" to your php.ini.
 	$g_allow_file_upload	= ON;
+
+	# --- mail reporting settings -----
+	# This tells Mantis to report all the Mail with only one account
+	$g_mail_use_reporter    = OFF;
+
+	# The account's name for mail reporting
+	# Also used for fallback if a user is not found in database
+	$g_mail_reporter        = 'Mail';
+
+	# Signup new users automatically (possible security risk!)
+	# Default is OFF, ignored if mail_use_reporter is ON
+	$g_mail_auto_signup	= ON;
+
 ?>
diff -Nru mantis-0.19.0.orig/core/mail_api.php mantis-0.19.0/core/mail_api.php
--- mantis-0.19.0.orig/core/mail_api.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/core/mail_api.php	Wed Sep 15 17:20:27 2004
@@ -0,0 +1,222 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
+	
+	require_once( $t_core_dir . 'bug_api.php' );
+	require_once( $t_core_dir . 'bugnote_api.php' );
+	require_once( $t_core_dir . 'user_api.php' );
+	require_once( $t_core_dir . 'project_api.php' );
+
+	# This page receives an E-Mail via POP3 and generates an Report
+
+	require_once( 'Net/POP3.php' );
+    
+	# --------------------
+	# Update the mail account data
+	function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_pop3_host	= db_prepare_string( $p_pop3_host );
+		$v_pop3_user	= db_prepare_string( $p_pop3_user );
+		$v_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+			 	SET pop3_host='$v_pop3_host',
+				pop3_user='$v_pop3_user',
+				pop3_pass='$v_pop3_pass'
+				WHERE id='$v_project_id'";
+		db_query( $query );
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data
+	function mail_delete( $p_project_id ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Return all versions for the specified project
+	function mail_get_account_data( $p_project_id ) {
+		$v_project_id = db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass
+				FROM $t_project_table 
+				WHERE id='$v_project_id'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# return all projects with valid data for mail access
+	#  return an empty array if there are no such projects
+	function mail_project_get_all_rows() {
+		$v_projects = array();
+		$t_projects = project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_host']) {
+				array_push($v_projects, $t_project);
+			}
+		}
+
+		return $v_projects;
+	}
+
+	# --------------------
+	# return all mails for a project
+	#  return an empty array if there are no new mails
+	function mail_get_all_mails( $p_project ) {
+		$v_mails = array();
+		$t_pop3 = &new Net_POP3();
+		$t_pop3_host = $p_project['pop3_host'];
+		$t_pop3_user = $p_project['pop3_user'];
+		$t_pop3_password = $p_project['pop3_pass'];
+
+		$t_pop3->connect($t_pop3_host, 110);
+		$t_pop3->login($t_pop3_user, $t_pop3_password);
+
+		for ($i = 1; $i <= $t_pop3->numMsg(); $i++) {
+			$t_mail = $t_pop3->getParsedHeaders($i);
+			$t_mail['X-Mantis-Body'] = $t_pop3->getBody($i);
+			$t_mail['X-Mantis-Complete'] = $t_pop3->getMsg($i);
+			array_push($v_mails, $t_mail);
+			#$t_pop3->deleteMsg($i);
+		}
+
+		$t_pop3->disconnect();
+		return $v_mails;
+	}
+
+	# --------------------
+	# return the mailadress from the mail's 'From'
+	function mail_parse_address ( $p_mailaddress ) {
+		if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) {
+			$c_mailaddress = $matches[1];
+		}
+
+		return $c_mailaddress;
+	}
+
+	# --------------------
+	# return the a valid username from an email address
+	function mail_user_name_from_address ( $p_mailaddress ) {
+
+		return preg_replace("/[@\.-]/", '_', $p_mailaddress);
+	}
+
+	# --------------------
+	# return true if there is a valid mantis bug referernce in subject
+	function mail_is_a_bugnote ($p_mail_subject) {
+		return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_mail_subject);
+	}
+
+	# --------------------
+	# return the bug's id from the subject
+	function mail_get_bug_id_from_subject ( $p_mail_subject) {
+		preg_match("/\[([A-Za-z0-9-_\.]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches);
+
+		return $v_matches[2];
+	}
+
+	# --------------------
+	# return the user id for the mail reporting user
+	function mail_get_user ($p_mailaddress) {
+		$t_mail_use_reporter	= config_get( 'mail_use_reporter' );
+		$t_mail_auto_signup	= config_get( 'mail_auto_signup' );
+		$t_mail_reporter	= config_get( 'mail_reporter' );
+		
+		$c_mailaddress = mail_parse_address( $p_mailaddress );
+
+		if ( $t_mail_use_reporter ) {
+			// Always report as mail_reporter
+			$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+		} else {
+			// Try to get the reporting users id
+			$t_reporter_id = user_get_id_by_mail ( $c_mailaddress );
+			if ( ! $t_reporter_id && $t_mail_auto_signup ) {
+				// So, we've to sign up a new user...
+				$t_user_name = mail_user_name_from_address ( $c_mailaddress );
+				user_signup($t_user_name, $c_mailaddress);
+				$t_reporter_id = user_get_id_by_name($t_user_name);
+			} elseif ( ! $t_reporter_id ) {
+				// Fall back to the default mail_reporter
+				$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+			}
+		}
+
+		return $t_reporter_id;
+	}
+    
+	# --------------------
+	# Adds a bug which is reported via email
+	# Taken from bug_report.php and 
+	function mail_add_bug( $p_mail, $p_project ) {
+		$t_bug_data = new BugData;
+		$t_bug_data->build			= gpc_get_string( 'build', '' );
+		$t_bug_data->platform			= gpc_get_string( 'platform', '' );
+		$t_bug_data->os				= gpc_get_string( 'os', '' );
+		$t_bug_data->os_build			= gpc_get_string( 'os_build', '' );
+		$t_bug_data->version			= gpc_get_string( 'product_version', '' );
+		$t_bug_data->profile_id			= gpc_get_int( 'profile_id', 0 );
+		$t_bug_data->handler_id			= gpc_get_int( 'handler_id', 0 );
+		$t_bug_data->view_state			= gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
+
+		$t_bug_data->category			= gpc_get_string( 'category', '' );
+		$t_bug_data->reproducibility		= 10;
+		$t_bug_data->severity			= 50;
+		$t_bug_data->priority			= gpc_get_int( 'priority', NORMAL );
+		$t_bug_data->summary			= $p_mail['Subject'];
+		$t_bug_data->description		= $p_mail['X-Mantis-Body'];
+		$t_bug_data->steps_to_reproduce		= gpc_get_string( 'steps_to_reproduce', '' );
+		$t_bug_data->additional_information	= $p_mail['X-Mantis-Complete'];
+
+		$t_bug_data->project_id			= $p_project['id'];
+
+		$t_bug_data->reporter_id		= mail_get_user( $p_mail['From'] );
+
+		if (mail_is_a_bugnote($p_mail['Subject']))
+		{
+			# Add a bug note
+			$t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] );
+			if ( ! bug_is_readonly( $t_bug_id ) ) {
+				bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] );
+				email_bugnote_add ( $t_bug_id );
+			}
+		}
+		else
+		{
+			# Create the bug
+			#$t_bug_id = bug_create( $t_bug_data );
+			#email_new_bug( $t_bug_id );
+		}
+
+	}
+
+?>
diff -Nru mantis-0.19.0.orig/core/user_api.php mantis-0.19.0/core/user_api.php
--- mantis-0.19.0.orig/core/user_api.php	Mon Aug 23 16:13:34 2004
+++ mantis-0.19.0/core/user_api.php	Wed Sep 15 17:20:36 2004
@@ -478,6 +478,27 @@
 	}
 
 	# --------------------
+	# get a user id from an mail address
+	#  return false if the mail address does not exist
+	function user_get_id_by_mail( $p_mailaddress ) {
+		
+		$c_mailaddress = db_prepare_string( $p_mailaddress );
+
+		$t_user_table = config_get( 'mantis_user_table' );
+
+		$query = "SELECT id
+				  FROM $t_user_table
+				  WHERE email='$c_mailaddress'";
+		$result = db_query( $query );
+
+		if ( 0 == db_num_rows( $result ) ) {
+			return false;
+		} else {
+			return db_result( $result );
+		}
+	}
+
+	# --------------------
 	# return all data associated with a particular user name
 	#  return false if the username does not exist
 	function user_get_row_by_name( $p_username ) {
diff -Nru mantis-0.19.0.orig/doc/README.bug_report_mail mantis-0.19.0/doc/README.bug_report_mail
--- mantis-0.19.0.orig/doc/README.bug_report_mail	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/doc/README.bug_report_mail	Wed Sep 15 17:32:01 2004
@@ -0,0 +1,53 @@
+The current version of bug_report_mail only support plain text e-mails
+and POP3 Mailaccounts with PEAR's Net_POP3 packge.
+
+bug_report_mail is able to recognize if mail is a reply to an already opened
+bug and adds the content as a bugnote.
+
+If you are alway running Mantis you have to alter your projects table
+with the sql/bug_report_mail.sql script.
+If not, you can create the database tables in the way described in
+the doc/INSTALL file.
+
+This patch changes the following files:
+    core/user_api.php
+    manage_proj_edit_page.php
+    config_default_inc.php
+These files are new:
+    core/mail_api.php
+    sql/bug_report_mail.sql
+    bug_report_mail.php
+    manage_proj_mail_delete.php
+    manage_proj_mail_update.php
+
+After installing this patch, you can add a POP3 server's hostname
+and authentication data for each of your projects with the project edit form.
+
+There are two ways to receive mail with bug_report_mail:
+The secure (and default) way is to use a standard reporting user:
+You have to create a reporter account, for example 'Mail'.
+The name for this reporter account you have to write in your config_inc.php file:
+	$g_mail_reporter = "Mail";
+and then, bug_report_mail must be informed to behave like this:
+    $g_mail_use_reporter = ON;
+
+The other way is to signup new user accounts automatically.
+For using this, you have to change this
+    $g_mail_auto_signup     = OFF;
+from OFF to ON.
+Now, bug_report_mail will look for an user named like the mail's sender
+or an user which mail adress is identical.
+If no user is found, then a new account will be created.
+The new user's name will be the mail address.
+
+This could be used for attacks, but there is no other way in the moment.
+
+After this, bug_report_mail can be used via cron like this:
+
+*/5 *   *   *   * lynx --dump http://mantis.homepage.com/bug_report_mail.php
+
+This line uses lynx to fetch bug reports from via POP3 every 5 minutes. 
+
+This addon is distributed under the same condition as Mantis itself.
+
+Gerrit Beine, August 2004
diff -Nru mantis-0.19.0.orig/doc/README.bug_report_mail~ mantis-0.19.0/doc/README.bug_report_mail~
--- mantis-0.19.0.orig/doc/README.bug_report_mail~	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/doc/README.bug_report_mail~	Mon Aug  9 23:26:21 2004
@@ -0,0 +1,54 @@
+The current version of bug_report_mail only support plain text e-mails
+and POP3 Mailaccounts with PEAR's Net_POP3 packge.
+
+bug_report_mail is able to recognize if mail is a reply to an already opened
+bug and adds the content as a bugnote.
+
+If you are alway running Mantis you have to alter you projects table
+with the sql/bug_report_mail.sql script.
+If not, you can create the database tables in the way described in
+the doc/INSTALL file.
+
+This patch changes the following files:
+    core/user_api.php
+    manage_proj_edit_page.php
+    config_inc.php.sample
+These files are new:
+    core/mail_api.php
+    sql/bug_report_mail.php
+    bug_report_mail.php
+    manage_proj_mail_delete.php
+    manage_proj_mail_update.php
+
+After installing this patch, you can add a POP3 server's hostname
+and authentication data for each of your projects with the
+project edit form.
+
+There are two ways to receive mail with bug_report_mail:
+The secure way is to use a standard reporting user:
+You have to create a reporter account, for example 'Mail'.
+The name for this reporter account you have to write in your config_inc.php file:
+	$g_mail_reporter = "Mail";
+and then, bug_report_mail must be informed to behave like this:
+    $g_mail_use_reporter = ON;
+
+The other way is to signup new user accounts automatically.
+For using this, you have to change this
+    $g_mail_auto_signup     = OFF;
+from OFF to ON.
+Now, bug_report_mail will look for an user named like the mail's sender
+or an user which mail adress is identical.
+If no user is found, then a new account will be created.
+The new user's name will be the mail address.
+
+This could be used for attacks, but there is no other way in the moment.
+
+After this, bug_report_mail can be used via cron like this:
+
+*/5 *   *   *   * lynx --dump http://mantis.homepage.com/bug_report_mail.php
+
+This line uses lynx to fetch bug reports from via POP3 every 5 minutes. 
+
+This addon is distributed under the same condition as Mantis itself.
+
+Gerrit Beine, August 2004
diff -Nru mantis-0.19.0.orig/manage_proj_edit_page.php mantis-0.19.0/manage_proj_edit_page.php
--- mantis-0.19.0.orig/manage_proj_edit_page.php	Thu Jul 15 00:16:34 2004
+++ mantis-0.19.0/manage_proj_edit_page.php	Wed Sep 15 17:30:05 2004
@@ -18,6 +18,7 @@
 	require_once( $t_core_path . 'version_api.php' );
 	require_once( $t_core_path . 'custom_field_api.php' );
 	require_once( $t_core_path . 'icon_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
 ?>
 <?php
 	$f_project_id = gpc_get_int( 'project_id' );
@@ -25,6 +26,8 @@
 	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
 
 	$row = project_get_row( $f_project_id );
+	$mail = mail_get_account_data( $f_project_id );
+
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -534,4 +537,55 @@
 	</table>
 </div>
 
+
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nru mantis-0.19.0.orig/manage_proj_edit_page.php~ mantis-0.19.0/manage_proj_edit_page.php~
--- mantis-0.19.0.orig/manage_proj_edit_page.php~	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/manage_proj_edit_page.php~	Wed Sep 15 16:40:53 2004
@@ -0,0 +1,591 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id: manage_proj_edit_page.php,v 1.79 2004/07/14 22:16:34 vboctor Exp $
+	# --------------------------------------------------------
+?>
+<?php
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'category_api.php' );
+	require_once( $t_core_path . 'version_api.php' );
+	require_once( $t_core_path . 'custom_field_api.php' );
+	require_once( $t_core_path . 'icon_api.php' );
+	require_once( $t_core_path.'mail_api.php' );
+?>
+<?php
+	$f_project_id = gpc_get_int( 'project_id' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	$row = project_get_row( $f_project_id );
+	$mail = mail_get_account_data( $f_project_id );
+
+?>
+<?php html_page_top1() ?>
+<?php html_page_top2() ?>
+
+<?php print_manage_menu( 'manage_proj_edit_page.php' ) ?>
+
+<br />
+
+
+<!-- PROJECT PROPERTIES -->
+<div align="center">
+<form method="post" action="manage_proj_update.php">
+<table class="width75" cellspacing="1">
+
+<!-- Title -->
+<tr>
+	<td class="form-title" colspan="2">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<?php echo lang_get( 'edit_project_title' ) ?>
+	</td>
+</tr>
+
+<!-- Name -->
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category" width="25%">
+		<?php echo lang_get( 'project_name' ) ?>
+	</td>
+	<td width="75%">
+		<input type="text" name="name" size="50" maxlength="128" value="<?php echo string_attribute( $row['name'] ) ?>" />
+	</td>
+</tr>
+
+<!-- Status -->
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'status' ) ?>
+	</td>
+	<td>
+		<select name="status">
+		<?php print_enum_string_option_list( 'project_status', $row['status'] ) ?>
+		</select>
+	</td>
+</tr>
+
+<!-- Enabled -->
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'enabled' ) ?>
+	</td>
+	<td>
+		<input type="checkbox" name="enabled" <?php check_checked( $row['enabled'], ON ); ?> />
+	</td>
+</tr>
+
+<!-- View Status (public/private) -->
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'view_status' ) ?>
+	</td>
+	<td>
+		<select name="view_state">
+			<?php print_enum_string_option_list( 'view_state', $row['view_state']) ?>
+		</select>
+	</td>
+</tr>
+
+<!-- File upload path (if uploading is enabled) -->
+<?php if ( file_is_uploading_enabled() ) { ?>
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'upload_file_path' ) ?>
+	</td>
+	<td>
+		<input type="text" name="file_path" size="50" maxlength="250" value="<?php echo string_attribute( $row['file_path'] ) ?>" />
+	</td>
+</tr>
+<?php } ?>
+
+<!-- Description -->
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'description' ) ?>
+	</td>
+	<td>
+		<textarea name="description" cols="60" rows="5" wrap="virtual"><?php echo string_textarea( $row['description'] ) ?></textarea>
+	</td>
+</tr>
+
+<!-- Submit Button -->
+<tr>
+	<td>&nbsp;</td>
+	<td>
+		<input type="submit" class="button" value="<?php echo lang_get( 'update_project_button' ) ?>" />
+	</td>
+</tr>
+</table>
+</form>
+</div>
+
+<br />
+
+<!-- PROJECT DELETE -->
+<?php
+# You must have global permissions to delete projects
+if ( access_has_global_level ( config_get( 'delete_project_threshold' ) ) ) { ?>
+<div class="border-center">
+	<form method="post" action="manage_proj_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="submit" class="button" value="<?php echo lang_get( 'delete_project_button' ) ?>" />
+	</form>
+</div>
+<?php } ?>
+
+<br />
+
+<?php
+	# reset the class counter
+	helper_alternate_class( 0 );
+?>
+
+<!-- PROJECT CATEGORIES -->
+<div align="center">
+<table class="width75" cellspacing="1">
+
+<!-- Title -->
+<tr>
+	<td class="form-title" colspan="3">
+		<?php echo lang_get( 'categories' ) ?>
+	</td>
+</tr>
+<?php
+	$t_categories = category_get_all_rows( $f_project_id );
+
+	if ( count( $t_categories ) > 0 ) {
+?>
+		<tr class="row-category">
+			<td>
+				<?php echo lang_get( 'category' ) ?>
+			</td>
+			<td>
+				<?php echo lang_get( 'assign_to' ) ?>
+			</td>
+			<td class="center">
+				<?php echo lang_get( 'actions' ) ?>
+			</td>
+		</tr>
+<?php
+	}
+	
+	foreach ( $t_categories as $t_category ) {
+		$t_name = $t_category['category'];
+
+		if ( NO_USER != $t_category['user_id'] && user_exists( $t_category['user_id'] )) {
+			$t_user_name = user_get_name( $t_category['user_id'] );
+		} else {
+			$t_user_name = '';
+		}
+?>
+<!-- Repeated Info Row -->
+		<tr <?php echo helper_alternate_class() ?>>
+			<td>
+				<?php echo string_display( $t_name ) ?>
+			</td>
+			<td>
+				<?php echo $t_user_name ?>
+			</td>
+			<td class="center">
+				<?php
+					$t_name = urlencode( $t_name );
+
+					print_bracket_link( 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&amp;category=' . $t_name, lang_get( 'edit_link' ) );
+					echo ' ';
+					print_bracket_link( 'manage_proj_cat_delete.php?project_id=' . $f_project_id . '&amp;category=' . $t_name, lang_get( 'delete_link' ) );
+				?>
+			</td>
+		</tr>
+<?php
+	} # end for loop
+?>
+
+<!-- Add Category Form -->
+<tr>
+	<td class="left" colspan="3">
+		<form method="post" action="manage_proj_cat_add.php">
+			<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+			<input type="text" name="category" size="32" maxlength="64" />
+			<input type="submit" class="button" value="<?php echo lang_get( 'add_category_button' ) ?>" />
+		</form>
+	</td>
+</tr>
+
+<!-- Copy Categories Form -->
+<tr>
+	<td class="left" colspan="3">
+		<form method="post" action="manage_proj_cat_copy.php">
+			<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+			<select name="other_project_id">
+				<?php print_project_option_list( null, false ) ?>
+			</select>
+			<input type="submit" name="copy_from" class="button" value="<?php echo lang_get( 'copy_categories_from' ) ?>" />
+			<input type="submit" name="copy_to" class="button" value="<?php echo lang_get( 'copy_categories_to' ) ?>" />
+		</form>
+	</td>
+</tr>
+</table>
+
+<br />
+
+<?php
+	# reset the class counter
+	helper_alternate_class( 0 );
+?>
+
+<!-- PROJECT VERSIONS -->
+<table class="width75" cellspacing="1">
+
+<!-- Title -->
+<tr>
+	<td class="form-title" colspan="3">
+		<?php echo lang_get( 'versions' ) ?>
+	</td>
+</tr>
+<?php
+	$t_versions = version_get_all_rows( $f_project_id );
+
+	if ( count( $t_versions ) > 0 ) {
+?>
+		<tr class="row-category">
+			<td>
+				<?php echo lang_get( 'version' ) ?>
+			</td>
+			<td class="center">
+				<?php echo lang_get( 'timestamp' ) ?>
+			</td>
+			<td class="center">
+				<?php echo lang_get( 'actions' ) ?>
+			</td>
+		</tr>
+<?php
+	}
+
+	foreach ( $t_versions as $t_version ) {
+		$t_name = $t_version['version'];
+		$t_date_order = $t_version['date_order'];
+		$t_date_formatted = string_format_complete_date( $t_version['date_order'] );
+?>
+<!-- Repeated Info Rows -->
+		<tr <?php echo helper_alternate_class() ?>>
+			<td>
+				<?php echo string_display( $t_name ) ?>
+			</td>
+			<td class="center">
+				<?php echo $t_date_formatted ?>
+			</td>
+			<td class="center">
+				<?php
+					$t_version_id = version_get_id( $t_name, $f_project_id );
+
+					print_bracket_link( 'manage_proj_ver_edit_page.php?version_id=' . $t_version_id, lang_get( 'edit_link' ) );
+					echo '&nbsp;';
+					print_bracket_link( 'manage_proj_ver_delete.php?version_id=' . $t_version_id, lang_get( 'delete_link' ) );
+				?>
+			</td>
+		</tr>
+<?php
+	} # end for loop
+?>
+
+<!-- Version Add Form -->
+<tr>
+	<td class="left" colspan="3">
+		<form method="post" action="manage_proj_ver_add.php">
+			<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+			<input type="text" name="version" size="32" maxlength="64" />
+			<input type="submit" class="button" value="<?php echo lang_get( 'add_version_button' ) ?>" />
+		</form>
+	</td>
+</tr>
+</table>
+</div>
+
+
+<?php
+	# reset the class counter
+	helper_alternate_class( 0 );
+?>
+
+<!-- PROJECT CUSTOM FIELD -->
+<?php
+# You need either global permissions or project-specific permissions to link
+#  custom fields
+if ( access_has_project_level( config_get( 'custom_field_link_threshold' ), $f_project_id ) &&
+	( count( custom_field_get_ids() ) > 0 ) ) {
+?>
+	<br />
+	<div align="center">
+	<table class="width75" cellspacing="1">
+	<tr>
+		<td class="form-title" colspan="3">
+			<?php echo lang_get( 'custom_fields_setup' ) ?>
+		</td>
+	</tr>
+	<?php
+		$t_custom_fields = custom_field_get_linked_ids( $f_project_id );
+
+		if ( count( $t_custom_fields ) > 0 ) {
+	?>
+			<tr class="row-category">
+				<td width="50%">
+					<?php echo lang_get( 'custom_field' ) ?>
+				</td>
+				<td width="25%">
+					<?php echo lang_get( 'custom_field_sequence' ) ?>
+				</td>
+				<td class="center" width="25%">
+					<?php echo lang_get( 'actions' ); ?>
+				</td>
+			</tr>
+	<?php
+		}
+
+		foreach( $t_custom_fields as $t_field_id ) {
+			$t_desc = custom_field_get_definition( $t_field_id );
+	?>
+			<tr <?php echo helper_alternate_class() ?>>
+				<td>
+					<?php echo $t_desc['name'] ?>
+				</td>
+				<td>
+<form method="post" action="manage_proj_custom_field_update.php">
+	<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+	<input type="hidden" name="field_id" value="<?php echo $t_field_id ?>" />
+	<input type="text" name="sequence" value="<?php echo custom_field_get_sequence( $t_field_id, $f_project_id ) ?>" size="2" />
+	<input type="submit" class="button" value="<?php echo lang_get( 'update' ) ?>" />
+</form>
+				</td>
+				<td class="center">
+				<?php
+					# You need global permissions to edit custom field defs
+					print_bracket_link( "manage_proj_custom_field_remove.php?field_id=$t_field_id&amp;project_id=$f_project_id", lang_get( 'remove_link' ) );
+				?>
+				</td>
+			</tr>
+	<?php
+		} # end for loop
+	?>
+	<tr>
+		<td class="left" colspan="3">
+			<form method="post" action="manage_proj_custom_field_add_existing.php">
+			<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+			<select name="field_id">
+				<?php
+					$t_custom_fields = custom_field_get_ids();
+
+					foreach( $t_custom_fields as $t_field_id )
+					{
+						if( !custom_field_is_linked( $t_field_id, $f_project_id ) ) {
+							$t_desc = custom_field_get_definition( $t_field_id );
+							echo "<option value=\"$t_field_id\">" . string_attribute( $t_desc['name'] ) . '</option>' ;
+						}
+					}
+				?>
+			</select>
+			<input type="submit" class="button" value="<?php echo lang_get( 'add_existing_custom_field' ) ?>" />
+			</form>
+		</td>
+	</tr>
+	</table>
+	</div>
+<?php
+}
+?>
+
+
+<!-- PROJECT VIEW STATUS -->
+<br />
+<div align="center">
+	<table class="width75" cellspacing="1">
+		<tr>
+			<td class="center">
+			<?php
+				if ( VS_PUBLIC == project_get_field( $f_project_id, 'view_state' ) ) {
+					echo lang_get( 'public_project_msg' );
+				} else {
+					echo lang_get( 'private_project_msg' );
+				}
+			?>
+			</td>
+		</tr>
+	</table>
+</div>
+
+
+<!-- USER MANAGEMENT (ADD) -->
+<?php
+# We want to allow people with global permissions and people with high enough
+#  permissions on the project we are editing
+if ( access_has_project_level( config_get( 'project_user_threshold' ), $f_project_id ) ) {
+?>
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_user_add.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="5">
+					<?php echo lang_get( 'add_user_title' ) ?>
+				</td>
+			</tr>
+			<tr class="row-1" valign="top">
+				<td class="category">
+					<?php echo lang_get( 'username' ) ?>
+				</td>
+				<td class="category">
+					<?php echo lang_get( 'access_level' ) ?>
+				</td>
+				<td class="category"> &nbsp; </td>
+			</tr>
+			<tr class="row-1" valign="top">
+				<td>
+					<select name="user_id[]" multiple="multiple" size="10">
+						<?php print_project_user_list_option_list( $f_project_id ) ?>
+					</select>
+				</td>
+				<td>
+					<select name="access_level">
+						<?php # No administrator choice ?>
+						<?php print_project_access_levels_option_list( config_get( 'default_new_account_access_level' ) ) ?>
+					</select>
+				</td>
+				<td>
+					<input type="submit" class="button" value="<?php echo lang_get( 'add_user_button' ) ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<?php
+}
+?>
+
+
+<!-- LIST OF USERS -->
+<br />
+<div align="center">
+	<table class="width75" cellspacing="1">
+		<tr>
+			<td class="form-title" colspan="4">
+				<?php echo lang_get( 'manage_accounts_title' ) ?>
+			</td>
+		</tr>
+		<tr class="row-category">
+			<td>
+				<?php echo lang_get( 'username' ) ?>
+			</td>
+			<td>
+				<?php echo lang_get( 'email' ) ?>
+			</td>
+			<td>
+				<?php echo lang_get( 'access_level' ) ?>
+			</td>
+			<td class="center">
+				<?php echo lang_get( 'actions' ) ?>
+			</td>
+		</tr>
+<?php
+	$t_users = project_get_all_user_rows( $f_project_id );
+
+	# reset the class counter
+	helper_alternate_class( 0 );
+
+	foreach ( $t_users as $t_user ) {
+?>
+		<tr <?php echo helper_alternate_class() ?>>
+			<td>
+				<?php
+					echo $t_user['username'];
+					if ( isset( $t_user['realname'] ) && $t_user['realname'] > "" ) {
+						echo " (" . $t_user['realname'] . ")";
+					}
+				?>
+			</td>
+			<td>
+			<?php 
+				$t_email = user_get_email( $t_user['id'] );
+				print_email_link( $t_email, $t_email );
+			?>
+			</td>
+			<td>
+				<?php echo get_enum_element( 'access_levels', $t_user['access_level'] ) ?>
+			</td>
+			<td class="center">
+			<?php
+				# You need global or project-specific permissions to remove users
+				#  from this project
+				if ( access_has_project_level( config_get( 'project_user_threshold' ), $f_project_id ) ) {
+					if ( project_includes_user( $f_project_id, $t_user['id'] )  ) {
+						print_bracket_link( 'manage_proj_user_remove.php?project_id=' . $f_project_id . '&amp;user_id=' . $t_user['id'], lang_get( 'remove_link' ) );
+					}
+				}
+			?>
+			</td>
+		</tr>
+<?php
+	}  # end for
+?>
+	</table>
+</div>
+
+
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nru mantis-0.19.0.orig/manage_proj_mail_delete.php mantis-0.19.0/manage_proj_mail_delete.php
--- mantis-0.19.0.orig/manage_proj_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/manage_proj_mail_delete.php	Wed Sep 15 17:29:59 2004
@@ -0,0 +1,42 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_delete( $f_project_id );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nru mantis-0.19.0.orig/manage_proj_mail_delete.php~ mantis-0.19.0/manage_proj_mail_delete.php~
--- mantis-0.19.0.orig/manage_proj_mail_delete.php~	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/manage_proj_mail_delete.php~	Wed Sep 15 16:35:39 2004
@@ -0,0 +1,42 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path.'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_delete( $f_project_id );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nru mantis-0.19.0.orig/manage_proj_mail_update.php mantis-0.19.0/manage_proj_mail_update.php
--- mantis-0.19.0.orig/manage_proj_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/manage_proj_mail_update.php	Wed Sep 15 17:29:54 2004
@@ -0,0 +1,58 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+
+	echo $f_project_id;
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+	}
+
+	mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nru mantis-0.19.0.orig/manage_proj_mail_update.php~ mantis-0.19.0/manage_proj_mail_update.php~
--- mantis-0.19.0.orig/manage_proj_mail_update.php~	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/manage_proj_mail_update.php~	Wed Sep 15 16:37:50 2004
@@ -0,0 +1,58 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path.'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+
+	echo $f_project_id;
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+	}
+
+	mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nru mantis-0.19.0.orig/sql/bug_report_mail.sql mantis-0.19.0/sql/bug_report_mail.sql
--- mantis-0.19.0.orig/sql/bug_report_mail.sql	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/sql/bug_report_mail.sql	Wed Sep 15 17:24:06 2004
@@ -0,0 +1,4 @@
+ALTER TABLE `mantis_project_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ;
diff -Nru mantis-0.19.0.orig/sql/db_generate.sql mantis-0.19.0/sql/db_generate.sql
--- mantis-0.19.0.orig/sql/db_generate.sql	Sun Sep 12 14:19:24 2004
+++ mantis-0.19.0/sql/db_generate.sql	Wed Sep 15 17:24:02 2004
@@ -377,6 +377,9 @@
   access_min int(2) NOT NULL default '10',
   file_path varchar(250) NOT NULL default '',
   description text NOT NULL,
+  pop3_host varchar( 255 ) default NULL ,
+  pop3_user varchar( 255 ) default NULL ,
+  pop3_pass varchar( 255 ) default NULL ,
   PRIMARY KEY  (id),
   UNIQUE KEY name (name),
   KEY id (id)
mantis-0.19.0.patch (42,781 bytes)   
mantis-0.19.0.patch (34,447 bytes)   
diff -Nru mantis-0.19.0.orig/bug_report_mail.php mantis-0.19.0/bug_report_mail.php
--- mantis-0.19.0.orig/bug_report_mail.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/bug_report_mail.php	Wed Sep 15 18:59:59 2004
@@ -0,0 +1,33 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	# This page receives an E-Mail via POP3 and generates an Report
+	header("Content-type: text/plain");
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'string_api.php' );
+	require_once( $t_core_path . 'bug_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$t_mailaccounts = mail_get_accounts();
+	
+	foreach ($t_mailaccounts as $t_mailaccount) {
+		$t_mails = mail_get_all_mails($t_mailaccount);
+		foreach ($t_mails as $t_mail)
+		{
+			mail_add_bug($t_mail, $t_mailaccount);
+		}
+	}
+?>
+
diff -Nru mantis-0.19.0.orig/config_defaults_inc.php mantis-0.19.0/config_defaults_inc.php
--- mantis-0.19.0.orig/config_defaults_inc.php	Sun Sep 12 14:12:30 2004
+++ mantis-0.19.0/config_defaults_inc.php	Wed Sep 15 17:27:55 2004
@@ -1335,4 +1335,20 @@
 	# Enable support for bug relationships where a bug can be a related, dependent on, or duplicate of another.
 	# See relationship_api.php for more details.
 	$g_enable_relationship = ON;
+
+	######################
+	# Mail Reporting
+	######################
+
+	# --- mail reporting settings -----
+	# This tells Mantis to report all the Mail with only one account
+	$g_mail_use_reporter    = ON;
+
+	# The account's name for mail reporting
+	# Also used for fallback if a user is not found in database
+	$g_mail_reporter        = 'Mail';
+
+	# Signup new users automatically (possible security risk!)
+	# Default is OFF, ignored if mail_use_reporter is ON
+	$g_mail_auto_signup	= OFF;
 ?>
diff -Nru mantis-0.19.0.orig/config_inc.php mantis-0.19.0/config_inc.php
--- mantis-0.19.0.orig/config_inc.php	Sun Sep 12 16:03:14 2004
+++ mantis-0.19.0/config_inc.php	Wed Sep 15 17:28:04 2004
@@ -49,4 +49,17 @@
 	# The default value is ON but you must make sure file uploading is enabled
 	#  in PHP as well.  You may need to add "file_uploads = TRUE" to your php.ini.
 	$g_allow_file_upload	= ON;
+
+	# --- mail reporting settings -----
+	# This tells Mantis to report all the Mail with only one account
+	$g_mail_use_reporter    = OFF;
+
+	# The account's name for mail reporting
+	# Also used for fallback if a user is not found in database
+	$g_mail_reporter        = 'Mail';
+
+	# Signup new users automatically (possible security risk!)
+	# Default is OFF, ignored if mail_use_reporter is ON
+	$g_mail_auto_signup	= ON;
+
 ?>
diff -Nru mantis-0.19.0.orig/core/category_api.php mantis-0.19.0/core/category_api.php
--- mantis-0.19.0.orig/core/category_api.php	Thu Apr  8 20:04:52 2004
+++ mantis-0.19.0/core/category_api.php	Wed Sep 15 18:52:45 2004
@@ -206,7 +206,7 @@
 
 		$t_project_category_table = config_get( 'mantis_project_category_table' );
 
-		$query = "SELECT category, user_id
+		$query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass
 				FROM $t_project_category_table
 				WHERE project_id='$c_project_id'
 				ORDER BY category";
diff -Nru mantis-0.19.0.orig/core/mail_api.php mantis-0.19.0/core/mail_api.php
--- mantis-0.19.0.orig/core/mail_api.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/core/mail_api.php	Wed Sep 15 19:00:09 2004
@@ -0,0 +1,341 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
+	
+	require_once( $t_core_dir . 'bug_api.php' );
+	require_once( $t_core_dir . 'bugnote_api.php' );
+	require_once( $t_core_dir . 'user_api.php' );
+	require_once( $t_core_dir . 'project_api.php' );
+
+	# This page receives an E-Mail via POP3 and generates an Report
+
+	require_once( 'Net/POP3.php' );
+
+	# --------------------
+	# Return mail account data for the specified project
+	function mail_get_account_data( $p_project_id ) {
+		$v_project_id = db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories
+				FROM $t_project_table 
+				WHERE id='$v_project_id'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data
+	function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_pop3_host	= db_prepare_string( $p_pop3_host );
+		$v_pop3_user	= db_prepare_string( $p_pop3_user );
+		$v_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+			 	SET pop3_host='$v_pop3_host',
+				pop3_user='$v_pop3_user',
+				pop3_pass='$v_pop3_pass'
+				WHERE id='$v_project_id'";
+		db_query( $query );
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data
+	function mail_delete( $p_project_id ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Activate the Mail per Category feature for a project
+	function mail_categories( $p_project_id , $p_active ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		if ($p_active == 'On') {
+			$v_active = 1;
+		} else {
+			$v_active = 0;
+		}
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_categories='$v_active'
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Return mail account data for the specified project and category
+	function mail_category_get_account_data( $p_project_id, $p_category ) {
+		$c_project_id = db_prepare_int( $p_project_id );
+		$c_category	= db_prepare_string( $p_category );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass
+				FROM $t_project_category_table 
+				WHERE project_id='$c_project_id' AND category='$c_category'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data for a category
+	function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$c_project_id	= db_prepare_int( $p_project_id );
+		$c_category	= db_prepare_string( $p_category );
+		$c_pop3_host	= db_prepare_string( $p_pop3_host );
+		$c_pop3_user	= db_prepare_string( $p_pop3_user );
+		$c_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host='$c_pop3_host',
+				pop3_user='$c_pop3_user',
+				pop3_pass='$c_pop3_pass'
+				WHERE project_id='$c_project_id' AND category='$c_category'";
+		db_query( $query );
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data for a category
+	function mail_category_delete( $p_project_id, $p_category ) {
+		$c_project_id	= db_prepare_int( $p_project_id );
+		$c_category	= db_prepare_string( $p_category );
+		
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE project_id='$c_project_id' AND category='$c_category'";
+
+		db_query( $query );
+		return true;
+	}
+
+	# --------------------
+	# return all mailaccounts
+	#  return an empty array if there are no
+	function mail_get_accounts() {
+		$v_accounts = array();
+		$t_projects = mail_project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_categories']) {
+				$v_categories = mail_categories_get_all_rows( $t_project['pop3_categories'] );
+				$v_accounts = array_merge($v_accounts, $v_categories);
+			} else {
+				array_push($v_accounts, $t_project);
+			}
+		}
+
+		return $v_accounts;
+	}
+
+	# --------------------
+	# return all projects with valid data for mail access
+	#  return an empty array if there are no such projects
+	function mail_project_get_all_rows() {
+		$v_projects = array();
+		$t_projects = project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_host'] || $t_project['pop3_categories']) {
+				array_push($v_projects, $t_project);
+			}
+		}
+
+		return $v_projects;
+	}
+
+	# --------------------
+	# return all projects with valid data for mail access
+	#  return an empty array if there are no such projects
+	function mail_categories_get_all_rows( $p_project_id ) {
+		$v_categories = array();
+		$t_categories = category_get_all_rows( $p_project_id );
+
+		foreach ($t_categories as $t_category) {
+			if ($t_category['pop3_host']) {
+				$t_category['id'] = $p_project_id;
+				array_push($v_categories, $t_category);
+			}
+		}
+
+		return $v_categories;
+	}
+
+	# --------------------
+	# return all mails for an account
+	#  return an empty array if there are no new mails
+	function mail_get_all_mails( $p_account ) {
+		$v_mails = array();
+		$t_pop3 = &new Net_POP3();
+		$t_pop3_host = $p_account['pop3_host'];
+		$t_pop3_user = $p_account['pop3_user'];
+		$t_pop3_password = $p_account['pop3_pass'];
+
+		$t_pop3->connect($t_pop3_host, 110);
+		$t_pop3->login($t_pop3_user, $t_pop3_password);
+
+		for ($i = 1; $i <= $t_pop3->numMsg(); $i++) {
+			$t_mail = $t_pop3->getParsedHeaders($i);
+			$t_mail['X-Mantis-Body'] = $t_pop3->getBody($i);
+			$t_mail['X-Mantis-Complete'] = $t_pop3->getMsg($i);
+			array_push($v_mails, $t_mail);
+			$t_pop3->deleteMsg($i);
+		}
+
+		$t_pop3->disconnect();
+		return $v_mails;
+	}
+
+	# --------------------
+	# return the mailadress from the mail's 'From'
+	function mail_parse_address ( $p_mailaddress ) {
+		if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) {
+			$c_mailaddress = $matches[1];
+		}
+
+		return $c_mailaddress;
+	}
+
+	# --------------------
+	# return the a valid username from an email address
+	function mail_user_name_from_address ( $p_mailaddress ) {
+
+		return preg_replace("/[@\.-]/", '_', $p_mailaddress);
+	}
+
+	# --------------------
+	# return true if there is a valid mantis bug referernce in subject
+	function mail_is_a_bugnote ($p_mail_subject) {
+		return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_mail_subject);
+	}
+
+	# --------------------
+	# return the bug's id from the subject
+	function mail_get_bug_id_from_subject ( $p_mail_subject) {
+		preg_match("/\[([A-Za-z0-9-_\.]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches);
+
+		return $v_matches[2];
+	}
+
+	# --------------------
+	# return the user id for the mail reporting user
+	function mail_get_user ($p_mailaddress) {
+		$t_mail_use_reporter	= config_get( 'mail_use_reporter' );
+		$t_mail_auto_signup	= config_get( 'mail_auto_signup' );
+		$t_mail_reporter	= config_get( 'mail_reporter' );
+		
+		$c_mailaddress = mail_parse_address( $p_mailaddress );
+
+		if ( $t_mail_use_reporter ) {
+			// Always report as mail_reporter
+			$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+		} else {
+			// Try to get the reporting users id
+			$t_reporter_id = user_get_id_by_mail ( $c_mailaddress );
+			if ( ! $t_reporter_id && $t_mail_auto_signup ) {
+				// So, we've to sign up a new user...
+				$t_user_name = mail_user_name_from_address ( $c_mailaddress );
+				user_signup($t_user_name, $c_mailaddress);
+				$t_reporter_id = user_get_id_by_name($t_user_name);
+			} elseif ( ! $t_reporter_id ) {
+				// Fall back to the default mail_reporter
+				$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+			}
+		}
+
+		return $t_reporter_id;
+	}
+    
+	# --------------------
+	# Adds a bug which is reported via email
+	# Taken from bug_report.php and 
+	function mail_add_bug( $p_mail, $p_account ) {
+		$t_bug_data = new BugData;
+		$t_bug_data->build			= gpc_get_string( 'build', '' );
+		$t_bug_data->platform			= gpc_get_string( 'platform', '' );
+		$t_bug_data->os				= gpc_get_string( 'os', '' );
+		$t_bug_data->os_build			= gpc_get_string( 'os_build', '' );
+		$t_bug_data->version			= gpc_get_string( 'product_version', '' );
+		$t_bug_data->profile_id			= gpc_get_int( 'profile_id', 0 );
+		$t_bug_data->handler_id			= gpc_get_int( 'handler_id', 0 );
+		$t_bug_data->view_state			= gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
+
+		if ( $p_account['category']) {
+			$t_bug_data->category			= gpc_get_string( 'category', $p_account['category'] );
+		} else {
+			$t_bug_data->category			= gpc_get_string( 'category', '' );
+		}
+		$t_bug_data->reproducibility		= 10;
+		$t_bug_data->severity			= 50;
+		$t_bug_data->priority			= gpc_get_int( 'priority', NORMAL );
+		$t_bug_data->summary			= $p_mail['Subject'];
+		$t_bug_data->description		= $p_mail['X-Mantis-Body'];
+		$t_bug_data->steps_to_reproduce		= gpc_get_string( 'steps_to_reproduce', '' );
+		$t_bug_data->additional_information	= $p_mail['X-Mantis-Complete'];
+
+		$t_bug_data->project_id			= $p_account['id'];
+
+		$t_bug_data->reporter_id		= mail_get_user( $p_mail['From'] );
+
+		if (mail_is_a_bugnote($p_mail['Subject']))
+		{
+			# Add a bug note
+			$t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] );
+			if ( ! bug_is_readonly( $t_bug_id ) ) {
+				bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] );
+				email_bugnote_add ( $t_bug_id );
+			}
+		}
+		else
+		{
+			# Create the bug
+			$t_bug_id = bug_create( $t_bug_data );
+			email_new_bug( $t_bug_id );
+		}
+
+	}
+
+?>
diff -Nru mantis-0.19.0.orig/core/user_api.php mantis-0.19.0/core/user_api.php
--- mantis-0.19.0.orig/core/user_api.php	Mon Aug 23 16:13:34 2004
+++ mantis-0.19.0/core/user_api.php	Wed Sep 15 17:20:36 2004
@@ -478,6 +478,27 @@
 	}
 
 	# --------------------
+	# get a user id from an mail address
+	#  return false if the mail address does not exist
+	function user_get_id_by_mail( $p_mailaddress ) {
+		
+		$c_mailaddress = db_prepare_string( $p_mailaddress );
+
+		$t_user_table = config_get( 'mantis_user_table' );
+
+		$query = "SELECT id
+				  FROM $t_user_table
+				  WHERE email='$c_mailaddress'";
+		$result = db_query( $query );
+
+		if ( 0 == db_num_rows( $result ) ) {
+			return false;
+		} else {
+			return db_result( $result );
+		}
+	}
+
+	# --------------------
 	# return all data associated with a particular user name
 	#  return false if the username does not exist
 	function user_get_row_by_name( $p_username ) {
diff -Nru mantis-0.19.0.orig/doc/README.bug_report_mail mantis-0.19.0/doc/README.bug_report_mail
--- mantis-0.19.0.orig/doc/README.bug_report_mail	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/doc/README.bug_report_mail	Wed Sep 15 19:01:55 2004
@@ -0,0 +1,58 @@
+The current version of bug_report_mail only support plain text e-mails
+and POP3 Mailaccounts with PEAR's Net_POP3 packge.
+
+bug_report_mail is able to recognize if mail is a reply to an already opened
+bug and adds the content as a bugnote.
+
+If you are alway running Mantis you have to alter your projects table
+with the sql/bug_report_mail.sql script.
+If not, you can create the database tables in the way described in
+the doc/INSTALL file.
+
+This patch changes the following files:
+    core/category_api.php
+    core/user_api.php
+    config_defaults_inc.php
+    manage_proj_cat_edit_page.php
+    manage_proj_edit_page.php
+These files are new:
+    core/mail_api.php
+    sql/bug_report_mail.sql
+    bug_report_mail.php
+    manage_proj_cat_mail_delete.php
+    manage_proj_cat_mail_update.php
+    manage_proj_mail_categories.php
+    manage_proj_mail_delete.php
+    manage_proj_mail_update.php
+
+After installing this patch, you can add a POP3 server's hostname
+and authentication data for each of your projects with the project edit form.
+
+There are two ways to receive mail with bug_report_mail:
+The secure (and default) way is to use a standard reporting user:
+You have to create a reporter account, for example 'Mail'.
+The name for this reporter account you have to write in your config_inc.php file:
+	$g_mail_reporter = "Mail";
+and then, bug_report_mail must be informed to behave like this:
+    $g_mail_use_reporter = ON;
+
+The other way is to signup new user accounts automatically.
+For using this, you have to change this
+    $g_mail_auto_signup     = OFF;
+from OFF to ON.
+Now, bug_report_mail will look for an user named like the mail's sender
+or an user which mail adress is identical.
+If no user is found, then a new account will be created.
+The new user's name will be the mail address.
+
+This could be used for attacks, but there is no other way in the moment.
+
+After this, bug_report_mail can be used via cron like this:
+
+*/5 *   *   *   * lynx --dump http://mantis.homepage.com/bug_report_mail.php
+
+This line uses lynx to fetch bug reports from via POP3 every 5 minutes. 
+
+This addon is distributed under the same condition as Mantis itself.
+
+Gerrit Beine, August 2004
diff -Nru mantis-0.19.0.orig/manage_proj_cat_edit_page.php mantis-0.19.0/manage_proj_cat_edit_page.php
--- mantis-0.19.0.orig/manage_proj_cat_edit_page.php	Mon Apr 12 23:04:34 2004
+++ mantis-0.19.0/manage_proj_cat_edit_page.php	Wed Sep 15 18:26:32 2004
@@ -15,6 +15,7 @@
 	$t_core_path = config_get( 'core_path' );
 	
 	require_once( $t_core_path.'category_api.php' );
+	require_once( $t_core_path.'mail_api.php' );
 ?>
 <?php
 	$f_project_id	= gpc_get_int( 'project_id' );
@@ -24,6 +25,12 @@
 
 	$t_row = category_get_row( $f_project_id, $f_category );
 	$t_assigned_to = $t_row['user_id'];
+	$t_mail = mail_get_account_data( $f_project_id );
+	if ( $t_mail['pop3_categories'] ) {
+		$t_category_mail = mail_category_get_account_data( $f_project_id, $f_category );
+		print_r($t_category_mail);
+	}
+
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -83,5 +90,60 @@
 		<input type="submit" class="button" value="<?php echo lang_get( 'delete_category_button' ) ?>" />
 	</form>
 </div>
+
+<?php  if ( $t_mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_cat_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Category Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_cat_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<?php } ?>
 
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nru mantis-0.19.0.orig/manage_proj_cat_mail_delete.php mantis-0.19.0/manage_proj_cat_mail_delete.php
--- mantis-0.19.0.orig/manage_proj_cat_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/manage_proj_cat_mail_delete.php	Wed Sep 15 18:26:08 2004
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_category_delete( $f_project_id, $f_category );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nru mantis-0.19.0.orig/manage_proj_cat_mail_update.php mantis-0.19.0/manage_proj_cat_mail_update.php
--- mantis-0.19.0.orig/manage_proj_cat_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/manage_proj_cat_mail_update.php	Wed Sep 15 18:14:39 2004
@@ -0,0 +1,58 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+	}
+
+	mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nru mantis-0.19.0.orig/manage_proj_edit_page.php mantis-0.19.0/manage_proj_edit_page.php
--- mantis-0.19.0.orig/manage_proj_edit_page.php	Thu Jul 15 00:16:34 2004
+++ mantis-0.19.0/manage_proj_edit_page.php	Wed Sep 15 18:27:49 2004
@@ -18,6 +18,7 @@
 	require_once( $t_core_path . 'version_api.php' );
 	require_once( $t_core_path . 'custom_field_api.php' );
 	require_once( $t_core_path . 'icon_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
 ?>
 <?php
 	$f_project_id = gpc_get_int( 'project_id' );
@@ -25,6 +26,8 @@
 	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
 
 	$row = project_get_row( $f_project_id );
+	$mail = mail_get_account_data( $f_project_id );
+
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -534,4 +537,74 @@
 	</table>
 </div>
 
+<?php  if ( ! $mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<br />
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="On" />
+		<input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } else { ?>
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="Off" />
+		<input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } ?>
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nru mantis-0.19.0.orig/manage_proj_mail_categories.php mantis-0.19.0/manage_proj_mail_categories.php
--- mantis-0.19.0.orig/manage_proj_mail_categories.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/manage_proj_mail_categories.php	Wed Sep 15 18:03:32 2004
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_activate	= gpc_get_string( 'categories' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_categories( $f_project_id, $f_activate );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nru mantis-0.19.0.orig/manage_proj_mail_delete.php mantis-0.19.0/manage_proj_mail_delete.php
--- mantis-0.19.0.orig/manage_proj_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/manage_proj_mail_delete.php	Wed Sep 15 17:50:34 2004
@@ -0,0 +1,42 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_delete( $f_project_id );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nru mantis-0.19.0.orig/manage_proj_mail_update.php mantis-0.19.0/manage_proj_mail_update.php
--- mantis-0.19.0.orig/manage_proj_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/manage_proj_mail_update.php	Wed Sep 15 17:50:31 2004
@@ -0,0 +1,58 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+
+	echo $f_project_id;
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+	}
+
+	mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nru mantis-0.19.0.orig/sql/bug_report_mail.sql mantis-0.19.0/sql/bug_report_mail.sql
--- mantis-0.19.0.orig/sql/bug_report_mail.sql	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.0/sql/bug_report_mail.sql	Wed Sep 15 18:13:15 2004
@@ -0,0 +1,12 @@
+ALTER TABLE `mantis_project_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_categories` ENUM( '0', '1' ) DEFAULT '0' NOT NULL ;
+
+ALTER TABLE `mantis_project_category_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ;
+
+
diff -Nru mantis-0.19.0.orig/sql/db_generate.sql mantis-0.19.0/sql/db_generate.sql
--- mantis-0.19.0.orig/sql/db_generate.sql	Sun Sep 12 14:19:24 2004
+++ mantis-0.19.0/sql/db_generate.sql	Wed Sep 15 18:30:43 2004
@@ -328,6 +328,10 @@
   project_id int(7) unsigned NOT NULL default '0',
   category varchar(64) NOT NULL default '',
   user_id int(7) unsigned NOT NULL default '0',
+  pop3_host varchar( 255 ) default NULL ,
+  pop3_user varchar( 255 ) default NULL ,
+  pop3_pass varchar( 255 ) default NULL ,
+  pop3_pass varchar( 255 ) default NULL ,
   PRIMARY KEY  (project_id,category)
 ) TYPE=MyISAM;
 
@@ -377,6 +381,11 @@
   access_min int(2) NOT NULL default '10',
   file_path varchar(250) NOT NULL default '',
   description text NOT NULL,
+  pop3_host varchar( 255 ) default NULL ,
+  pop3_user varchar( 255 ) default NULL ,
+  pop3_pass varchar( 255 ) default NULL ,
+  pop3_pass varchar( 255 ) default NULL ,
+  pop3_categories enum( '0','1' ) NOT NULL default '0',
   PRIMARY KEY  (id),
   UNIQUE KEY name (name),
   KEY id (id)
mantis-0.19.0.patch (34,447 bytes)   
mantis-0.19.1.patch (29,263 bytes)   
diff -Nur mantis-0.19.1.orig/bug_report_mail.php mantis-0.19.1/bug_report_mail.php
--- mantis-0.19.1.orig/bug_report_mail.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/bug_report_mail.php	Wed Sep 15 18:59:59 2004
@@ -0,0 +1,33 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	# This page receives an E-Mail via POP3 and generates an Report
+	header("Content-type: text/plain");
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'string_api.php' );
+	require_once( $t_core_path . 'bug_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$t_mailaccounts = mail_get_accounts();
+	
+	foreach ($t_mailaccounts as $t_mailaccount) {
+		$t_mails = mail_get_all_mails($t_mailaccount);
+		foreach ($t_mails as $t_mail)
+		{
+			mail_add_bug($t_mail, $t_mailaccount);
+		}
+	}
+?>
+
diff -Nur mantis-0.19.1.orig/config_defaults_inc.php mantis-0.19.1/config_defaults_inc.php
--- mantis-0.19.1.orig/config_defaults_inc.php	Sat Nov  6 12:54:14 2004
+++ mantis-0.19.1/config_defaults_inc.php	Sat Nov  6 19:59:13 2004
@@ -1470,4 +1470,20 @@
 	# NOTE: These are meaningless under Windows! Just ignore them!
 	$g_dot_tool							= '/usr/bin/dot';
 	$g_neato_tool						= '/usr/bin/neato';
+
+	######################
+	# Mail Reporting
+	######################
+
+	# --- mail reporting settings -----
+	# This tells Mantis to report all the Mail with only one account
+	$g_mail_use_reporter    = ON;
+
+	# The account's name for mail reporting
+	# Also used for fallback if a user is not found in database
+	$g_mail_reporter        = 'Mail';
+
+	# Signup new users automatically (possible security risk!)
+	# Default is OFF, ignored if mail_use_reporter is ON
+	$g_mail_auto_signup	= OFF;
 ?>
diff -Nur mantis-0.19.1.orig/core/category_api.php mantis-0.19.1/core/category_api.php
--- mantis-0.19.1.orig/core/category_api.php	Thu Apr  8 21:04:52 2004
+++ mantis-0.19.1/core/category_api.php	Sat Nov  6 19:41:45 2004
@@ -206,7 +206,7 @@
 
 		$t_project_category_table = config_get( 'mantis_project_category_table' );
 
-		$query = "SELECT category, user_id
+		$query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass
 				FROM $t_project_category_table
 				WHERE project_id='$c_project_id'
 				ORDER BY category";
diff -Nur mantis-0.19.1.orig/core/mail_api.php mantis-0.19.1/core/mail_api.php
--- mantis-0.19.1.orig/core/mail_api.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/core/mail_api.php	Sat Nov  6 18:27:31 2004
@@ -0,0 +1,341 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
+	
+	require_once( $t_core_dir . 'bug_api.php' );
+	require_once( $t_core_dir . 'bugnote_api.php' );
+	require_once( $t_core_dir . 'user_api.php' );
+	require_once( $t_core_dir . 'project_api.php' );
+
+	# This page receives an E-Mail via POP3 and generates an Report
+
+	require_once( 'Net/POP3.php' );
+
+	# --------------------
+	# Return mail account data for the specified project
+	function mail_get_account_data( $p_project_id ) {
+		$v_project_id = db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories
+				FROM $t_project_table 
+				WHERE id='$v_project_id'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data
+	function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_pop3_host	= db_prepare_string( $p_pop3_host );
+		$v_pop3_user	= db_prepare_string( $p_pop3_user );
+		$v_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+			 	SET pop3_host='$v_pop3_host',
+				pop3_user='$v_pop3_user',
+				pop3_pass='$v_pop3_pass'
+				WHERE id='$v_project_id'";
+		db_query( $query );
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data
+	function mail_delete( $p_project_id ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Activate the Mail per Category feature for a project
+	function mail_categories( $p_project_id , $p_active ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		if ($p_active == 'On') {
+			$v_active = 1;
+		} else {
+			$v_active = 0;
+		}
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_categories='$v_active'
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Return mail account data for the specified project and category
+	function mail_category_get_account_data( $p_project_id, $p_category ) {
+		$c_project_id = db_prepare_int( $p_project_id );
+		$c_category	= db_prepare_string( $p_category );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass
+				FROM $t_project_category_table 
+				WHERE project_id='$c_project_id' AND category='$c_category'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data for a category
+	function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$c_project_id	= db_prepare_int( $p_project_id );
+		$c_category	= db_prepare_string( $p_category );
+		$c_pop3_host	= db_prepare_string( $p_pop3_host );
+		$c_pop3_user	= db_prepare_string( $p_pop3_user );
+		$c_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host='$c_pop3_host',
+				pop3_user='$c_pop3_user',
+				pop3_pass='$c_pop3_pass'
+				WHERE project_id='$c_project_id' AND category='$c_category'";
+		db_query( $query );
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data for a category
+	function mail_category_delete( $p_project_id, $p_category ) {
+		$c_project_id	= db_prepare_int( $p_project_id );
+		$c_category	= db_prepare_string( $p_category );
+		
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE project_id='$c_project_id' AND category='$c_category'";
+
+		db_query( $query );
+		return true;
+	}
+
+	# --------------------
+	# return all mailaccounts
+	#  return an empty array if there are no
+	function mail_get_accounts() {
+		$v_accounts = array();
+		$t_projects = mail_project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_categories']) {
+				$v_categories = mail_categories_get_all_rows( $t_project['id'] );
+				$v_accounts = array_merge($v_accounts, $v_categories);
+			} else {
+				array_push($v_accounts, $t_project);
+			}
+		}
+
+		return $v_accounts;
+	}
+
+	# --------------------
+	# return all projects with valid data for mail access
+	#  return an empty array if there are no such projects
+	function mail_project_get_all_rows() {
+		$v_projects = array();
+		$t_projects = project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_host'] || $t_project['pop3_categories']) {
+				array_push($v_projects, $t_project);
+			}
+		}
+
+		return $v_projects;
+	}
+
+	# --------------------
+	# return all projects with valid data for mail access
+	#  return an empty array if there are no such projects
+	function mail_categories_get_all_rows( $p_project_id ) {
+		$v_categories = array();
+		$t_categories = category_get_all_rows( $p_project_id );
+
+		foreach ($t_categories as $t_category) {
+			if ($t_category['pop3_host']) {
+				$t_category['id'] = $p_project_id;
+				array_push($v_categories, $t_category);
+			}
+		}
+
+		return $v_categories;
+	}
+
+	# --------------------
+	# return all mails for an account
+	#  return an empty array if there are no new mails
+	function mail_get_all_mails( $p_account ) {
+		$v_mails = array();
+		$t_pop3 = &new Net_POP3();
+		$t_pop3_host = $p_account['pop3_host'];
+		$t_pop3_user = $p_account['pop3_user'];
+		$t_pop3_password = $p_account['pop3_pass'];
+
+		$t_pop3->connect($t_pop3_host, 110);
+		$t_pop3->login($t_pop3_user, $t_pop3_password);
+
+		for ($i = 1; $i <= $t_pop3->numMsg(); $i++) {
+			$t_mail = $t_pop3->getParsedHeaders($i);
+			$t_mail['X-Mantis-Body'] = $t_pop3->getBody($i);
+			$t_mail['X-Mantis-Complete'] = $t_pop3->getMsg($i);
+			array_push($v_mails, $t_mail);
+			$t_pop3->deleteMsg($i);
+		}
+
+		$t_pop3->disconnect();
+		return $v_mails;
+	}
+
+	# --------------------
+	# return the mailadress from the mail's 'From'
+	function mail_parse_address ( $p_mailaddress ) {
+		if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) {
+			$c_mailaddress = $matches[1];
+		}
+
+		return $c_mailaddress;
+	}
+
+	# --------------------
+	# return the a valid username from an email address
+	function mail_user_name_from_address ( $p_mailaddress ) {
+
+		return preg_replace("/[@\.-]/", '_', $p_mailaddress);
+	}
+
+	# --------------------
+	# return true if there is a valid mantis bug referernce in subject
+	function mail_is_a_bugnote ($p_mail_subject) {
+		return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_mail_subject);
+	}
+
+	# --------------------
+	# return the bug's id from the subject
+	function mail_get_bug_id_from_subject ( $p_mail_subject) {
+		preg_match("/\[([A-Za-z0-9-_\.]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches);
+
+		return $v_matches[2];
+	}
+
+	# --------------------
+	# return the user id for the mail reporting user
+	function mail_get_user ($p_mailaddress) {
+		$t_mail_use_reporter	= config_get( 'mail_use_reporter' );
+		$t_mail_auto_signup	= config_get( 'mail_auto_signup' );
+		$t_mail_reporter	= config_get( 'mail_reporter' );
+		
+		$c_mailaddress = mail_parse_address( $p_mailaddress );
+
+		if ( $t_mail_use_reporter ) {
+			// Always report as mail_reporter
+			$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+		} else {
+			// Try to get the reporting users id
+			$t_reporter_id = user_get_id_by_mail ( $c_mailaddress );
+			if ( ! $t_reporter_id && $t_mail_auto_signup ) {
+				// So, we've to sign up a new user...
+				$t_user_name = mail_user_name_from_address ( $c_mailaddress );
+				user_signup($t_user_name, $c_mailaddress);
+				$t_reporter_id = user_get_id_by_name($t_user_name);
+			} elseif ( ! $t_reporter_id ) {
+				// Fall back to the default mail_reporter
+				$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+			}
+		}
+
+		return $t_reporter_id;
+	}
+    
+	# --------------------
+	# Adds a bug which is reported via email
+	# Taken from bug_report.php and 
+	function mail_add_bug( $p_mail, $p_account ) {
+		$t_bug_data = new BugData;
+		$t_bug_data->build			= gpc_get_string( 'build', '' );
+		$t_bug_data->platform			= gpc_get_string( 'platform', '' );
+		$t_bug_data->os				= gpc_get_string( 'os', '' );
+		$t_bug_data->os_build			= gpc_get_string( 'os_build', '' );
+		$t_bug_data->version			= gpc_get_string( 'product_version', '' );
+		$t_bug_data->profile_id			= gpc_get_int( 'profile_id', 0 );
+		$t_bug_data->handler_id			= gpc_get_int( 'handler_id', 0 );
+		$t_bug_data->view_state			= gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
+
+		if ( $p_account['category']) {
+			$t_bug_data->category			= gpc_get_string( 'category', $p_account['category'] );
+		} else {
+			$t_bug_data->category			= gpc_get_string( 'category', '' );
+		}
+		$t_bug_data->reproducibility		= 10;
+		$t_bug_data->severity			= 50;
+		$t_bug_data->priority			= gpc_get_int( 'priority', NORMAL );
+		$t_bug_data->summary			= $p_mail['Subject'];
+		$t_bug_data->description		= $p_mail['X-Mantis-Body'];
+		$t_bug_data->steps_to_reproduce		= gpc_get_string( 'steps_to_reproduce', '' );
+		$t_bug_data->additional_information	= $p_mail['X-Mantis-Complete'];
+
+		$t_bug_data->project_id			= $p_account['id'];
+
+		$t_bug_data->reporter_id		= mail_get_user( $p_mail['From'] );
+
+		if (mail_is_a_bugnote($p_mail['Subject']))
+		{
+			# Add a bug note
+			$t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] );
+			if ( ! bug_is_readonly( $t_bug_id ) ) {
+				bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] );
+				email_bugnote_add ( $t_bug_id );
+			}
+		}
+		else
+		{
+			# Create the bug
+			$t_bug_id = bug_create( $t_bug_data );
+			email_new_bug( $t_bug_id );
+		}
+
+	}
+
+?>
diff -Nur mantis-0.19.1.orig/core/user_api.php mantis-0.19.1/core/user_api.php
--- mantis-0.19.1.orig/core/user_api.php	Mon Aug 23 17:13:34 2004
+++ mantis-0.19.1/core/user_api.php	Sat Nov  6 19:43:10 2004
@@ -477,6 +477,27 @@
 		}
 	}
 
+	# get a user id from an mail address
+	#  return false if the mail address does not exist
+	function user_get_id_by_mail( $p_mailaddress ) {
+		
+		$c_mailaddress = db_prepare_string( $p_mailaddress );
+
+		$t_user_table = config_get( 'mantis_user_table' );
+
+		$query = "SELECT id
+				  FROM $t_user_table
+				  WHERE email='$c_mailaddress'";
+		$result = db_query( $query );
+
+		if ( 0 == db_num_rows( $result ) ) {
+			return false;
+		} else {
+			return db_result( $result );
+		}
+	}
+
+	# --------------------
 	# --------------------
 	# return all data associated with a particular user name
 	#  return false if the username does not exist
diff -Nur mantis-0.19.1.orig/manage_proj_cat_edit_page.php mantis-0.19.1/manage_proj_cat_edit_page.php
--- mantis-0.19.1.orig/manage_proj_cat_edit_page.php	Tue Apr 13 00:04:34 2004
+++ mantis-0.19.1/manage_proj_cat_edit_page.php	Sat Nov  6 19:55:07 2004
@@ -15,6 +15,7 @@
 	$t_core_path = config_get( 'core_path' );
 	
 	require_once( $t_core_path.'category_api.php' );
+	require_once( $t_core_path.'mail_api.php' );
 ?>
 <?php
 	$f_project_id	= gpc_get_int( 'project_id' );
@@ -24,6 +25,10 @@
 
 	$t_row = category_get_row( $f_project_id, $f_category );
 	$t_assigned_to = $t_row['user_id'];
+	$t_mail = mail_get_account_data( $f_project_id );
+	if ( $t_mail['pop3_categories'] ) {
+		$t_category_mail = mail_category_get_account_data( $f_project_id, $f_category );
+	}
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -83,5 +88,60 @@
 		<input type="submit" class="button" value="<?php echo lang_get( 'delete_category_button' ) ?>" />
 	</form>
 </div>
+
+<?php  if ( $t_mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_cat_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Category Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_cat_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<?php } ?>
 
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.1.orig/manage_proj_cat_mail_delete.php mantis-0.19.1/manage_proj_cat_mail_delete.php
--- mantis-0.19.1.orig/manage_proj_cat_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/manage_proj_cat_mail_delete.php	Wed Sep 15 18:26:08 2004
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_category_delete( $f_project_id, $f_category );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.1.orig/manage_proj_cat_mail_update.php mantis-0.19.1/manage_proj_cat_mail_update.php
--- mantis-0.19.1.orig/manage_proj_cat_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/manage_proj_cat_mail_update.php	Wed Sep 15 18:14:39 2004
@@ -0,0 +1,58 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+	}
+
+	mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.1.orig/manage_proj_edit_page.php mantis-0.19.1/manage_proj_edit_page.php
--- mantis-0.19.1.orig/manage_proj_edit_page.php	Wed Sep 22 13:15:32 2004
+++ mantis-0.19.1/manage_proj_edit_page.php	Sat Nov  6 19:54:10 2004
@@ -18,6 +18,7 @@
 	require_once( $t_core_path . 'version_api.php' );
 	require_once( $t_core_path . 'custom_field_api.php' );
 	require_once( $t_core_path . 'icon_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
 ?>
 <?php
 	$f_project_id = gpc_get_int( 'project_id' );
@@ -25,6 +26,7 @@
 	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
 
 	$row = project_get_row( $f_project_id );
+	$mail = mail_get_account_data( $f_project_id );
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -551,4 +553,74 @@
 	</table>
 </div>
 
+<?php  if ( ! $mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<br />
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="On" />
+		<input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } else { ?>
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="Off" />
+		<input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } ?>
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.1.orig/manage_proj_mail_categories.php mantis-0.19.1/manage_proj_mail_categories.php
--- mantis-0.19.1.orig/manage_proj_mail_categories.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/manage_proj_mail_categories.php	Wed Sep 15 18:03:32 2004
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_activate	= gpc_get_string( 'categories' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_categories( $f_project_id, $f_activate );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.1.orig/manage_proj_mail_delete.php mantis-0.19.1/manage_proj_mail_delete.php
--- mantis-0.19.1.orig/manage_proj_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/manage_proj_mail_delete.php	Wed Sep 15 17:50:34 2004
@@ -0,0 +1,42 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_delete( $f_project_id );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.1.orig/manage_proj_mail_update.php mantis-0.19.1/manage_proj_mail_update.php
--- mantis-0.19.1.orig/manage_proj_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/manage_proj_mail_update.php	Wed Sep 15 17:50:31 2004
@@ -0,0 +1,58 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+
+	echo $f_project_id;
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+	}
+
+	mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
mantis-0.19.1.patch (29,263 bytes)   
mantis-0.19.1-mime.patch (38,514 bytes)   
diff -Nur mantis-0.19.1.orig/bug_report_mail.php mantis-0.19.1/bug_report_mail.php
--- mantis-0.19.1.orig/bug_report_mail.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/bug_report_mail.php	Sun Nov 21 18:19:31 2004
@@ -0,0 +1,33 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	# This page receives an E-Mail via POP3 and generates an Report
+	header("Content-type: text/plain");
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'string_api.php' );
+	require_once( $t_core_path . 'bug_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$t_mailaccounts = mail_get_accounts();
+
+	foreach ($t_mailaccounts as $t_mailaccount) {
+		$t_mails = mail_get_all_mails($t_mailaccount);
+		foreach ($t_mails as $t_mail)
+		{
+			$GLOBALS['g_cache_current_user_id'] = mail_get_user( $t_mail['From'] );
+                        mail_add_bug($t_mail, $t_mailaccount);
+		}
+	}
+?>
+
diff -Nur mantis-0.19.1.orig/config_defaults_inc.php mantis-0.19.1/config_defaults_inc.php
--- mantis-0.19.1.orig/config_defaults_inc.php	Sat Nov  6 12:54:14 2004
+++ mantis-0.19.1/config_defaults_inc.php	Sat Nov  6 19:59:13 2004
@@ -1470,4 +1470,20 @@
 	# NOTE: These are meaningless under Windows! Just ignore them!
 	$g_dot_tool							= '/usr/bin/dot';
 	$g_neato_tool						= '/usr/bin/neato';
+
+	######################
+	# Mail Reporting
+	######################
+
+	# --- mail reporting settings -----
+	# This tells Mantis to report all the Mail with only one account
+	$g_mail_use_reporter    = ON;
+
+	# The account's name for mail reporting
+	# Also used for fallback if a user is not found in database
+	$g_mail_reporter        = 'Mail';
+
+	# Signup new users automatically (possible security risk!)
+	# Default is OFF, ignored if mail_use_reporter is ON
+	$g_mail_auto_signup	= OFF;
 ?>
diff -Nur mantis-0.19.1.orig/config_inc.php mantis-0.19.1/config_inc.php
--- mantis-0.19.1.orig/config_inc.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/config_inc.php	Sun Sep 12 15:23:34 2004
@@ -0,0 +1,52 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id: config_inc.php.sample,v 1.14 2004/09/12 12:23:35 vboctor Exp $
+	# --------------------------------------------------------
+	
+	# This sample file contains the essential files that you MUST
+	# configure to your specific settings.  You may override settings
+	# from config_defaults_inc.php by assigning new values in this file
+
+	# Rename this file to config_inc.php after configuration.
+
+	###########################################################################
+	# CONFIGURATION VARIABLES
+	###########################################################################
+
+	# In general the value OFF means the feature is disabled and ON means the
+	# feature is enabled.  Any other cases will have an explanation.
+
+	# Look in http://www.mantisbt.org/manual or config_defaults_inc.php for more
+	# detailed comments.
+
+	# --- database variables ---------
+
+	# set these values to match your setup
+	$g_hostname      = "localhost";
+	$g_db_username   = "root";
+	$g_db_password   = "";
+	$g_database_name = "bugtracker";
+
+	# --- email variables -------------
+	$g_administrator_email  = 'administrator@example.com';
+	$g_webmaster_email      = 'webmaster@example.com';
+
+	# the "From: " field in emails
+	$g_from_email           = 'noreply@example.com';
+
+	# the return address for bounced mail
+	$g_return_path_email    = 'admin@example.com';
+
+	# --- file upload settings --------
+	# This is the master setting to disable *all* file uploading functionality
+	#
+	# The default value is ON but you must make sure file uploading is enabled
+	#  in PHP as well.  You may need to add "file_uploads = TRUE" to your php.ini.
+	$g_allow_file_upload	= ON;
+?>
\ No newline at end of file
diff -Nur mantis-0.19.1.orig/core/category_api.php mantis-0.19.1/core/category_api.php
--- mantis-0.19.1.orig/core/category_api.php	Thu Apr  8 21:04:52 2004
+++ mantis-0.19.1/core/category_api.php	Sat Nov  6 19:41:45 2004
@@ -206,7 +206,7 @@
 
 		$t_project_category_table = config_get( 'mantis_project_category_table' );
 
-		$query = "SELECT category, user_id
+		$query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass
 				FROM $t_project_category_table
 				WHERE project_id='$c_project_id'
 				ORDER BY category";
diff -Nur mantis-0.19.1.orig/core/mail_api.php mantis-0.19.1/core/mail_api.php
--- mantis-0.19.1.orig/core/mail_api.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/core/mail_api.php	Sun Nov 21 18:39:10 2004
@@ -0,0 +1,409 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
+	
+	require_once( $t_core_dir . 'bug_api.php' );
+	require_once( $t_core_dir . 'bugnote_api.php' );
+	require_once( $t_core_dir . 'user_api.php' );
+	require_once( $t_core_dir . 'project_api.php' );
+	require_once( $t_core_dir . 'file_api.php' );
+
+	# This page receives an E-Mail via POP3 and generates an Report
+
+	require_once( 'Net/POP3.php' );
+	require_once( 'Mail/mimeDecode.php' );
+
+	# --------------------
+	# Return mail account data for the specified project
+	function mail_get_account_data( $p_project_id ) {
+		$v_project_id = db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories
+				FROM $t_project_table 
+				WHERE id='$v_project_id'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data
+	function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_pop3_host	= db_prepare_string( $p_pop3_host );
+		$v_pop3_user	= db_prepare_string( $p_pop3_user );
+		$v_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+			 	SET pop3_host='$v_pop3_host',
+				pop3_user='$v_pop3_user',
+				pop3_pass='$v_pop3_pass'
+				WHERE id='$v_project_id'";
+		db_query( $query );
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data
+	function mail_delete( $p_project_id ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Activate the Mail per Category feature for a project
+	function mail_categories( $p_project_id , $p_active ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		if ($p_active == 'On') {
+			$v_active = 1;
+		} else {
+			$v_active = 0;
+		}
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_categories='$v_active'
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Return mail account data for the specified project and category
+	function mail_category_get_account_data( $p_project_id, $p_category ) {
+		$c_project_id = db_prepare_int( $p_project_id );
+		$c_category	= db_prepare_string( $p_category );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass
+				FROM $t_project_category_table 
+				WHERE project_id='$c_project_id' AND category='$c_category'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data for a category
+	function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$c_project_id	= db_prepare_int( $p_project_id );
+		$c_category	= db_prepare_string( $p_category );
+		$c_pop3_host	= db_prepare_string( $p_pop3_host );
+		$c_pop3_user	= db_prepare_string( $p_pop3_user );
+		$c_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host='$c_pop3_host',
+				pop3_user='$c_pop3_user',
+				pop3_pass='$c_pop3_pass'
+				WHERE project_id='$c_project_id' AND category='$c_category'";
+		db_query( $query );
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data for a category
+	function mail_category_delete( $p_project_id, $p_category ) {
+		$c_project_id	= db_prepare_int( $p_project_id );
+		$c_category	= db_prepare_string( $p_category );
+		
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE project_id='$c_project_id' AND category='$c_category'";
+
+		db_query( $query );
+		return true;
+	}
+
+	# --------------------
+	# return all mailaccounts
+	#  return an empty array if there are no
+	function mail_get_accounts() {
+		$v_accounts = array();
+		$t_projects = mail_project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_categories']) {
+				$v_categories = mail_categories_get_all_rows( $t_project['id'] );
+				$v_accounts = array_merge($v_accounts, $v_categories);
+			} else {
+				array_push($v_accounts, $t_project);
+			}
+		}
+
+		return $v_accounts;
+	}
+
+	# --------------------
+	# return all projects with valid data for mail access
+	#  return an empty array if there are no such projects
+	function mail_project_get_all_rows() {
+		$v_projects = array();
+		$t_projects = project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_host'] || $t_project['pop3_categories']) {
+				array_push($v_projects, $t_project);
+			}
+		}
+
+		return $v_projects;
+	}
+
+	# --------------------
+	# return all projects with valid data for mail access
+	#  return an empty array if there are no such projects
+	function mail_categories_get_all_rows( $p_project_id ) {
+		$v_categories = array();
+		$t_categories = category_get_all_rows( $p_project_id );
+
+		foreach ($t_categories as $t_category) {
+			if ($t_category['pop3_host']) {
+				$t_category['id'] = $p_project_id;
+				array_push($v_categories, $t_category);
+			}
+		}
+
+		return $v_categories;
+	}
+
+	# --------------------
+	# return all mails for an account
+	#  return an empty array if there are no new mails
+	function mail_get_all_mails( $p_account ) {
+		$v_mails = array();
+		$t_pop3 = &new Net_POP3();
+		$t_pop3_host = $p_account['pop3_host'];
+		$t_pop3_user = $p_account['pop3_user'];
+		$t_pop3_password = $p_account['pop3_pass'];
+		$t_pop3->connect($t_pop3_host, 110);
+		$t_pop3->login($t_pop3_user, $t_pop3_password);
+
+		for ($i = 1; $i <= $t_pop3->numMsg(); $i++) {
+                        $t_mail = mail_parse_content( $t_pop3->getMsg($i) );
+			array_push($v_mails, $t_mail);
+#			$t_pop3->deleteMsg($i);
+		}
+
+		$t_pop3->disconnect();
+		return $v_mails;
+	}
+
+	# --------------------
+	# return the mail parsed for Mantis
+	function mail_parse_content ( $p_mail ) {
+                $t_mail = array ();
+		$t_decoder = new Mail_mimeDecode($p_mail);
+                $t_params['include_bodies'] = true;
+                $t_params['decode_bodies']  = true;
+                $t_params['decode_headers'] = true;
+		$t_structure = $t_decoder->decode($t_params);
+                $t_mail['To'] = $t_structure->headers['to'];
+                $t_mail['From'] = $t_structure->headers['from'];
+                $t_mail['Subject'] = $t_structure->headers['subject'];
+                if (is_array($t_structure->parts))
+                {
+                    $t_parts = mail_parse_parts( $t_structure->parts );
+                }
+                else
+                {
+                    $t_parts = array ( mail_parse_part( $t_structure ) );
+                }
+                if ($t_parts[0]['Content-Type'] == 'text/plain') {
+                    $t_body = array_shift($t_parts);
+                }
+                else
+                {
+                    $t_body['Body'] = "It seems, there is no text... :-o";
+                }
+                $t_mail['X-Mantis-Parts'] = $t_parts;
+                $t_mail['X-Mantis-Body'] = $t_body['Body'];
+		$t_mail['X-Mantis-Complete'] = $p_mail;
+		
+		return $t_mail;
+	}
+
+	# --------------------
+	# return the mail parsed for Mantis
+	function mail_parse_parts ( $p_parts ) {
+                $t_parts = array ();
+                foreach ( $p_parts as $t_part ) {
+                    array_push($t_parts, mail_parse_part( $t_part ));
+                }
+                
+                return $t_parts;
+        }
+
+	# --------------------
+	# return the mail parsed for Mantis
+	function mail_parse_part ( $p_part ) {
+                $t_part = array ();
+                $t_part['Content-Type'] = $p_part->ctype_primary."/".$p_part->ctype_secondary;
+                $t_part['Name'] = $p_part->ctype_parameters['name'];
+                $t_part['Body'] = $p_part->body;
+
+                return $t_part;
+        }
+
+	# --------------------
+	# return the mailadress from the mail's 'From'
+	function mail_parse_address ( $p_mailaddress ) {
+		if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) {
+			$c_mailaddress = $matches[1];
+		}
+
+		return $c_mailaddress;
+	}
+
+	# --------------------
+	# return the a valid username from an email address
+	function mail_user_name_from_address ( $p_mailaddress ) {
+		return preg_replace("/[@\.-]/", '_', $p_mailaddress);
+	}
+
+	# --------------------
+	# return true if there is a valid mantis bug referernce in subject
+	function mail_is_a_bugnote ($p_mail_subject) {
+		return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_mail_subject);
+	}
+
+	# --------------------
+	# return the bug's id from the subject
+	function mail_get_bug_id_from_subject ( $p_mail_subject) {
+		preg_match("/\[([A-Za-z0-9-_\.]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches);
+
+		return $v_matches[2];
+	}
+
+	# --------------------
+	# return the user id for the mail reporting user
+	function mail_get_user ($p_mailaddress) {
+		$t_mail_use_reporter	= config_get( 'mail_use_reporter' );
+		$t_mail_auto_signup	= config_get( 'mail_auto_signup' );
+		$t_mail_reporter	= config_get( 'mail_reporter' );
+		
+		$c_mailaddress = mail_parse_address( $p_mailaddress );
+
+		if ( $t_mail_use_reporter ) {
+			// Always report as mail_reporter
+			$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+		} else {
+			// Try to get the reporting users id
+			$t_reporter_id = user_get_id_by_mail ( $c_mailaddress );
+			if ( ! $t_reporter_id && $t_mail_auto_signup ) {
+				// So, we've to sign up a new user...
+				$t_user_name = mail_user_name_from_address ( $c_mailaddress );
+				user_signup($t_user_name, $c_mailaddress);
+				$t_reporter_id = user_get_id_by_name($t_user_name);
+			} elseif ( ! $t_reporter_id ) {
+				// Fall back to the default mail_reporter
+				$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+			}
+		}
+
+		return $t_reporter_id;
+	}
+
+	# --------------------
+	# Adds a file to a bug. Very dirty
+	function mail_add_file( $p_bug_id, $p_part ) {
+            $GLOBALS['_mail_file_'] = $p_part['Name'];
+            $t_file_name = '/tmp/'.$p_part['Name'];
+            file_put_contents($t_file_name, $p_part['Body']);
+            file_add($p_bug_id, $t_file_name,  $p_part['Name'], $p_part['Content-Type'], 'bug');
+            unlink($t_file_name);
+        }
+
+	# --------------------
+	# Adds a bug which is reported via email
+	# Taken from bug_report.php and 
+	function mail_add_bug( $p_mail, $p_account ) {
+		$t_bug_data = new BugData;
+		$t_bug_data->build			= gpc_get_string( 'build', '' );
+		$t_bug_data->platform			= gpc_get_string( 'platform', '' );
+		$t_bug_data->os				= gpc_get_string( 'os', '' );
+		$t_bug_data->os_build			= gpc_get_string( 'os_build', '' );
+		$t_bug_data->version			= gpc_get_string( 'product_version', '' );
+		$t_bug_data->profile_id			= gpc_get_int( 'profile_id', 0 );
+		$t_bug_data->handler_id			= gpc_get_int( 'handler_id', 0 );
+		$t_bug_data->view_state			= gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
+
+		if ( $p_account['category']) {
+			$t_bug_data->category			= gpc_get_string( 'category', $p_account['category'] );
+		} else {
+			$t_bug_data->category			= gpc_get_string( 'category', '' );
+		}
+		$t_bug_data->reproducibility		= 10;
+		$t_bug_data->severity			= 50;
+		$t_bug_data->priority			= gpc_get_int( 'priority', NORMAL );
+		$t_bug_data->summary			= $p_mail['Subject'];
+		$t_bug_data->description		= $p_mail['X-Mantis-Body'];
+		$t_bug_data->steps_to_reproduce		= gpc_get_string( 'steps_to_reproduce', '' );
+		$t_bug_data->additional_information	= $p_mail['X-Mantis-Complete'];
+
+		$t_bug_data->project_id			= $p_account['id'];
+
+		$t_bug_data->reporter_id		= mail_get_user( $p_mail['From'] );
+
+                if (mail_is_a_bugnote($p_mail['Subject']))
+		{
+			# Add a bug note
+			$t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] );
+			if ( ! bug_is_readonly( $t_bug_id ) ) {
+				bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] );
+				email_bugnote_add ( $t_bug_id );
+			}
+		}
+		else
+		{
+			# Create the bug
+			$t_bug_id = bug_create( $t_bug_data );
+			email_new_bug( $t_bug_id );
+		}
+                # Add files
+                foreach ($p_mail['X-Mantis-Parts'] as $part) {
+                    mail_add_file ( $t_bug_id, $part );
+                }
+
+	}
+
+?>
diff -Nur mantis-0.19.1.orig/core/user_api.php mantis-0.19.1/core/user_api.php
--- mantis-0.19.1.orig/core/user_api.php	Mon Aug 23 17:13:34 2004
+++ mantis-0.19.1/core/user_api.php	Sat Nov  6 19:43:10 2004
@@ -477,6 +477,27 @@
 		}
 	}
 
+	# get a user id from an mail address
+	#  return false if the mail address does not exist
+	function user_get_id_by_mail( $p_mailaddress ) {
+		
+		$c_mailaddress = db_prepare_string( $p_mailaddress );
+
+		$t_user_table = config_get( 'mantis_user_table' );
+
+		$query = "SELECT id
+				  FROM $t_user_table
+				  WHERE email='$c_mailaddress'";
+		$result = db_query( $query );
+
+		if ( 0 == db_num_rows( $result ) ) {
+			return false;
+		} else {
+			return db_result( $result );
+		}
+	}
+
+	# --------------------
 	# --------------------
 	# return all data associated with a particular user name
 	#  return false if the username does not exist
diff -Nur mantis-0.19.1.orig/doc/README.bug_report_mail mantis-0.19.1/doc/README.bug_report_mail
--- mantis-0.19.1.orig/doc/README.bug_report_mail	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/doc/README.bug_report_mail	Sun Nov 21 18:46:44 2004
@@ -0,0 +1,58 @@
+The current version of bug_report_mail only support plain text e-mails
+and POP3 Mailaccounts with PEAR's Net_POP3 packge.
+
+bug_report_mail is able to recognize if mail is a reply to an already opened
+bug and adds the content as a bugnote.
+
+If you are alway running Mantis you have to alter your projects table
+with the sql/bug_report_mail.sql script.
+If not, you can create the database tables in the way described in
+the doc/INSTALL file.
+
+This patch changes the following files:
+    core/category_api.php
+    core/user_api.php
+    config_defaults_inc.php
+    manage_proj_cat_edit_page.php
+    manage_proj_edit_page.php
+These files are new:
+    core/mail_api.php
+    sql/bug_report_mail.sql
+    bug_report_mail.php
+    manage_proj_cat_mail_delete.php
+    manage_proj_cat_mail_update.php
+    manage_proj_mail_categories.php
+    manage_proj_mail_delete.php
+    manage_proj_mail_update.php
+
+After installing this patch, you can add a POP3 server's hostname
+and authentication data for each of your projects with the project edit form.
+
+There are two ways to receive mail with bug_report_mail:
+The secure (and default) way is to use a standard reporting user:
+You have to create a reporter account, for example 'Mail'.
+The name for this reporter account you have to write in your config_inc.php file:
+	$g_mail_reporter = "Mail";
+and then, bug_report_mail must be informed to behave like this:
+    $g_mail_use_reporter = ON;
+
+The other way is to signup new user accounts automatically.
+For using this, you have to change this
+    $g_mail_auto_signup     = OFF;
+from OFF to ON.
+Now, bug_report_mail will look for an user named like the mail's sender
+or an user which mail adress is identical.
+If no user is found, then a new account will be created.
+The new user's name will be the mail address.
+
+This could be used for attacks, but there is no other way in the moment.
+
+After this, bug_report_mail can be used via cron like this:
+
+*/5 *   *   *   * lynx --dump http://mantis.homepage.com/bug_report_mail.php
+
+This line uses lynx to fetch bug reports from via POP3 every 5 minutes. 
+
+This addon is distributed under the same condition as Mantis itself.
+
+Gerrit Beine, August 2004
diff -Nur mantis-0.19.1.orig/manage_proj_cat_edit_page.php mantis-0.19.1/manage_proj_cat_edit_page.php
--- mantis-0.19.1.orig/manage_proj_cat_edit_page.php	Tue Apr 13 00:04:34 2004
+++ mantis-0.19.1/manage_proj_cat_edit_page.php	Sat Nov  6 19:55:07 2004
@@ -15,6 +15,7 @@
 	$t_core_path = config_get( 'core_path' );
 	
 	require_once( $t_core_path.'category_api.php' );
+	require_once( $t_core_path.'mail_api.php' );
 ?>
 <?php
 	$f_project_id	= gpc_get_int( 'project_id' );
@@ -24,6 +25,10 @@
 
 	$t_row = category_get_row( $f_project_id, $f_category );
 	$t_assigned_to = $t_row['user_id'];
+	$t_mail = mail_get_account_data( $f_project_id );
+	if ( $t_mail['pop3_categories'] ) {
+		$t_category_mail = mail_category_get_account_data( $f_project_id, $f_category );
+	}
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -83,5 +88,60 @@
 		<input type="submit" class="button" value="<?php echo lang_get( 'delete_category_button' ) ?>" />
 	</form>
 </div>
+
+<?php  if ( $t_mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_cat_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Category Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_cat_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<?php } ?>
 
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.1.orig/manage_proj_cat_mail_delete.php mantis-0.19.1/manage_proj_cat_mail_delete.php
--- mantis-0.19.1.orig/manage_proj_cat_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/manage_proj_cat_mail_delete.php	Wed Sep 15 18:26:08 2004
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_category_delete( $f_project_id, $f_category );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.1.orig/manage_proj_cat_mail_update.php mantis-0.19.1/manage_proj_cat_mail_update.php
--- mantis-0.19.1.orig/manage_proj_cat_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/manage_proj_cat_mail_update.php	Wed Sep 15 18:14:39 2004
@@ -0,0 +1,58 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+	}
+
+	mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.1.orig/manage_proj_edit_page.php mantis-0.19.1/manage_proj_edit_page.php
--- mantis-0.19.1.orig/manage_proj_edit_page.php	Wed Sep 22 13:15:32 2004
+++ mantis-0.19.1/manage_proj_edit_page.php	Sat Nov  6 19:54:10 2004
@@ -18,6 +18,7 @@
 	require_once( $t_core_path . 'version_api.php' );
 	require_once( $t_core_path . 'custom_field_api.php' );
 	require_once( $t_core_path . 'icon_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
 ?>
 <?php
 	$f_project_id = gpc_get_int( 'project_id' );
@@ -25,6 +26,7 @@
 	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
 
 	$row = project_get_row( $f_project_id );
+	$mail = mail_get_account_data( $f_project_id );
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -551,4 +553,74 @@
 	</table>
 </div>
 
+<?php  if ( ! $mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<br />
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="On" />
+		<input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } else { ?>
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="Off" />
+		<input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } ?>
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.1.orig/manage_proj_mail_categories.php mantis-0.19.1/manage_proj_mail_categories.php
--- mantis-0.19.1.orig/manage_proj_mail_categories.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/manage_proj_mail_categories.php	Wed Sep 15 18:03:32 2004
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_activate	= gpc_get_string( 'categories' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_categories( $f_project_id, $f_activate );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.1.orig/manage_proj_mail_delete.php mantis-0.19.1/manage_proj_mail_delete.php
--- mantis-0.19.1.orig/manage_proj_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/manage_proj_mail_delete.php	Wed Sep 15 17:50:34 2004
@@ -0,0 +1,42 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_delete( $f_project_id );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.1.orig/manage_proj_mail_update.php mantis-0.19.1/manage_proj_mail_update.php
--- mantis-0.19.1.orig/manage_proj_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/manage_proj_mail_update.php	Wed Sep 15 17:50:31 2004
@@ -0,0 +1,58 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+
+	echo $f_project_id;
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+	}
+
+	mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.1.orig/sql/bug_report_mail.sql mantis-0.19.1/sql/bug_report_mail.sql
--- mantis-0.19.1.orig/sql/bug_report_mail.sql	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.1/sql/bug_report_mail.sql	Sun Nov 21 18:45:09 2004
@@ -0,0 +1,11 @@
+ALTER TABLE `mantis_project_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_categories` ENUM( '0', '1' ) DEFAULT '0' NOT NULL ;
+
+ALTER TABLE `mantis_project_category_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ;
+
diff -Nur mantis-0.19.1.orig/sql/db_generate.sql mantis-0.19.1/sql/db_generate.sql
--- mantis-0.19.1.orig/sql/db_generate.sql	Sat Nov  6 13:07:30 2004
+++ mantis-0.19.1/sql/db_generate.sql	Sun Nov 21 18:43:25 2004
@@ -330,6 +330,9 @@
   project_id int(7) unsigned NOT NULL default '0',
   category varchar(64) NOT NULL default '',
   user_id int(7) unsigned NOT NULL default '0',
+  pop3_host varchar( 255 ) default NULL,
+  pop3_user varchar( 255 ) default NULL,
+  pop3_pass varchar( 255 ) default NULL,
   PRIMARY KEY  (project_id,category)
 ) TYPE=MyISAM;
 
@@ -379,6 +382,10 @@
   access_min int(2) NOT NULL default '10',
   file_path varchar(250) NOT NULL default '',
   description text NOT NULL,
+  pop3_host varchar( 255 ) default NULL,
+  pop3_user varchar( 255 ) default NULL,
+  pop3_pass varchar( 255 ) default NULL,
+  pop3_cateories enum( '0', '1' ) NOT NULL default '0',
   PRIMARY KEY  (id),
   UNIQUE KEY name (name),
   KEY id (id)
mantis-0.19.1-mime.patch (38,514 bytes)   
mantis-0.19.2.patch (39,297 bytes)   
diff -Nur mantis-0.19.2.orig/bug_report_mail.php mantis-0.19.2/bug_report_mail.php
--- mantis-0.19.2.orig/bug_report_mail.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.2/bug_report_mail.php	Tue Dec 21 17:45:44 2004
@@ -0,0 +1,33 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	# This page receives an E-Mail via POP3 and generates an Report
+	header("Content-type: text/plain");
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'string_api.php' );
+	require_once( $t_core_path . 'bug_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$t_mailaccounts = mail_get_accounts();
+
+	foreach ($t_mailaccounts as $t_mailaccount) {
+		$t_mails = mail_get_all_mails($t_mailaccount);
+		foreach ($t_mails as $t_mail)
+		{
+			$GLOBALS['g_cache_current_user_id'] = mail_get_user( $t_mail['From'] );
+                        mail_add_bug($t_mail, $t_mailaccount);
+		}
+	}
+?>
+
diff -Nur mantis-0.19.2.orig/config_defaults_inc.php mantis-0.19.2/config_defaults_inc.php
--- mantis-0.19.2.orig/config_defaults_inc.php	Sat Dec 11 08:21:52 2004
+++ mantis-0.19.2/config_defaults_inc.php	Sat Dec 25 14:54:13 2004
@@ -1474,4 +1474,30 @@
 	# NOTE: These are meaningless under Windows! Just ignore them!
 	$g_dot_tool							= '/usr/bin/dot';
 	$g_neato_tool						= '/usr/bin/neato';
-?>
\ No newline at end of file
+
+	######################
+	# Mail Reporting
+	######################
+
+	# --- mail reporting settings -----
+	# This tells Mantis to report all the Mail with only one account
+	$g_mail_use_reporter	= ON;
+
+	# The account's name for mail reporting
+	# Also used for fallback if a user is not found in database
+	$g_mail_reporter	= 'Mail';
+
+	# Signup new users automatically (possible security risk!)
+	# Default is OFF, ignored if mail_use_reporter is ON
+	$g_mail_auto_signup	= OFF;
+
+	# Write complete mail into the "Additional Information"
+	$g_mail_additional	= OFF;
+
+	# Parse MIME mails (may require a lot of memory)
+	$g_mail_parse_mime	= OFF;
+
+	# How many mails should be fetched at the same time
+	# If big mails with attachments should be received, specify only one
+	$g_mail_fetch_max	= 1;
+?>
diff -Nur mantis-0.19.2.orig/core/category_api.php mantis-0.19.2/core/category_api.php
--- mantis-0.19.2.orig/core/category_api.php	Thu Apr  8 20:04:54 2004
+++ mantis-0.19.2/core/category_api.php	Tue Dec 21 17:45:44 2004
@@ -206,7 +206,7 @@
 
 		$t_project_category_table = config_get( 'mantis_project_category_table' );
 
-		$query = "SELECT category, user_id
+		$query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass
 				FROM $t_project_category_table
 				WHERE project_id='$c_project_id'
 				ORDER BY category";
@@ -221,4 +221,4 @@
 
 		return $rows;
 	}
-?>
\ No newline at end of file
+?>
diff -Nur mantis-0.19.2.orig/core/file_api.php mantis-0.19.2/core/file_api.php
--- mantis-0.19.2.orig/core/file_api.php	Sun Oct 17 03:58:58 2004
+++ mantis-0.19.2/core/file_api.php	Tue Dec 21 17:45:44 2004
@@ -509,7 +509,7 @@
 			trigger_error( ERROR_DUPLICATE_FILE, ERROR );
 		}  
 
-		if ( is_uploaded_file( $p_tmp_file ) ) {
+		if ( is_uploaded_file( $p_tmp_file ) || $GLOBALS['_mail_file_']  == $p_file_name ) {
 			if ( 'bug' == $p_table ) {
 				$t_project_id	= bug_get_field( $p_bug_id, 'project_id' );
 				$t_bug_id		= bug_format_id( $p_bug_id );
diff -Nur mantis-0.19.2.orig/core/mail_api.php mantis-0.19.2/core/mail_api.php
--- mantis-0.19.2.orig/core/mail_api.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.2/core/mail_api.php	Sat Dec 25 14:48:34 2004
@@ -0,0 +1,435 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
+
+	require_once( $t_core_dir . 'bug_api.php' );
+	require_once( $t_core_dir . 'bugnote_api.php' );
+	require_once( $t_core_dir . 'user_api.php' );
+	require_once( $t_core_dir . 'project_api.php' );
+	require_once( $t_core_dir . 'file_api.php' );
+
+	# This page receives an E-Mail via POP3 and generates an Report
+
+	require_once( 'Net/POP3.php' );
+	require_once( 'Mail/mimeDecode.php' );
+
+	# --------------------
+	# Return mail account data for the specified project
+	function mail_get_account_data( $p_project_id ) {
+		$v_project_id = db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories
+				FROM $t_project_table 
+				WHERE id='$v_project_id'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data for a project
+	function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_pop3_host	= db_prepare_string( $p_pop3_host );
+		$v_pop3_user	= db_prepare_string( $p_pop3_user );
+		$v_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+			 	SET pop3_host='$v_pop3_host',
+				pop3_user='$v_pop3_user',
+				pop3_pass='$v_pop3_pass'
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data from a project
+	function mail_delete( $p_project_id ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Activate the 'Mail per Category' feature for a project
+	function mail_categories( $p_project_id, $p_active ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		if ($p_active == 'On') {
+			$v_active = 1;
+		} else {
+			$v_active = 0;
+		}
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_categories='$v_active'
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Return mail account data for the specified project and category
+	function mail_category_get_account_data( $p_project_id, $p_category ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass
+				FROM $t_project_category_table 
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data for a category
+	function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+		$v_pop3_host	= db_prepare_string( $p_pop3_host );
+		$v_pop3_user	= db_prepare_string( $p_pop3_user );
+		$v_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host='$v_pop3_host',
+				pop3_user='$v_pop3_user',
+				pop3_pass='$v_pop3_pass'
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data for a category
+	function mail_category_delete( $p_project_id, $p_category ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+		
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# return all mailaccounts
+	#  return an empty array if there are no
+	function mail_get_accounts() {
+		$v_accounts = array();
+		$t_projects = mail_project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_categories']) {
+				$v_categories = mail_categories_get_all_rows( $t_project['id'] );
+				$v_accounts = array_merge($v_accounts, $v_categories);
+			} else {
+				array_push($v_accounts, $t_project);
+			}
+		}
+
+		return $v_accounts;
+	}
+
+	# --------------------
+	# return all projects with valid data for mail access
+	#  return an empty array if there are no such projects
+	function mail_project_get_all_rows() {
+		$v_projects = array();
+		$t_projects = project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_host'] || $t_project['pop3_categories']) {
+				array_push($v_projects, $t_project);
+			}
+		}
+
+		return $v_projects;
+	}
+
+	# --------------------
+	# return all categories from a project with valid data for mail access
+	#  return an empty array if there are no such categories
+	function mail_categories_get_all_rows( $p_project_id ) {
+		$v_categories = array();
+		$t_categories = category_get_all_rows( $p_project_id );
+
+		foreach ($t_categories as $t_category) {
+			if ($t_category['pop3_host']) {
+				$t_category['id'] = $p_project_id;
+				array_push($v_categories, $t_category);
+			}
+		}
+
+		return $v_categories;
+	}
+
+	# --------------------
+	# return all mails for an account
+	#  return an empty array if there are no new mails
+	function mail_get_all_mails( $p_account ) {
+		$t_mail_parse_mime	= config_get( 'mail_parse_mime' );
+		$t_mail_fetch_max	= config_get( 'mail_fetch_max' );
+		$t_mail_additional	= config_get( 'mail_additional' );
+		
+		$v_mails = array();
+		$t_pop3 = &new Net_POP3();
+		$t_pop3_host = $p_account['pop3_host'];
+		$t_pop3_user = $p_account['pop3_user'];
+		$t_pop3_password = $p_account['pop3_pass'];
+		$t_pop3->connect($t_pop3_host, 110);
+		$t_pop3->login($t_pop3_user, $t_pop3_password);
+
+		if (0 == $t_pop3->numMsg()) {
+			return $v_mails;
+		}
+		for ($i = 1; $i <= $t_mail_fetch_max; $i++) {
+			$t_headers = $t_pop3->getParsedHeaders($i);
+			$t_msg = $t_pop3->getMsg($i);
+
+			if (true == $t_mail_parse_mime &&
+			    true == isset( $t_headers['MIME-Version'] ) ) {
+				$t_mail = mail_parse_content( $t_msg );
+			} else {
+				$t_mail = $t_headers;
+				$t_mail['X-Mantis-Body'] = $t_pop3->getBody($i);
+			}
+
+			if (true == $t_mail_additional) {
+				$t_mail['X-Mantis-Complete'] = $t_msg;
+			}
+
+			array_push($v_mails, $t_mail);
+			$t_pop3->deleteMsg($i);
+		}
+
+		$t_pop3->disconnect();
+		return $v_mails;
+	}
+
+	# --------------------
+	# return the mail parsed for Mantis
+	function mail_parse_content ( $p_mail ) {
+                $v_mail = array ();
+		$t_decoder = new Mail_mimeDecode($p_mail);
+                $t_params['include_bodies'] = true;
+                $t_params['decode_bodies']  = true;
+                $t_params['decode_headers'] = true;
+		$t_structure = $t_decoder->decode($t_params);
+                $v_mail['To'] = $t_structure->headers['to'];
+                $v_mail['From'] = $t_structure->headers['from'];
+                $v_mail['Subject'] = $t_structure->headers['subject'];
+                if (is_array($t_structure->parts))
+                {
+                    $t_parts = mail_parse_parts( $t_structure->parts );
+                }
+                else
+                {
+                    $t_parts = array ( mail_parse_part( $t_structure ) );
+                }
+                if ($t_parts[0]['Content-Type'] == 'text/plain') {
+                    $t_body = array_shift($t_parts);
+                }
+                else
+                {
+                    $t_body['Body'] = "It seems, there is no text... :-o";
+                }
+                $v_mail['X-Mantis-Parts'] = $t_parts;
+                $v_mail['X-Mantis-Body'] = $t_body['Body'];
+		
+		return $v_mail;
+	}
+
+	# --------------------
+	# return the parsed parts from the mail
+	function mail_parse_parts ( $p_parts ) {
+                $v_parts = array ();
+                foreach ( $p_parts as $t_part ) {
+                    array_push($v_parts, mail_parse_part( $t_part ));
+                }
+                
+                return $v_parts;
+        }
+
+	# --------------------
+	# return one parsed part
+	function mail_parse_part ( $p_part ) {
+                $v_part = array ();
+                $v_part['Content-Type'] = $p_part->ctype_primary."/".$p_part->ctype_secondary;
+                $v_part['Name'] = $p_part->ctype_parameters['name'];
+                $v_part['Body'] = $p_part->body;
+
+                return $v_part;
+        }
+
+	# --------------------
+	# return the mailadress from the mail's 'From'
+	function mail_parse_address ( $p_mailaddress ) {
+		if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) {
+			$v_mailaddress = $matches[1];
+		}
+
+		return $v_mailaddress;
+	}
+
+	# --------------------
+	# return the a valid username from an email address
+	function mail_user_name_from_address ( $p_mailaddress ) {
+		return preg_replace("/[@\.-]/", '_', $p_mailaddress);
+	}
+
+	# --------------------
+	# return true if there is a valid mantis bug referernce in subject
+	function mail_is_a_bugnote ( $p_mail_subject ) {
+		return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_mail_subject);
+	}
+
+	# --------------------
+	# return the bug's id from the subject
+	function mail_get_bug_id_from_subject ( $p_mail_subject ) {
+		preg_match("/\[([A-Za-z0-9-_\.]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches);
+
+		return $v_matches[2];
+	}
+
+	# --------------------
+	# return the user id for the mail reporting user
+	function mail_get_user ($p_mailaddress) {
+		$t_mail_use_reporter	= config_get( 'mail_use_reporter' );
+		$t_mail_auto_signup	= config_get( 'mail_auto_signup' );
+		$t_mail_reporter	= config_get( 'mail_reporter' );
+		
+		$v_mailaddress = mail_parse_address( $p_mailaddress );
+
+		if ( $t_mail_use_reporter ) {
+			// Always report as mail_reporter
+			$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+		} else {
+			// Try to get the reporting users id
+			$t_reporter_id = user_get_id_by_mail ( $v_mailaddress );
+			if ( ! $t_reporter_id && $t_mail_auto_signup ) {
+				// So, we've to sign up a new user...
+				$t_user_name = mail_user_name_from_address ( $v_mailaddress );
+				user_signup($t_user_name, $v_mailaddress);
+				$t_reporter_id = user_get_id_by_name($t_user_name);
+			} elseif ( ! $t_reporter_id ) {
+				// Fall back to the default mail_reporter
+				$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+			}
+		}
+
+		// dirty: Set the identified user's id
+		// required if bug_report_mail is run via command line
+		$GLOBAL['g_cache_current_user_id'] = $t_reporter_id;
+
+		return $t_reporter_id;
+	}
+
+	# --------------------
+	# Very dirty: Adds a file to a bug.
+	function mail_add_file( $p_bug_id, $p_part ) {
+            $GLOBALS['_mail_file_'] = $p_part['Name'];
+            $t_file_name = '/tmp/'.$p_part['Name'];
+            file_put_contents($t_file_name, $p_part['Body']);
+            file_add($p_bug_id, $t_file_name,  $p_part['Name'], $p_part['Content-Type'], 'bug');
+            unlink($t_file_name);
+        }
+
+	# --------------------
+	# Adds a bug which is reported via email
+	# Taken from bug_report.php and 
+	function mail_add_bug( $p_mail, $p_account ) {
+		$t_bug_data = new BugData;
+		$t_bug_data->build			= gpc_get_string( 'build', '' );
+		$t_bug_data->platform			= gpc_get_string( 'platform', '' );
+		$t_bug_data->os				= gpc_get_string( 'os', '' );
+		$t_bug_data->os_build			= gpc_get_string( 'os_build', '' );
+		$t_bug_data->version			= gpc_get_string( 'product_version', '' );
+		$t_bug_data->profile_id			= gpc_get_int( 'profile_id', 0 );
+		$t_bug_data->handler_id			= gpc_get_int( 'handler_id', 0 );
+		$t_bug_data->view_state			= gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
+
+		if ( $p_account['category']) {
+			$t_bug_data->category			= gpc_get_string( 'category', $p_account['category'] );
+		} else {
+			$t_bug_data->category			= gpc_get_string( 'category', '' );
+		}
+		$t_bug_data->reproducibility		= 10;
+		$t_bug_data->severity			= 50;
+		$t_bug_data->priority			= gpc_get_int( 'priority', NORMAL );
+		$t_bug_data->summary			= $p_mail['Subject'];
+		$t_bug_data->description		= $p_mail['X-Mantis-Body'];
+		$t_bug_data->steps_to_reproduce		= gpc_get_string( 'steps_to_reproduce', '' );
+		$t_bug_data->additional_information	= $p_mail['X-Mantis-Complete'];
+
+		$t_bug_data->project_id			= $p_account['id'];
+
+		$t_bug_data->reporter_id		= mail_get_user( $p_mail['From'] );
+
+                if (mail_is_a_bugnote($p_mail['Subject'])) {
+			# Add a bug note
+			$t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] );
+			if ( ! bug_is_readonly( $t_bug_id ) ) {
+				bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] );
+				email_bugnote_add ( $t_bug_id );
+			}
+		} else	{
+			# Create the bug
+			$t_bug_id = bug_create( $t_bug_data );
+			email_new_bug( $t_bug_id );
+		}
+                # Add files
+		foreach ($p_mail['X-Mantis-Parts'] as $part) {
+			mail_add_file ( $t_bug_id, $part );
+		}
+
+	}
+
+?>
diff -Nur mantis-0.19.2.orig/core/user_api.php mantis-0.19.2/core/user_api.php
--- mantis-0.19.2.orig/core/user_api.php	Fri Nov 19 13:29:00 2004
+++ mantis-0.19.2/core/user_api.php	Tue Dec 21 17:45:44 2004
@@ -477,6 +477,27 @@
 		}
 	}
 
+	# get a user id from an mail address
+	#  return false if the mail address does not exist
+	function user_get_id_by_mail( $p_mailaddress ) {
+		
+		$c_mailaddress = db_prepare_string( $p_mailaddress );
+
+		$t_user_table = config_get( 'mantis_user_table' );
+
+		$query = "SELECT id
+				  FROM $t_user_table
+				  WHERE email='$c_mailaddress'";
+		$result = db_query( $query );
+
+		if ( 0 == db_num_rows( $result ) ) {
+			return false;
+		} else {
+			return db_result( $result );
+		}
+	}
+
+	# --------------------
 	# --------------------
 	# return all data associated with a particular user name
 	#  return false if the username does not exist
diff -Nur mantis-0.19.2.orig/doc/README.bug_report_mail mantis-0.19.2/doc/README.bug_report_mail
--- mantis-0.19.2.orig/doc/README.bug_report_mail	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.2/doc/README.bug_report_mail	Sun Dec 26 14:33:20 2004
@@ -0,0 +1,92 @@
+The current version of bug_report_mail support plain text and MIME
+encoded e-mails via POP3 Mailaccounts with PEAR's Net_POP3 package.
+
+bug_report_mail is able to recognize if mail is a reply to an already opened
+bug and adds the content as a bugnote.
+
+If you are alway running Mantis you have to alter your projects table
+with the sql/bug_report_mail.sql script.
+If not, you can create the database tables in the way described in
+the doc/INSTALL file.
+
+This patch changes the following files:
+    core/category_api.php
+    core/file_api.php
+    core/user_api.php
+    sql/db_generate.sql
+    config_defaults_inc.php
+    manage_proj_cat_edit_page.php
+    manage_proj_edit_page.php
+These files are new:
+    core/mail_api.php
+    doc/README.bug_report_mail
+    sql/bug_report_mail.sql
+    bug_report_mail.php
+    manage_proj_cat_mail_delete.php
+    manage_proj_cat_mail_update.php
+    manage_proj_mail_categories.php
+    manage_proj_mail_delete.php
+    manage_proj_mail_update.php
+
+After installing this patch, you can add a POP3 server's hostname
+and authentication data for each of your projects with the project edit form.
+
+There are two ways to receive mail with bug_report_mail:
+The secure (and default) way is to use a standard reporting user:
+You have to create a reporter account, for example 'Mail'.
+The name for this reporter account you have to write in your config_inc.php file:
+	$g_mail_reporter = "Mail";
+and then, bug_report_mail must be informed to behave like this:
+	$g_mail_use_reporter = ON;
+
+The other way is to signup new user accounts automatically.
+For using this, you have to change this
+	$g_mail_auto_signup     = OFF;
+from OFF to ON.
+Now, bug_report_mail will look for an user named like the mail's sender
+or an user which mail adress is identical.
+If no user is found, then a new account will be created.
+The new user's name will be the mail address.
+
+This could be used for attacks, but there is no other way in the moment.
+
+If you like to parse MIME encoded mails, you have to install the PEAR
+Mail_Mime package and set
+	$g_mail_parse_mime	= OFF;
+from OFF to ON.
+
+For debugging controls there is the switch
+	$g_mail_additional	= OFF;
+which puts the complete message into the Additional Information field,
+if it is activated.
+
+In this case you should decrease the amount of fetched messages via
+	$g_mail_fetch_max	= 1;
+because the mime decoding needs a lot of memory.
+
+After this, bug_report_mail can be used via cron like this:
+
+*/5 *   *   *   * lynx --dump http://mantis.homepage.com/bug_report_mail.php
+or via command line interface
+*/5 *   *   *   * /usr/local/bin/php /path/to/mantis/bug_report_mail.php
+
+This line fetch bug reports from via POP3 every 5 minutes. 
+
+This addon is distributed under the same conditions as Mantis itself.
+
+Gerrit Beine, August 2004
+
+Changelog:
+Dec 2004:
+	- update to Mantis 0.19.2
+	- add config: g_mail_parse_mime
+	- add config: g_mail_additional
+	- add config: g_mail_fetch_max
+	- make it working via CLI
+Nov 2004:
+	- update to Mantis 0.19.1
+	- add support for MIME decoding
+Sep 2004:
+	- update to Mantis 0.19.0
+Aug 2004:
+	- create patch for Mantis 0.18.3
diff -Nur mantis-0.19.2.orig/manage_proj_cat_edit_page.php mantis-0.19.2/manage_proj_cat_edit_page.php
--- mantis-0.19.2.orig/manage_proj_cat_edit_page.php	Mon Apr 12 23:04:36 2004
+++ mantis-0.19.2/manage_proj_cat_edit_page.php	Tue Dec 21 17:45:44 2004
@@ -15,6 +15,7 @@
 	$t_core_path = config_get( 'core_path' );
 	
 	require_once( $t_core_path.'category_api.php' );
+	require_once( $t_core_path.'mail_api.php' );
 ?>
 <?php
 	$f_project_id	= gpc_get_int( 'project_id' );
@@ -24,6 +25,10 @@
 
 	$t_row = category_get_row( $f_project_id, $f_category );
 	$t_assigned_to = $t_row['user_id'];
+	$t_mail = mail_get_account_data( $f_project_id );
+	if ( $t_mail['pop3_categories'] ) {
+		$t_category_mail = mail_category_get_account_data( $f_project_id, $f_category );
+	}
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -83,5 +88,60 @@
 		<input type="submit" class="button" value="<?php echo lang_get( 'delete_category_button' ) ?>" />
 	</form>
 </div>
+
+<?php  if ( $t_mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_cat_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Category Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_cat_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<?php } ?>
 
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.2.orig/manage_proj_cat_mail_delete.php mantis-0.19.2/manage_proj_cat_mail_delete.php
--- mantis-0.19.2.orig/manage_proj_cat_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.2/manage_proj_cat_mail_delete.php	Tue Dec 21 17:45:44 2004
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_category_delete( $f_project_id, $f_category );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.2.orig/manage_proj_cat_mail_update.php mantis-0.19.2/manage_proj_cat_mail_update.php
--- mantis-0.19.2.orig/manage_proj_cat_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.2/manage_proj_cat_mail_update.php	Tue Dec 21 17:45:44 2004
@@ -0,0 +1,58 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+	}
+
+	mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.2.orig/manage_proj_edit_page.php mantis-0.19.2/manage_proj_edit_page.php
--- mantis-0.19.2.orig/manage_proj_edit_page.php	Wed Sep 22 12:15:34 2004
+++ mantis-0.19.2/manage_proj_edit_page.php	Tue Dec 21 17:45:44 2004
@@ -18,6 +18,7 @@
 	require_once( $t_core_path . 'version_api.php' );
 	require_once( $t_core_path . 'custom_field_api.php' );
 	require_once( $t_core_path . 'icon_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
 ?>
 <?php
 	$f_project_id = gpc_get_int( 'project_id' );
@@ -25,6 +26,7 @@
 	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
 
 	$row = project_get_row( $f_project_id );
+	$mail = mail_get_account_data( $f_project_id );
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -551,4 +553,74 @@
 	</table>
 </div>
 
+<?php  if ( ! $mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<br />
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="On" />
+		<input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } else { ?>
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="Off" />
+		<input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } ?>
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.2.orig/manage_proj_mail_categories.php mantis-0.19.2/manage_proj_mail_categories.php
--- mantis-0.19.2.orig/manage_proj_mail_categories.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.2/manage_proj_mail_categories.php	Tue Dec 21 17:45:44 2004
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_activate	= gpc_get_string( 'categories' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_categories( $f_project_id, $f_activate );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.2.orig/manage_proj_mail_delete.php mantis-0.19.2/manage_proj_mail_delete.php
--- mantis-0.19.2.orig/manage_proj_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.2/manage_proj_mail_delete.php	Tue Dec 21 17:45:44 2004
@@ -0,0 +1,42 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_delete( $f_project_id );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.2.orig/manage_proj_mail_update.php mantis-0.19.2/manage_proj_mail_update.php
--- mantis-0.19.2.orig/manage_proj_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.2/manage_proj_mail_update.php	Tue Dec 21 17:45:44 2004
@@ -0,0 +1,58 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+
+	echo $f_project_id;
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+        }
+	}
+
+	mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.2.orig/sql/bug_report_mail.sql mantis-0.19.2/sql/bug_report_mail.sql
--- mantis-0.19.2.orig/sql/bug_report_mail.sql	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.2/sql/bug_report_mail.sql	Sat Dec 25 17:05:41 2004
@@ -0,0 +1,11 @@
+ALTER TABLE `mantis_project_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_categories` ENUM( '0', '1' ) DEFAULT '0' NOT NULL ;
+
+ALTER TABLE `mantis_project_category_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ;
+
diff -Nur mantis-0.19.2.orig/sql/db_generate.sql mantis-0.19.2/sql/db_generate.sql
--- mantis-0.19.2.orig/sql/db_generate.sql	Sat Nov  6 12:07:30 2004
+++ mantis-0.19.2/sql/db_generate.sql	Sat Dec 25 17:05:18 2004
@@ -330,6 +330,9 @@
   project_id int(7) unsigned NOT NULL default '0',
   category varchar(64) NOT NULL default '',
   user_id int(7) unsigned NOT NULL default '0',
+  pop3_host varchar( 255 ) default NULL,
+  pop3_user varchar( 255 ) default NULL,
+  pop3_pass varchar( 255 ) default NULL,
   PRIMARY KEY  (project_id,category)
 ) TYPE=MyISAM;
 
@@ -379,6 +382,10 @@
   access_min int(2) NOT NULL default '10',
   file_path varchar(250) NOT NULL default '',
   description text NOT NULL,
+  pop3_host varchar( 255 ) default NULL,
+  pop3_user varchar( 255 ) default NULL,
+  pop3_pass varchar( 255 ) default NULL,
+  pop3_categories enum( '0', '1' ) NOT NULL default '0',
   PRIMARY KEY  (id),
   UNIQUE KEY name (name),
   KEY id (id)
@@ -881,3 +888,5 @@
 #
 
 INSERT INTO mantis_user_table VALUES (1, 'administrator', '', 'admin', '63a9f0ea7bb98050796b649e85481845', '2003-02-16 02:03:48', '2004-07-08 23:59:22', 1, 1, 90, 3, 0, 0, CONCAT(MD5(RAND()),MD5(NOW())));
+INSERT INTO mantis_user_table VALUES (2, 'Mail', 'Mail Reporter', 'nomail', 'a268462c3c679a9027658c5aa723f97c', '2004-12-25 15:41:49', '2004-12-25 15:41:49', 1, 0, 25, 0, 0, 0, CONCAT(MD5(RAND()),MD5(NOW())));
+
mantis-0.19.2.patch (39,297 bytes)   
mantis-0.19.2-additional-fixes.patch (1,416 bytes)   
diff -uNr mantis-0.19.2/core/mail_api.php mantis.new/core/mail_api.php
--- mantis-0.19.2/core/mail_api.php	2005-02-12 14:02:17.591258328 +0100
+++ mantis.new/core/mail_api.php	2005-02-12 14:20:29.676236176 +0100
@@ -235,7 +235,8 @@
 			$t_msg = $t_pop3->getMsg($i);
 
 			if (true == $t_mail_parse_mime &&
-			    true == isset( $t_headers['MIME-Version'] ) ) {
+			    true == isset( $t_headers['MIME-Version'] ) &&
+			    'multipart' == strtolower(substr($t_headers['Content-Type'],0,9) ) ) {
 				$t_mail = mail_parse_content( $t_msg );
 			} else {
 				$t_mail = $t_headers;
@@ -274,7 +275,7 @@
                 {
                     $t_parts = array ( mail_parse_part( $t_structure ) );
                 }
-                if ($t_parts[0]['Content-Type'] == 'text/plain') {
+		if (strtolower($t_parts[0]['Content-Type']) == 'text/plain') {
                     $t_body = array_shift($t_parts);
                 }
                 else
@@ -405,7 +406,7 @@
 		$t_bug_data->severity			= 50;
 		$t_bug_data->priority			= gpc_get_int( 'priority', NORMAL );
 		$t_bug_data->summary			= $p_mail['Subject'];
-		$t_bug_data->description		= $p_mail['X-Mantis-Body'];
+		$t_bug_data->description		= "Report from: ".$p_mail['From']."\n\n".$p_mail['X-Mantis-Body'];
 		$t_bug_data->steps_to_reproduce		= gpc_get_string( 'steps_to_reproduce', '' );
 		$t_bug_data->additional_information	= $p_mail['X-Mantis-Complete'];
 
mantis-1.0.0rc1.patch (44,881 bytes)   
diff -Nur mantis-1.0.0rc1/admin/bug_report_mail.sql mantis/admin/bug_report_mail.sql
--- mantis-1.0.0rc1/admin/bug_report_mail.sql	Thu Jan  1 01:00:00 1970
+++ mantis/admin/bug_report_mail.sql	Sun Aug  7 10:48:26 2005
@@ -0,0 +1,11 @@
+ALTER TABLE `mantis_project_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_categories` ENUM( '0', '1' ) DEFAULT '0' NOT NULL ;
+
+ALTER TABLE `mantis_project_category_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ;
+
diff -Nur mantis-1.0.0rc1/admin/schema.php mantis/admin/schema.php
--- mantis-1.0.0rc1/admin/schema.php	Wed Jul  6 01:48:48 2005
+++ mantis/admin/schema.php	Sun Aug  7 10:55:13 2005
@@ -192,7 +192,10 @@
 $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_project_category_table'),"
   project_id 		 I  UNSIGNED NOTNULL PRIMARY DEFAULT '0',
   category 		C(64) NOTNULL PRIMARY DEFAULT \" '' \",
-  user_id 		 I  UNSIGNED NOTNULL DEFAULT '0'
+  user_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  pop3_host		C( 255 ) NULL,
+  pop3_user		C( 255 ) NULL,
+  pop3_pass		C( 255 ) NULL
 ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS')));
 
 $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_project_file_table'),"
@@ -222,7 +225,11 @@
   view_state 		I2 NOTNULL DEFAULT '10',
   access_min 		I2 NOTNULL DEFAULT '10',
   file_path 		C(250) NOTNULL DEFAULT \" '' \",
-  description 		XS NOTNULL
+  description 		XS NOTNULL,
+  pop3_host		C( 255 ) NULL,
+  pop3_user		C( 255 ) NULL,
+  pop3_pass		C( 255 ) NULL,
+  pop3_categories	L NOTNULL DEFAULT '0'
 ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS')));
 $upgrade[] = Array('CreateIndexSQL',Array('idx_project_id',config_get('mantis_project_table'),'id'));
 $upgrade[] = Array('CreateIndexSQL',Array('idx_project_name',config_get('mantis_project_table'),'name',Array('UNIQUE')));
diff -Nur mantis-1.0.0rc1/bug_report_mail.php mantis/bug_report_mail.php
--- mantis-1.0.0rc1/bug_report_mail.php	Thu Jan  1 01:00:00 1970
+++ mantis/bug_report_mail.php	Sun Aug  7 10:13:09 2005
@@ -0,0 +1,33 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	# This page receives an E-Mail via POP3 and generates an Report
+	header("Content-type: text/plain");
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'string_api.php' );
+	require_once( $t_core_path . 'bug_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$t_mailaccounts = mail_get_accounts();
+
+	foreach ($t_mailaccounts as $t_mailaccount) {
+		$t_mails = mail_get_all_mails($t_mailaccount);
+		foreach ($t_mails as $t_mail)
+		{
+			$GLOBALS['g_cache_current_user_id'] = mail_get_user( $t_mail['From'] );
+                        mail_add_bug($t_mail, $t_mailaccount);
+		}
+	}
+?>
+
diff -Nur mantis-1.0.0rc1/config_defaults_inc.php mantis/config_defaults_inc.php
--- mantis-1.0.0rc1/config_defaults_inc.php	Sat Jul 23 01:37:06 2005
+++ mantis/config_defaults_inc.php	Sun Aug  7 10:14:42 2005
@@ -1611,4 +1611,33 @@
 	#   )
 	# );
 	$g_custom_group_actions = array();
+
+
+	######################
+	# Mail Reporting
+	######################
+
+	# --- mail reporting settings -----
+	# This tells Mantis to report all the Mail with only one account
+	$g_mail_use_reporter	= ON;
+
+	# The account's name for mail reporting
+	# Also used for fallback if a user is not found in database
+	$g_mail_reporter	= 'Mail';
+
+	# Signup new users automatically (possible security risk!)
+	# Default is OFF, ignored if mail_use_reporter is ON
+	$g_mail_auto_signup	= OFF;
+
+	# Write complete mail into the "Additional Information"
+	$g_mail_additional	= OFF;
+
+	# Parse MIME mails (may require a lot of memory)
+	$g_mail_parse_mime	= OFF;
+
+	# How many mails should be fetched at the same time
+	# If big mails with attachments should be received, specify only one
+	$g_mail_fetch_max	= 1;
+
 ?>
+
diff -Nur mantis-1.0.0rc1/config_inc.php mantis/config_inc.php
--- mantis-1.0.0rc1/config_inc.php	Thu Jan  1 01:00:00 1970
+++ mantis/config_inc.php	Fri Apr 29 15:24:10 2005
@@ -0,0 +1,53 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# Copyright (C) 2002 - 2005  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id: config_inc.php.sample,v 1.16 2005/04/29 13:24:10 vboctor Exp $
+	# --------------------------------------------------------
+
+	# This sample file contains the essential files that you MUST
+	# configure to your specific settings.  You may override settings
+	# from config_defaults_inc.php by assigning new values in this file
+
+	# Rename this file to config_inc.php after configuration.
+
+	###########################################################################
+	# CONFIGURATION VARIABLES
+	###########################################################################
+
+	# In general the value OFF means the feature is disabled and ON means the
+	# feature is enabled.  Any other cases will have an explanation.
+
+	# Look in http://manual.mantisbt.org/ or config_defaults_inc.php for more
+	# detailed comments.
+
+	# --- database variables ---------
+
+	# set these values to match your setup
+	$g_hostname      = "localhost";
+	$g_db_username   = "root";
+	$g_db_password   = "";
+	$g_database_name = "bugtracker";
+	$g_db_type       = "mysql";
+
+	# --- email variables -------------
+	$g_administrator_email  = 'administrator@example.com';
+	$g_webmaster_email      = 'webmaster@example.com';
+
+	# the "From: " field in emails
+	$g_from_email           = 'noreply@example.com';
+
+	# the return address for bounced mail
+	$g_return_path_email    = 'admin@example.com';
+
+	# --- file upload settings --------
+	# This is the master setting to disable *all* file uploading functionality
+	#
+	# The default value is ON but you must make sure file uploading is enabled
+	#  in PHP as well.  You may need to add "file_uploads = TRUE" to your php.ini.
+	$g_allow_file_upload	= ON;
+?>
\ No newline at end of file
diff -Nur mantis-1.0.0rc1/core/category_api.php mantis/core/category_api.php
--- mantis-1.0.0rc1/core/category_api.php	Sat Feb 12 21:01:10 2005
+++ mantis/core/category_api.php	Sun Aug  7 10:05:49 2005
@@ -206,7 +206,7 @@
 
 		$t_project_category_table = config_get( 'mantis_project_category_table' );
 
-		$query = "SELECT category, user_id
+		$query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass
 				FROM $t_project_category_table
 				WHERE project_id='$c_project_id'
 				ORDER BY category";
diff -Nur mantis-1.0.0rc1/core/mail_api.php mantis/core/mail_api.php
--- mantis-1.0.0rc1/core/mail_api.php	Thu Jan  1 01:00:00 1970
+++ mantis/core/mail_api.php	Sun Aug  7 11:11:44 2005
@@ -0,0 +1,441 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
+
+	require_once( $t_core_dir . 'bug_api.php' );
+	require_once( $t_core_dir . 'bugnote_api.php' );
+	require_once( $t_core_dir . 'user_api.php' );
+	require_once( $t_core_dir . 'project_api.php' );
+	require_once( $t_core_dir . 'file_api.php' );
+
+	# This page receives an E-Mail via POP3 and generates an Report
+
+	require_once( 'Net/POP3.php' );
+	require_once( 'Mail/mimeDecode.php' );
+
+	# --------------------
+	# Return mail account data for the specified project
+	function mail_get_account_data( $p_project_id ) {
+		$v_project_id = db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories
+				FROM $t_project_table 
+				WHERE id='$v_project_id'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data for a project
+	function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_pop3_host	= db_prepare_string( $p_pop3_host );
+		$v_pop3_user	= db_prepare_string( $p_pop3_user );
+		$v_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+			 	SET pop3_host='$v_pop3_host',
+				pop3_user='$v_pop3_user',
+				pop3_pass='$v_pop3_pass'
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data from a project
+	function mail_delete( $p_project_id ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Activate the 'Mail per Category' feature for a project
+	function mail_categories( $p_project_id, $p_active ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		if ($p_active == 'On') {
+			$v_active = 1;
+		} else {
+			$v_active = 0;
+		}
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_categories='$v_active'
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Return mail account data for the specified project and category
+	function mail_category_get_account_data( $p_project_id, $p_category ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass
+				FROM $t_project_category_table 
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data for a category
+	function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+		$v_pop3_host	= db_prepare_string( $p_pop3_host );
+		$v_pop3_user	= db_prepare_string( $p_pop3_user );
+		$v_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host='$v_pop3_host',
+				pop3_user='$v_pop3_user',
+				pop3_pass='$v_pop3_pass'
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data for a category
+	function mail_category_delete( $p_project_id, $p_category ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+		
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# return all mailaccounts
+	#  return an empty array if there are no
+	function mail_get_accounts() {
+		$v_accounts = array();
+		$t_projects = mail_project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_categories']) {
+				$v_categories = mail_categories_get_all_rows( $t_project['id'] );
+				$v_accounts = array_merge($v_accounts, $v_categories);
+			} else {
+				array_push($v_accounts, $t_project);
+			}
+		}
+
+		return $v_accounts;
+	}
+
+	# --------------------
+	# return all projects with valid data for mail access
+	#  return an empty array if there are no such projects
+	function mail_project_get_all_rows() {
+		$v_projects = array();
+		$t_projects = project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_host'] || $t_project['pop3_categories']) {
+				array_push($v_projects, $t_project);
+			}
+		}
+
+		return $v_projects;
+	}
+
+	# --------------------
+	# return all categories from a project with valid data for mail access
+	#  return an empty array if there are no such categories
+	function mail_categories_get_all_rows( $p_project_id ) {
+		$v_categories = array();
+		$t_categories = category_get_all_rows( $p_project_id );
+
+		foreach ($t_categories as $t_category) {
+			if ($t_category['pop3_host']) {
+				$t_category['id'] = $p_project_id;
+				array_push($v_categories, $t_category);
+			}
+		}
+
+		return $v_categories;
+	}
+
+	# --------------------
+	# return all mails for an account
+	#  return an empty array if there are no new mails
+	function mail_get_all_mails( $p_account ) {
+		$t_mail_parse_mime	= config_get( 'mail_parse_mime' );
+		$t_mail_fetch_max	= config_get( 'mail_fetch_max' );
+		$t_mail_additional	= config_get( 'mail_additional' );
+		
+		$v_mails = array();
+		$t_pop3 = &new Net_POP3();
+		$t_pop3_host = $p_account['pop3_host'];
+		$t_pop3_user = $p_account['pop3_user'];
+		$t_pop3_password = $p_account['pop3_pass'];
+		$t_pop3->connect($t_pop3_host, 110);
+		$t_pop3->login($t_pop3_user, $t_pop3_password);
+
+		if (0 == $t_pop3->numMsg()) {
+			return $v_mails;
+		}
+		for ($i = 1; $i <= $t_mail_fetch_max; $i++) {
+			$t_headers = $t_pop3->getParsedHeaders($i);
+			$t_msg = $t_pop3->getMsg($i);
+
+			if (true == $t_mail_parse_mime &&
+			    true == isset( $t_headers['MIME-Version'] ) &&
+                            'multipart' == strtolower(substr($t_headers['Content-type'],0,9) ) ) {
+				$t_mail = mail_parse_content( $t_msg );
+			} else {
+				$t_mail = $t_headers;
+				$t_mail['X-Mantis-Body'] = $t_pop3->getBody($i);
+			}
+
+			if (true == $t_mail_additional) {
+				$t_mail['X-Mantis-Complete'] = $t_msg;
+			}
+
+			array_push($v_mails, $t_mail);
+			$t_pop3->deleteMsg($i);
+		}
+
+		$t_pop3->disconnect();
+		return $v_mails;
+	}
+
+	# --------------------
+	# return the mail parsed for Mantis
+	function mail_parse_content ( $p_mail ) {
+                $v_mail = array ();
+		$t_decoder = new Mail_mimeDecode($p_mail);
+                $t_params['include_bodies'] = true;
+                $t_params['decode_bodies']  = true;
+                $t_params['decode_headers'] = true;
+		$t_structure = $t_decoder->decode($t_params);
+                $v_mail['To'] = $t_structure->headers['to'];
+                $v_mail['From'] = $t_structure->headers['from'];
+                $v_mail['Subject'] = $t_structure->headers['subject'];
+                if (is_array($t_structure->parts))
+                {
+                    $t_parts = mail_parse_parts( $t_structure->parts );
+                }
+                else
+                {
+                    $t_parts = array ( mail_parse_part( $t_structure ) );
+                }
+                if (strtolower($t_parts[0]['Content-Type']) == 'text/plain' ||
+                    strtolower($t_parts[0]['Content-Type']) == 'text/html' ) {
+                    # $t_body = array_shift($t_parts);
+                    $t_body['Body'] = $t_parts[0]['Body'];
+                }
+                else
+                {
+                    $t_body['Body'] = "It seems, there is no text... :-o";
+                }
+                $v_mail['X-Mantis-Parts'] = $t_parts;
+                $v_mail['X-Mantis-Body'] = $t_body['Body'];
+		
+		return $v_mail;
+	}
+
+	# --------------------
+	# return the parsed parts from the mail
+	function mail_parse_parts ( $p_parts ) {
+                $v_parts = array ();
+                foreach ( $p_parts as $t_part ) {
+                    array_push($v_parts, mail_parse_part( $t_part ));
+                }
+                
+                return $v_parts;
+        }
+
+	# --------------------
+	# return one parsed part
+	function mail_parse_part ( $p_part ) {
+                $v_part = array ();
+                $v_part['Content-Type'] = $p_part->ctype_primary."/".$p_part->ctype_secondary;
+                $v_part['Name'] = $p_part->ctype_parameters['name'];
+                $v_part['Body'] = $p_part->body;
+
+                return $v_part;
+        }
+
+	# --------------------
+	# return the mailadress from the mail's 'From'
+	function mail_parse_address ( $p_mailaddress ) {
+		if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) {
+			$v_mailaddress = $matches[1];
+		}
+
+		return $v_mailaddress;
+	}
+
+	# --------------------
+	# return the a valid username from an email address
+	function mail_user_name_from_address ( $p_mailaddress ) {
+		return preg_replace("/[@\.-]/", '_', $p_mailaddress);
+	}
+
+	# --------------------
+	# return true if there is a valid mantis bug referernce in subject
+	function mail_is_a_bugnote ( $p_mail_subject ) {
+		return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_mail_subject);
+	}
+
+	# --------------------
+	# return the bug's id from the subject
+	function mail_get_bug_id_from_subject ( $p_mail_subject ) {
+		preg_match("/\[([A-Za-z0-9-_\. ]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches);
+
+		return $v_matches[2];
+	}
+
+	# --------------------
+	# return the user id for the mail reporting user
+	function mail_get_user ($p_mailaddress) {
+		$t_mail_use_reporter	= config_get( 'mail_use_reporter' );
+		$t_mail_auto_signup	= config_get( 'mail_auto_signup' );
+		$t_mail_reporter	= config_get( 'mail_reporter' );
+		
+		$v_mailaddress = mail_parse_address( $p_mailaddress );
+
+		if ( $t_mail_use_reporter ) {
+			// Always report as mail_reporter
+			$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+		} else {
+			// Try to get the reporting users id
+			$t_reporter_id = user_get_id_by_mail ( $v_mailaddress );
+			if ( ! $t_reporter_id && $t_mail_auto_signup ) {
+				// So, we've to sign up a new user...
+				$t_user_name = mail_user_name_from_address ( $v_mailaddress );
+				user_signup($t_user_name, $v_mailaddress);
+				$t_reporter_id = user_get_id_by_name($t_user_name);
+			} elseif ( ! $t_reporter_id ) {
+				// Fall back to the default mail_reporter
+				$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+			}
+		}
+
+		// dirty: Set the identified user's id
+		// required if bug_report_mail is run via command line
+		$GLOBAL['g_cache_current_user_id'] = $t_reporter_id;
+
+		return $t_reporter_id;
+	}
+
+	# --------------------
+	# Very dirty: Adds a file to a bug.
+	function mail_add_file( $p_bug_id, $p_part ) {
+		$GLOBALS['_mail_file_'] = $p_part['Name'];
+		if ( 0 < strlen($p_part['Name']) ) {
+			$t_file_name = '/tmp/'.$p_part['Name'];
+			file_put_contents($t_file_name, $p_part['Body']);
+			file_add($p_bug_id, $t_file_name,  $p_part['Name'], $p_part['Content-Type'], 'bug');
+			unlink($t_file_name);
+		}
+        }
+
+	# --------------------
+	# Adds a bug which is reported via email
+	# Taken from bug_report.php and 
+	function mail_add_bug ( $p_mail, $p_account ) {
+		$t_bug_data = new BugData;
+		$t_bug_data->build			= gpc_get_string( 'build', '' );
+		$t_bug_data->platform			= gpc_get_string( 'platform', '' );
+		$t_bug_data->os				= gpc_get_string( 'os', '' );
+		$t_bug_data->os_build			= gpc_get_string( 'os_build', '' );
+		$t_bug_data->version			= gpc_get_string( 'product_version', '' );
+		$t_bug_data->profile_id			= gpc_get_int( 'profile_id', 0 );
+		$t_bug_data->handler_id			= gpc_get_int( 'handler_id', 0 );
+		$t_bug_data->view_state			= gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
+
+		if ( $p_account['category']) {
+			$t_bug_data->category			= gpc_get_string( 'category', $p_account['category'] );
+		} else {
+			$t_bug_data->category			= gpc_get_string( 'category', '' );
+		}
+		$t_bug_data->reproducibility		= 10;
+		$t_bug_data->severity			= 50;
+		$t_bug_data->priority			= gpc_get_int( 'priority', NORMAL );
+		$t_bug_data->summary			= $p_mail['Subject'];
+		$t_bug_data->description		= "Report from: ".$p_mail['From']."\n\n".$p_mail['X-Mantis-Body'];
+		$t_bug_data->steps_to_reproduce		= gpc_get_string( 'steps_to_reproduce', '' );
+		$t_bug_data->additional_information	= $p_mail['X-Mantis-Complete'];
+
+		$t_bug_data->project_id			= $p_account['id'];
+
+		$t_bug_data->reporter_id		= mail_get_user( $p_mail['From'] );
+
+                if (mail_is_a_bugnote($p_mail['Subject'])) {
+			# Add a bug note
+			$t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] );
+			if ( ! bug_is_readonly( $t_bug_id ) ) {
+				bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] );
+				email_bugnote_add ( $t_bug_id );
+			}
+		} else	{
+			# Create the bug
+			$t_bug_id = bug_create( $t_bug_data );
+			email_new_bug( $t_bug_id );
+		}
+                # Add files
+		foreach ($p_mail['X-Mantis-Parts'] as $part) {
+			mail_add_file ( $t_bug_id, $part );
+		}
+
+	}
+
+?>
+
diff -Nur mantis-1.0.0rc1/core/user_api.php mantis/core/user_api.php
--- mantis-1.0.0rc1/core/user_api.php	Fri Jul 22 17:34:02 2005
+++ mantis/core/user_api.php	Sun Aug  7 10:09:36 2005
@@ -526,6 +526,26 @@
 		}
 	}
 
+	# get a user id from an mail address
+	#  return false if the mail address does not exist
+	function user_get_id_by_mail( $p_mailaddress ) {
+		
+		$c_mailaddress = db_prepare_string( $p_mailaddress );
+
+		$t_user_table = config_get( 'mantis_user_table' );
+
+		$query = "SELECT id
+				  FROM $t_user_table
+				  WHERE email='$c_mailaddress'";
+		$result = db_query( $query );
+
+		if ( 0 == db_num_rows( $result ) ) {
+			return false;
+		} else {
+			return db_result( $result );
+		}
+	}
+
 	# --------------------
 	# return all data associated with a particular user name
 	#  return false if the username does not exist
diff -Nur mantis-1.0.0rc1/doc/README.bug_report_mail mantis/doc/README.bug_report_mail
--- mantis-1.0.0rc1/doc/README.bug_report_mail	Thu Jan  1 01:00:00 1970
+++ mantis/doc/README.bug_report_mail	Sun Aug  7 11:13:18 2005
@@ -0,0 +1,104 @@
+The current version of bug_report_mail support plain text and MIME
+encoded e-mails via POP3 Mailaccounts with PEAR's Net_POP3 package.
+
+bug_report_mail is able to recognize if mail is a reply to an already opened
+bug and adds the content as a bugnote.
+
+If you are alway running Mantis you have to alter your projects table
+with the sql/bug_report_mail.sql script.
+If not, you can create the database tables in the way described in
+the doc/INSTALL file.
+
+This patch changes the following files:
+    core/category_api.php
+    core/file_api.php
+    core/user_api.php
+    admin/schema.php
+    config_defaults_inc.php
+    manage_proj_cat_edit_page.php
+    manage_proj_edit_page.php
+These files are new:
+    core/mail_api.php
+    doc/README.bug_report_mail
+    admin/bug_report_mail.sql
+    bug_report_mail.php
+    manage_proj_cat_mail_delete.php
+    manage_proj_cat_mail_update.php
+    manage_proj_mail_categories.php
+    manage_proj_mail_delete.php
+    manage_proj_mail_update.php
+
+After installing this patch, you can add a POP3 server's hostname
+and authentication data for each of your projects with the project edit form.
+
+There are two ways to receive mail with bug_report_mail:
+The secure (and default) way is to use a standard reporting user:
+You have to create a reporter account, for example 'Mail'.
+The name for this reporter account you have to write in your config_inc.php file:
+	$g_mail_reporter = "Mail";
+and then, bug_report_mail must be informed to behave like this:
+	$g_mail_use_reporter = ON;
+
+The other way is to signup new user accounts automatically.
+For using this, you have to change this
+	$g_mail_auto_signup     = OFF;
+from OFF to ON.
+Now, bug_report_mail will look for an user named like the mail's sender
+or an user which mail adress is identical.
+If no user is found, then a new account will be created.
+The new user's name will be the mail address.
+
+This could be used for attacks, but there is no other way in the moment.
+
+If you like to parse MIME encoded mails, you have to install the PEAR
+Mail_Mime package and set
+	$g_mail_parse_mime	= OFF;
+from OFF to ON.
+
+For debugging controls there is the switch
+	$g_mail_additional	= OFF;
+which puts the complete message into the Additional Information field,
+if it is activated.
+
+In this case you should decrease the amount of fetched messages via
+	$g_mail_fetch_max	= 1;
+because the mime decoding needs a lot of memory.
+
+After this, bug_report_mail can be used via cron like this:
+
+*/5 *   *   *   * lynx --dump http://mantis.homepage.com/bug_report_mail.php
+or via command line interface
+*/5 *   *   *   * /usr/local/bin/php /path/to/mantis/bug_report_mail.php
+
+This line fetch bug reports from via POP3 every 5 minutes. 
+
+This addon is distributed under the same conditions as Mantis itself.
+
+Gerrit Beine, August 2004
+
+Changelog:
+Aug 2005:
+	- update to Mantis 1.0.0rc1
+	- include the additional patches submitted by
+		- gernot (Fixed MIME handling and save the mail's sender)
+		  mail_get_all_mails in core/mail_api.php
+		  mail_parse_content in core/mail_api.php
+		  mail_add_bug in core/mail_api.php
+		- stevenc (Fixed MIME handling)
+		  mail_parse_content in core/mail_api.php
+		- rainman (Fixed empty files bug and regex for finding a bug id)
+		  mail_add_file in core/mail_api.php
+		  mail_get_bug_id_from_subject in core/mail_api.php
+Dec 2004:
+	- update to Mantis 0.19.2
+	- add config: g_mail_parse_mime
+	- add config: g_mail_additional
+	- add config: g_mail_fetch_max
+	- make it working via CLI
+Nov 2004:
+	- update to Mantis 0.19.1
+	- add support for MIME decoding
+Sep 2004:
+	- update to Mantis 0.19.0
+Aug 2004:
+	- create patch for Mantis 0.18.3
diff -Nur mantis-1.0.0rc1/doc/README.bug_report_mail~ mantis/doc/README.bug_report_mail~
--- mantis-1.0.0rc1/doc/README.bug_report_mail~	Thu Jan  1 01:00:00 1970
+++ mantis/doc/README.bug_report_mail~	Sun Aug  7 10:20:58 2005
@@ -0,0 +1,98 @@
+The current version of bug_report_mail support plain text and MIME
+encoded e-mails via POP3 Mailaccounts with PEAR's Net_POP3 package.
+
+bug_report_mail is able to recognize if mail is a reply to an already opened
+bug and adds the content as a bugnote.
+
+If you are alway running Mantis you have to alter your projects table
+with the sql/bug_report_mail.sql script.
+If not, you can create the database tables in the way described in
+the doc/INSTALL file.
+
+This patch changes the following files:
+    core/category_api.php
+    core/file_api.php
+    core/user_api.php
+    sql/db_generate.sql
+    config_defaults_inc.php
+    manage_proj_cat_edit_page.php
+    manage_proj_edit_page.php
+These files are new:
+    core/mail_api.php
+    doc/README.bug_report_mail
+    sql/bug_report_mail.sql
+    bug_report_mail.php
+    manage_proj_cat_mail_delete.php
+    manage_proj_cat_mail_update.php
+    manage_proj_mail_categories.php
+    manage_proj_mail_delete.php
+    manage_proj_mail_update.php
+
+After installing this patch, you can add a POP3 server's hostname
+and authentication data for each of your projects with the project edit form.
+
+There are two ways to receive mail with bug_report_mail:
+The secure (and default) way is to use a standard reporting user:
+You have to create a reporter account, for example 'Mail'.
+The name for this reporter account you have to write in your config_inc.php file:
+	$g_mail_reporter = "Mail";
+and then, bug_report_mail must be informed to behave like this:
+	$g_mail_use_reporter = ON;
+
+The other way is to signup new user accounts automatically.
+For using this, you have to change this
+	$g_mail_auto_signup     = OFF;
+from OFF to ON.
+Now, bug_report_mail will look for an user named like the mail's sender
+or an user which mail adress is identical.
+If no user is found, then a new account will be created.
+The new user's name will be the mail address.
+
+This could be used for attacks, but there is no other way in the moment.
+
+If you like to parse MIME encoded mails, you have to install the PEAR
+Mail_Mime package and set
+	$g_mail_parse_mime	= OFF;
+from OFF to ON.
+
+For debugging controls there is the switch
+	$g_mail_additional	= OFF;
+which puts the complete message into the Additional Information field,
+if it is activated.
+
+In this case you should decrease the amount of fetched messages via
+	$g_mail_fetch_max	= 1;
+because the mime decoding needs a lot of memory.
+
+After this, bug_report_mail can be used via cron like this:
+
+*/5 *   *   *   * lynx --dump http://mantis.homepage.com/bug_report_mail.php
+or via command line interface
+*/5 *   *   *   * /usr/local/bin/php /path/to/mantis/bug_report_mail.php
+
+This line fetch bug reports from via POP3 every 5 minutes. 
+
+This addon is distributed under the same conditions as Mantis itself.
+
+Gerrit Beine, August 2004
+
+Changelog:
+Aug 2005:
+        - update to Mantis 1.0.0rc1
+        - include the additional patches submitted by
+                - gernot
+                - stevenc
+                - rainman
+Dec 2004:
+	- update to Mantis 0.19.2
+	- add config: g_mail_parse_mime
+	- add config: g_mail_additional
+	- add config: g_mail_fetch_max
+	- make it working via CLI
+Nov 2004:
+	- update to Mantis 0.19.1
+	- add support for MIME decoding
+Sep 2004:
+	- update to Mantis 0.19.0
+Aug 2004:
+	- create patch for Mantis 0.18.3
diff -Nur mantis-1.0.0rc1/manage_proj_cat_edit_page.php mantis/manage_proj_cat_edit_page.php
--- mantis-1.0.0rc1/manage_proj_cat_edit_page.php	Sat Feb 12 21:01:06 2005
+++ mantis/manage_proj_cat_edit_page.php	Sun Aug  7 10:23:56 2005
@@ -15,6 +15,7 @@
 	$t_core_path = config_get( 'core_path' );
 
 	require_once( $t_core_path.'category_api.php' );
+	require_once( $t_core_path.'mail_api.php' );
 ?>
 <?php
 	$f_project_id	= gpc_get_int( 'project_id' );
@@ -24,6 +25,10 @@
 
 	$t_row = category_get_row( $f_project_id, $f_category );
 	$t_assigned_to = $t_row['user_id'];
+	$t_mail = mail_get_account_data( $f_project_id );
+	if ( $t_mail['pop3_categories'] ) {
+		$t_category_mail = mail_category_get_account_data( $f_project_id, $f_category );
+	}
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -84,4 +89,59 @@
 	</form>
 </div>
 
+<?php  if ( $t_mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_cat_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Category Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+			<td colspan="2">
+				<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_cat_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<?php } ?>
+ 
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-1.0.0rc1/manage_proj_cat_mail_delete.php mantis/manage_proj_cat_mail_delete.php
--- mantis-1.0.0rc1/manage_proj_cat_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis/manage_proj_cat_mail_delete.php	Sun Aug  7 10:24:56 2005
@@ -0,0 +1,44 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_category_delete( $f_project_id, $f_category );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-1.0.0rc1/manage_proj_cat_mail_update.php mantis/manage_proj_cat_mail_update.php
--- mantis-1.0.0rc1/manage_proj_cat_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis/manage_proj_cat_mail_update.php	Sun Aug  7 10:25:59 2005
@@ -0,0 +1,59 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+		}
+	}
+
+	mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-1.0.0rc1/manage_proj_edit_page.php mantis/manage_proj_edit_page.php
--- mantis-1.0.0rc1/manage_proj_edit_page.php	Tue Jul 19 15:42:48 2005
+++ mantis/manage_proj_edit_page.php	Sun Aug  7 10:41:35 2005
@@ -18,6 +18,7 @@
 	require_once( $t_core_path . 'version_api.php' );
 	require_once( $t_core_path . 'custom_field_api.php' );
 	require_once( $t_core_path . 'icon_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
 ?>
 <?php
 	$f_project_id = gpc_get_int( 'project_id' );
@@ -25,6 +26,7 @@
 	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
 
 	$row = project_get_row( $f_project_id );
+	$mail = mail_get_account_data( $f_project_id );
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -690,4 +692,76 @@
 	</table>
 </div>
 
+<?php  if ( ! $mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+			<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<br />
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="On" />
+		<input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } else { ?>
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="Off" />
+		<input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } ?>
+
 <?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-1.0.0rc1/manage_proj_mail_categories.php mantis/manage_proj_mail_categories.php
--- mantis-1.0.0rc1/manage_proj_mail_categories.php	Thu Jan  1 01:00:00 1970
+++ mantis/manage_proj_mail_categories.php	Sun Aug  7 10:30:02 2005
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_activate	= gpc_get_string( 'categories' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_categories( $f_project_id, $f_activate );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-1.0.0rc1/manage_proj_mail_delete.php mantis/manage_proj_mail_delete.php
--- mantis-1.0.0rc1/manage_proj_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis/manage_proj_mail_delete.php	Sun Aug  7 10:31:01 2005
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_delete( $f_project_id );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-1.0.0rc1/manage_proj_mail_update.php mantis/manage_proj_mail_update.php
--- mantis-1.0.0rc1/manage_proj_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis/manage_proj_mail_update.php	Sun Aug  7 10:32:15 2005
@@ -0,0 +1,59 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+	
+	$t_core_path = config_get( 'core_path' );
+	
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+
+	echo $f_project_id;
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+		}
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+		}
+	}
+
+	mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
mantis-1.0.0rc1.patch (44,881 bytes)   
mantis-1.0.0rc1.patch-2 (40,308 bytes)
mantis-1.0.0rc2.patch (41,283 bytes)   
diff -Nur mantis-1.0.0rc2.orig/admin/schema.php mantis-1.0.0rc2/admin/schema.php
--- mantis-1.0.0rc2.orig/admin/schema.php	Wed Aug  3 16:20:34 2005
+++ mantis-1.0.0rc2/admin/schema.php	Mon Oct 31 11:15:02 2005
@@ -192,7 +192,10 @@
 $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_project_category_table'),"
   project_id 		 I  UNSIGNED NOTNULL PRIMARY DEFAULT '0',
   category 		C(64) NOTNULL PRIMARY DEFAULT \" '' \",
-  user_id 		 I  UNSIGNED NOTNULL DEFAULT '0'
+  user_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  pop3_host		C(250) NULL,
+  pop3_user		C(250) NULL,
+  pop3_pass		C(250) NULL
 ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS')));
 
 $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_project_file_table'),"
@@ -222,7 +225,11 @@
   view_state 		I2 NOTNULL DEFAULT '10',
   access_min 		I2 NOTNULL DEFAULT '10',
   file_path 		C(250) NOTNULL DEFAULT \" '' \",
-  description 		XS NOTNULL
+  description 		XS NOTNULL,
+  pop3_host		C(250) NULL,
+  pop3_user		C(250) NULL,
+  pop3_pass		C(250) NULL,
+  pop3_categories	L NOTNULL DEFAULT '0'
 ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS')));
 $upgrade[] = Array('CreateIndexSQL',Array('idx_project_id',config_get('mantis_project_table'),'id'));
 $upgrade[] = Array('CreateIndexSQL',Array('idx_project_name',config_get('mantis_project_table'),'name',Array('UNIQUE')));
@@ -340,5 +347,9 @@
 $upgrade[] = Array('InsertData', Array( config_get('mantis_user_table'), 
     "(username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES 
         ('administrator', '', 'root@localhost', '63a9f0ea7bb98050796b649e85481845', " . db_now() . ", " . db_now() . ", 1, 0, 90, 3, 0, 0, '" . 
+             md5( mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() ) ) . md5( time() ) . "')" ) );
+$upgrade[] = Array('InsertData', Array( config_get('mantis_user_table'), 
+    "(username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES 
+        ('mail', 'Mail Reporter', 'root@nomail@localhost', 'a268462c3c679a9027658c5aa723f97c', " . db_now() . ", " . db_now() . ", 1, 0, 25, 0, 0, 0, '" . 
              md5( mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() ) ) . md5( time() ) . "')" ) );
 ?>
diff -Nur mantis-1.0.0rc2.orig/bug_report_mail.php mantis-1.0.0rc2/bug_report_mail.php
--- mantis-1.0.0rc2.orig/bug_report_mail.php	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc2/bug_report_mail.php	Mon Oct 31 11:15:02 2005
@@ -0,0 +1,39 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	# This page receives an E-Mail via POP3 and generates an Report
+	header("Content-type: text/plain");
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'string_api.php' );
+	require_once( $t_core_path . 'bug_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$t_mailaccounts = mail_get_accounts();
+
+	foreach ($t_mailaccounts as $t_mailaccount) {
+		if ( config_get( 'mail_debug' ) ) {
+			print_r($t_mailaccounts);
+		}
+		$t_mails = mail_get_all_mails($t_mailaccount);
+		foreach ($t_mails as $t_mail)
+		{
+			if ( config_get( 'mail_debug' ) ) {
+				print_r($t_mail);
+			}
+			$GLOBALS['g_cache_current_user_id'] = mail_get_user( $t_mail['From'] );
+			mail_add_bug($t_mail, $t_mailaccount);
+		}
+	}
+?>
+
diff -Nur mantis-1.0.0rc2.orig/config_defaults_inc.php mantis-1.0.0rc2/config_defaults_inc.php
--- mantis-1.0.0rc2.orig/config_defaults_inc.php	Sun Sep 11 13:24:08 2005
+++ mantis-1.0.0rc2/config_defaults_inc.php	Mon Oct 31 11:15:02 2005
@@ -1617,4 +1617,37 @@
 	#   )
 	# );
 	$g_custom_group_actions = array();
+
+	######################
+	# Mail Reporting
+	######################
+
+	# --- mail reporting settings -----
+	# This tells Mantis to report all the Mail with only one account
+	$g_mail_use_reporter	= ON;
+
+	# The account's name for mail reporting
+	# Also used for fallback if a user is not found in database
+	$g_mail_reporter	= 'Mail';
+
+	# Signup new users automatically (possible security risk!)
+	# Default is OFF, ignored if mail_use_reporter is ON
+	$g_mail_auto_signup	= OFF;
+
+	# Write complete mail into the "Additional Information"
+	$g_mail_additional	= OFF;
+
+	# Write sender of the message into the bug report
+	$g_mail_save_from	= OFF;
+
+	# Parse MIME mails (may require a lot of memory)
+	$g_mail_parse_mime	= OFF;
+
+	# How many mails should be fetched at the same time
+	# If big mails with attachments should be received, specify only one
+	$g_mail_fetch_max	= 1;
+
+	# Signup new users automatically (possible security risk!)
+	# Default is OFF, ignored if mail_use_reporter is ON
+	$g_mail_debug		= OFF;
 ?>
diff -Nur mantis-1.0.0rc2.orig/core/category_api.php mantis-1.0.0rc2/core/category_api.php
--- mantis-1.0.0rc2.orig/core/category_api.php	Sat Feb 12 21:01:10 2005
+++ mantis-1.0.0rc2/core/category_api.php	Mon Oct 31 11:15:22 2005
@@ -186,7 +186,7 @@
 
 		$t_project_category_table = config_get( 'mantis_project_category_table' );
 
-		$query = "SELECT category, user_id
+		$query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass
 				FROM $t_project_category_table
 				WHERE project_id='$c_project_id' AND
 					category='$c_category'";
@@ -206,7 +206,7 @@
 
 		$t_project_category_table = config_get( 'mantis_project_category_table' );
 
-		$query = "SELECT category, user_id
+		$query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass
 				FROM $t_project_category_table
 				WHERE project_id='$c_project_id'
 				ORDER BY category";
diff -Nur mantis-1.0.0rc2.orig/core/mail_api.php mantis-1.0.0rc2/core/mail_api.php
--- mantis-1.0.0rc2.orig/core/mail_api.php	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc2/core/mail_api.php	Mon Oct 31 11:15:02 2005
@@ -0,0 +1,443 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
+
+	require_once( $t_core_dir . 'bug_api.php' );
+	require_once( $t_core_dir . 'bugnote_api.php' );
+	require_once( $t_core_dir . 'user_api.php' );
+	require_once( $t_core_dir . 'project_api.php' );
+	require_once( $t_core_dir . 'file_api.php' );
+
+	# This page receives an E-Mail via POP3 and generates an Report
+
+	require_once( 'Net/POP3.php' );
+	require_once( 'Mail/mimeDecode.php' );
+
+	# --------------------
+	# Return mail account data for the specified project
+	function mail_get_account_data( $p_project_id ) {
+		$v_project_id = db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories
+				FROM $t_project_table 
+				WHERE id='$v_project_id'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data for a project
+	function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_pop3_host	= db_prepare_string( $p_pop3_host );
+		$v_pop3_user	= db_prepare_string( $p_pop3_user );
+		$v_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+			 	SET pop3_host='$v_pop3_host',
+				pop3_user='$v_pop3_user',
+				pop3_pass='$v_pop3_pass'
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data from a project
+	function mail_delete( $p_project_id ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Activate the 'Mail per Category' feature for a project
+	function mail_categories( $p_project_id, $p_active ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		if ($p_active == 'On') {
+			$v_active = 1;
+		} else {
+			$v_active = 0;
+		}
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_categories='$v_active'
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Return mail account data for the specified project and category
+	function mail_category_get_account_data( $p_project_id, $p_category ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass
+				FROM $t_project_category_table 
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data for a category
+	function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+		$v_pop3_host	= db_prepare_string( $p_pop3_host );
+		$v_pop3_user	= db_prepare_string( $p_pop3_user );
+		$v_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host='$v_pop3_host',
+				pop3_user='$v_pop3_user',
+				pop3_pass='$v_pop3_pass'
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data for a category
+	function mail_category_delete( $p_project_id, $p_category ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+		
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# return all mailaccounts
+	#  return an empty array if there are no
+	function mail_get_accounts() {
+		$v_accounts = array();
+		$t_projects = mail_project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_categories']) {
+				$v_categories = mail_categories_get_all_rows( $t_project['id'] );
+				$v_accounts = array_merge($v_accounts, $v_categories);
+			} else {
+				array_push($v_accounts, $t_project);
+			}
+		}
+
+		return $v_accounts;
+	}
+
+	# --------------------
+	# return all projects with valid data for mail access
+	#  return an empty array if there are no such projects
+	function mail_project_get_all_rows() {
+		$v_projects = array();
+		$t_projects = project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_host'] || $t_project['pop3_categories']) {
+				array_push($v_projects, $t_project);
+			}
+		}
+
+		return $v_projects;
+	}
+
+	# --------------------
+	# return all categories from a project with valid data for mail access
+	#  return an empty array if there are no such categories
+	function mail_categories_get_all_rows( $p_project_id ) {
+		$v_categories = array();
+		$t_categories = category_get_all_rows( $p_project_id );
+
+		foreach ($t_categories as $t_category) {
+			if ($t_category['pop3_host']) {
+				$t_category['id'] = $p_project_id;
+				array_push($v_categories, $t_category);
+			}
+		}
+
+		return $v_categories;
+	}
+
+	# --------------------
+	# return all mails for an account
+	#  return an empty array if there are no new mails
+	function mail_get_all_mails( $p_account ) {
+		$t_mail_parse_mime	= config_get( 'mail_parse_mime' );
+		$t_mail_fetch_max	= config_get( 'mail_fetch_max' );
+		$t_mail_additional	= config_get( 'mail_additional' );
+		
+		$v_mails = array();
+		$t_pop3 = &new Net_POP3();
+		$t_pop3_host = $p_account['pop3_host'];
+		$t_pop3_user = $p_account['pop3_user'];
+		$t_pop3_password = $p_account['pop3_pass'];
+		$t_pop3->connect($t_pop3_host, 110);
+		$t_pop3->login($t_pop3_user, $t_pop3_password);
+
+		if ( 0 == $t_pop3->numMsg() ) {
+			return $v_mails;
+		}
+		for ($i = 1; $i <= $t_mail_fetch_max; $i++) {
+			$t_headers = $t_pop3->getParsedHeaders($i);
+			$t_msg = $t_pop3->getMsg($i);
+			if (true == $t_mail_parse_mime &&
+				true == isset( $t_headers['MIME-Version'] ) &&
+				'multipart' == strtolower ( substr( $t_headers['Content-Type'], 0, 9 ) ) ) {
+				$t_mail = mail_parse_content( $t_msg );
+			} else {
+				$t_mail = $t_headers;
+				$t_mail['X-Mantis-Body'] = $t_pop3->getBody($i);
+			}
+
+			if (true == $t_mail_additional) {
+				$t_mail['X-Mantis-Complete'] = $t_msg;
+			}
+
+			array_push($v_mails, $t_mail);
+			$t_pop3->deleteMsg($i);
+		}
+
+		$t_pop3->disconnect();
+		return $v_mails;
+	}
+
+	# --------------------
+	# return the mail parsed for Mantis
+	function mail_parse_content ( $p_mail ) {
+		$v_mail = array ();
+		$t_decoder = new Mail_mimeDecode($p_mail);
+		$t_params['include_bodies'] = true;
+		$t_params['decode_bodies']  = true;
+		$t_params['decode_headers'] = true;
+		$t_structure = $t_decoder->decode($t_params);
+		$v_mail['To'] = $t_structure->headers['to'];
+		$v_mail['From'] = $t_structure->headers['from'];
+		$v_mail['Subject'] = $t_structure->headers['subject'];
+		if (is_array($t_structure->parts)) {
+			$t_parts = mail_parse_parts( $t_structure->parts );
+		} else {
+                	$t_parts = array ( mail_parse_part( $t_structure ) );
+		}
+		if (strtolower($t_parts[0]['Content-Type']) == 'text/plain' ||
+			strtolower($t_parts[0]['Content-Type']) == 'text/html' ) {
+			$t_body['Body'] = $t_parts[0]['Body'];
+		} else {
+			$t_body['Body'] = "It seems, there is no text... :-o";
+		}
+		$v_mail['X-Mantis-Parts'] = $t_parts;
+		$v_mail['X-Mantis-Body'] = $t_body['Body'];
+
+		return $v_mail;
+	}
+
+	# --------------------
+	# return the parsed parts from the mail
+	function mail_parse_parts ( $p_parts ) {
+		$v_parts = array ();
+		foreach ( $p_parts as $t_part ) {
+			array_push($v_parts, mail_parse_part( $t_part ));
+		}
+
+		return $v_parts;
+	}
+
+	# --------------------
+	# return one parsed part
+	function mail_parse_part ( $p_part ) {
+		$v_part = array ();
+		$v_part['Content-Type'] = $p_part->ctype_primary."/".$p_part->ctype_secondary;
+		$v_part['Name'] = $p_part->ctype_parameters['name'];
+		$v_part['Body'] = $p_part->body;
+
+		return $v_part;
+	}
+
+	# --------------------
+	# return the mailadress from the mail's 'From'
+	function mail_parse_address ( $p_mailaddress ) {
+		if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) {
+			$v_mailaddress = $matches[1];
+		}
+
+		return $v_mailaddress;
+	}
+
+	# --------------------
+	# return the a valid username from an email address
+	function mail_user_name_from_address ( $p_mailaddress ) {
+		return preg_replace("/[@\.-]/", '_', $p_mailaddress);
+	}
+
+	# --------------------
+	# return true if there is a valid mantis bug referernce in subject
+	function mail_is_a_bugnote ( $p_mail_subject ) {
+		return preg_match("/\[([A-Za-z0-9-_\. ]*\s[0-9]{7})\]/", $p_mail_subject);
+	}
+
+	# --------------------
+	# return the bug's id from the subject
+	function mail_get_bug_id_from_subject ( $p_mail_subject ) {
+		preg_match("/\[([A-Za-z0-9-_\. ]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches);
+
+		return $v_matches[2];
+	}
+
+	# --------------------
+	# return the user id for the mail reporting user
+	function mail_get_user ($p_mailaddress) {
+		$t_mail_use_reporter	= config_get( 'mail_use_reporter' );
+		$t_mail_auto_signup	= config_get( 'mail_auto_signup' );
+		$t_mail_reporter	= config_get( 'mail_reporter' );
+		
+		$v_mailaddress = mail_parse_address( $p_mailaddress );
+
+		if ( $t_mail_use_reporter ) {
+			// Always report as mail_reporter
+			$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+		} else {
+			// Try to get the reporting users id
+			$t_reporter_id = user_get_id_by_mail ( $v_mailaddress );
+			if ( ! $t_reporter_id && $t_mail_auto_signup ) {
+				// So, we've to sign up a new user...
+				$t_user_name = mail_user_name_from_address ( $v_mailaddress );
+				user_signup($t_user_name, $v_mailaddress);
+				$t_reporter_id = user_get_id_by_name($t_user_name);
+			} elseif ( ! $t_reporter_id ) {
+				// Fall back to the default mail_reporter
+				$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+			}
+		}
+
+		// dirty: Set the identified user's id
+		// required if bug_report_mail is run via command line
+		$GLOBAL['g_cache_current_user_id'] = $t_reporter_id;
+
+		return $t_reporter_id;
+	}
+
+	# --------------------
+	# Very dirty: Adds a file to a bug.
+	function mail_add_file( $p_bug_id, $p_part ) {
+		$GLOBALS['_mail_file_'] = $p_part['Name'];
+		if ( 0 < strlen($p_part['Name']) ) {
+			$t_file_name = '/tmp/'.$p_part['Name'];
+			file_put_contents($t_file_name, $p_part['Body']);
+			file_add($p_bug_id, $t_file_name,  $p_part['Name'], $p_part['Content-Type'], 'bug');
+			unlink($t_file_name);
+		}
+	}
+
+	# --------------------
+	# Adds a bug which is reported via email
+	# Taken from bug_report.php and 
+	function mail_add_bug ( $p_mail, $p_account ) {
+		$t_mail_save_from	= config_get( 'mail_save_from' );
+
+		$t_bug_data = new BugData;
+		$t_bug_data->build			= gpc_get_string( 'build', '' );
+		$t_bug_data->platform			= gpc_get_string( 'platform', '' );
+		$t_bug_data->os				= gpc_get_string( 'os', '' );
+		$t_bug_data->os_build			= gpc_get_string( 'os_build', '' );
+		$t_bug_data->version			= gpc_get_string( 'product_version', '' );
+		$t_bug_data->profile_id			= gpc_get_int( 'profile_id', 0 );
+		$t_bug_data->handler_id			= gpc_get_int( 'handler_id', 0 );
+		$t_bug_data->view_state			= gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
+
+		if ( $p_account['category']) {
+			$t_bug_data->category			= gpc_get_string( 'category', $p_account['category'] );
+		} else {
+			$t_bug_data->category			= gpc_get_string( 'category', '' );
+		}
+		$t_bug_data->reproducibility		= 10;
+		$t_bug_data->severity			= 50;
+		$t_bug_data->priority			= gpc_get_int( 'priority', NORMAL );
+		$t_bug_data->summary			= $p_mail['Subject'];
+		if ( $t_mail_save_from ) {
+			$t_bug_data->description	= "Report from: ".$p_mail['From']."\n\n".$p_mail['X-Mantis-Body'];
+		}
+		else {
+			$t_bug_data->description	= $p_mail['X-Mantis-Body'];
+		}
+		$t_bug_data->steps_to_reproduce		= gpc_get_string( 'steps_to_reproduce', '' );
+		$t_bug_data->additional_information	= $p_mail['X-Mantis-Complete'];
+
+		$t_bug_data->project_id			= $p_account['id'];
+
+		$t_bug_data->reporter_id		= mail_get_user( $p_mail['From'] );
+
+		if ( mail_is_a_bugnote( $p_mail['Subject'] ) ) {
+			# Add a bug note
+			$t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] );
+			if ( ! bug_is_readonly( $t_bug_id ) ) {
+				bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] );
+				email_bugnote_add ( $t_bug_id );
+			}
+		} else	{
+			# Create the bug
+			$t_bug_id = bug_create( $t_bug_data );
+			email_new_bug( $t_bug_id );
+		}
+		# Add files
+		if ( null != $p_mail['X-Mantis-Parts'] ) {
+			foreach ($p_mail['X-Mantis-Parts'] as $part) {
+				mail_add_file ( $t_bug_id, $part );
+			}
+		}
+
+	}
+
+?>
+
diff -Nur mantis-1.0.0rc2.orig/core/user_api.php mantis-1.0.0rc2/core/user_api.php
--- mantis-1.0.0rc2.orig/core/user_api.php	Fri Jul 22 17:34:02 2005
+++ mantis-1.0.0rc2/core/user_api.php	Mon Oct 31 11:15:02 2005
@@ -526,6 +526,24 @@
 		}
 	}
 
+	# get a user id from an mail address
+	#  return false if the mail address does not exist
+	function user_get_id_by_mail( $p_mailaddress ) {
+		$c_mailaddress = db_prepare_string( $p_mailaddress );
+		$t_user_table = config_get( 'mantis_user_table' );
+
+		$query = "SELECT id
+				  FROM $t_user_table
+				  WHERE email='$c_mailaddress'";
+		$result = db_query( $query );
+
+		if ( 0 == db_num_rows( $result ) ) {
+			return false;
+		} else {
+			return db_result( $result );
+		}
+	}
+
 	# --------------------
 	# return all data associated with a particular user name
 	#  return false if the username does not exist
diff -Nur mantis-1.0.0rc2.orig/doc/README.bug_report_mail mantis-1.0.0rc2/doc/README.bug_report_mail
--- mantis-1.0.0rc2.orig/doc/README.bug_report_mail	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc2/doc/README.bug_report_mail	Mon Oct 31 11:17:22 2005
@@ -0,0 +1,113 @@
+The current version of bug_report_mail support plain text and MIME
+encoded e-mails via POP3 Mailaccounts with PEAR's Net_POP3 package.
+
+bug_report_mail is able to recognize if mail is a reply to an already opened
+bug and adds the content as a bugnote.
+
+If you are alway running Mantis you have to alter your projects table
+with the sql/bug_report_mail.sql script.
+If not, you can create the database tables in the way described in
+the doc/INSTALL file.
+
+This patch changes the following files:
+    core/category_api.php
+    core/user_api.php
+    admin/schema.php
+    config_defaults_inc.php
+    manage_proj_cat_edit_page.php
+    manage_proj_edit_page.php
+These files are new:
+    core/mail_api.php
+    doc/README.bug_report_mail
+    doc/bug_report_mail.sql
+    bug_report_mail.php
+    manage_proj_cat_mail_delete.php
+    manage_proj_cat_mail_update.php
+    manage_proj_mail_categories.php
+    manage_proj_mail_delete.php
+    manage_proj_mail_update.php
+
+After installing this patch, you can add a POP3 server's hostname
+and authentication data for each of your projects with the project edit form.
+
+There are two ways to receive mail with bug_report_mail:
+The secure (and default) way is to use a standard reporting user:
+You have to create a reporter account, for example 'Mail'.
+The name for this reporter account you have to write in your config_inc.php file:
+	$g_mail_reporter = "Mail";
+and then, bug_report_mail must be informed to behave like this:
+	$g_mail_use_reporter = ON;
+
+The other way is to signup new user accounts automatically.
+For using this, you have to change this
+	$g_mail_auto_signup     = OFF;
+from OFF to ON.
+Now, bug_report_mail will look for an user named like the mail's sender
+or an user which mail adress is identical.
+If no user is found, then a new account will be created.
+The new user's name will be the mail address.
+
+This could be used for attacks, but there is no other way in the moment.
+
+If you like to parse MIME encoded mails, you have to install the PEAR
+Mail_Mime package and set
+	$g_mail_parse_mime	= OFF;
+from OFF to ON.
+
+For debugging controls there is the switch
+	$g_mail_additional	= OFF;
+which puts the complete message into the Additional Information field,
+if it is activated.
+
+In this case you should decrease the amount of fetched messages via
+	$g_mail_fetch_max	= 1;
+because the mime decoding needs a lot of memory.
+
+If you'd like to use the Mail Reporter but don't save the whole message for
+making the sender's address available, set
+	$g_mail_save_from	= OFF;
+to ON.
+
+After this, bug_report_mail can be used via cron like this:
+
+*/5 *   *   *   * lynx --dump http://mantis.homepage.com/bug_report_mail.php
+or via command line interface
+*/5 *   *   *   * /usr/local/bin/php /path/to/mantis/bug_report_mail.php
+
+This line fetch bug reports from via POP3 every 5 minutes. 
+
+This addon is distributed under the same conditions as Mantis itself.
+
+Gerrit Beine, August 2004
+
+Changelog:
+Sep 2005:
+	- update to Mantis 1.0.0rc2
+	- fixed a bug in getting all categories for a project
+		category_get_all_rows in core/category_api.php
+Aug 2005:
+	- update to Mantis 1.0.0rc1
+	- include the additional patches submitted by
+		- gernot (Fixed MIME handling and save the mail's sender)
+		  mail_get_all_mails in core/mail_api.php
+		  mail_parse_content in core/mail_api.php
+		  mail_add_bug in core/mail_api.php
+		- stevenc (Fixed MIME handling)
+		  mail_parse_content in core/mail_api.php
+		- rainman (Fixed empty files bug and regex for finding a bug id)
+		  mail_add_file in core/mail_api.php
+		  mail_get_bug_id_from_subject in core/mail_api.php
+Dec 2004:
+	- update to Mantis 0.19.2
+	- add config: g_mail_parse_mime
+	- add config: g_mail_additional
+	- add config: g_mail_fetch_max
+	- make it working via CLI
+Nov 2004:
+	- update to Mantis 0.19.1
+	- add support for MIME decoding
+Sep 2004:
+	- update to Mantis 0.19.0
+Aug 2004:
+	- create patch for Mantis 0.18.3
+
diff -Nur mantis-1.0.0rc2.orig/doc/bug_report_mail.sql mantis-1.0.0rc2/doc/bug_report_mail.sql
--- mantis-1.0.0rc2.orig/doc/bug_report_mail.sql	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc2/doc/bug_report_mail.sql	Mon Oct 31 11:15:02 2005
@@ -0,0 +1,12 @@
+ALTER TABLE `mantis_project_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_categories` ENUM( '0', '1' ) DEFAULT '0' NOT NULL ;
+
+ALTER TABLE `mantis_project_category_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ;
+
+INSERT INTO mantis_user_table (username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES ('Mail', 'Mail Reporter', 'nomail', 'a268462c3c679a9027658c5aa723f97c', '2004-12-25 15:41:49', '2004-12-25 15:41:49', 1, 0, 25, 0, 0, 0, CONCAT(MD5(RAND()),MD5(NOW())));
diff -Nur mantis-1.0.0rc2.orig/manage_proj_cat_edit_page.php mantis-1.0.0rc2/manage_proj_cat_edit_page.php
--- mantis-1.0.0rc2.orig/manage_proj_cat_edit_page.php	Sat Feb 12 21:01:06 2005
+++ mantis-1.0.0rc2/manage_proj_cat_edit_page.php	Mon Oct 31 11:15:02 2005
@@ -15,6 +15,7 @@
 	$t_core_path = config_get( 'core_path' );
 
 	require_once( $t_core_path.'category_api.php' );
+	require_once( $t_core_path.'mail_api.php' );
 ?>
 <?php
 	$f_project_id	= gpc_get_int( 'project_id' );
@@ -24,6 +25,10 @@
 
 	$t_row = category_get_row( $f_project_id, $f_category );
 	$t_assigned_to = $t_row['user_id'];
+	$t_mail = mail_get_account_data( $f_project_id );
+	if ( $t_mail['pop3_categories'] ) {
+		$t_category_mail = mail_category_get_account_data( $f_project_id, $f_category );
+	}
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -84,4 +89,59 @@
 	</form>
 </div>
 
+<?php  if ( $t_mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_cat_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Category Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+			<td colspan="2">
+				<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_cat_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<?php } ?>
+ 
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-1.0.0rc2.orig/manage_proj_cat_mail_delete.php mantis-1.0.0rc2/manage_proj_cat_mail_delete.php
--- mantis-1.0.0rc2.orig/manage_proj_cat_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc2/manage_proj_cat_mail_delete.php	Mon Oct 31 11:15:02 2005
@@ -0,0 +1,44 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_category_delete( $f_project_id, $f_category );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-1.0.0rc2.orig/manage_proj_cat_mail_update.php mantis-1.0.0rc2/manage_proj_cat_mail_update.php
--- mantis-1.0.0rc2.orig/manage_proj_cat_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc2/manage_proj_cat_mail_update.php	Mon Oct 31 11:15:02 2005
@@ -0,0 +1,59 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+		}
+	}
+
+	mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-1.0.0rc2.orig/manage_proj_edit_page.php mantis-1.0.0rc2/manage_proj_edit_page.php
--- mantis-1.0.0rc2.orig/manage_proj_edit_page.php	Tue Jul 26 14:41:02 2005
+++ mantis-1.0.0rc2/manage_proj_edit_page.php	Mon Oct 31 11:15:02 2005
@@ -18,6 +18,7 @@
 	require_once( $t_core_path . 'version_api.php' );
 	require_once( $t_core_path . 'custom_field_api.php' );
 	require_once( $t_core_path . 'icon_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
 ?>
 <?php
 	$f_project_id = gpc_get_int( 'project_id' );
@@ -25,6 +26,7 @@
 	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
 
 	$row = project_get_row( $f_project_id );
+	$mail = mail_get_account_data( $f_project_id );
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -689,5 +691,76 @@
 	</tr>
 	</table>
 </div>
+
+<?php  if ( ! $mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<br />
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="On" />
+		<input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } else { ?>
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="Off" />
+		<input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } ?>
 
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-1.0.0rc2.orig/manage_proj_mail_categories.php mantis-1.0.0rc2/manage_proj_mail_categories.php
--- mantis-1.0.0rc2.orig/manage_proj_mail_categories.php	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc2/manage_proj_mail_categories.php	Mon Oct 31 11:15:02 2005
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_activate	= gpc_get_string( 'categories' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_categories( $f_project_id, $f_activate );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-1.0.0rc2.orig/manage_proj_mail_delete.php mantis-1.0.0rc2/manage_proj_mail_delete.php
--- mantis-1.0.0rc2.orig/manage_proj_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc2/manage_proj_mail_delete.php	Mon Oct 31 11:15:02 2005
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_delete( $f_project_id );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-1.0.0rc2.orig/manage_proj_mail_update.php mantis-1.0.0rc2/manage_proj_mail_update.php
--- mantis-1.0.0rc2.orig/manage_proj_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc2/manage_proj_mail_update.php	Mon Oct 31 11:15:02 2005
@@ -0,0 +1,58 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+		}
+	}
+
+	mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
mantis-1.0.0rc2.patch (41,283 bytes)   
mantis-0.19.3.patch (40,912 bytes)   
diff -Nur mantis-0.19.3.orig/bug_report_mail.php mantis-0.19.3/bug_report_mail.php
--- mantis-0.19.3.orig/bug_report_mail.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.3/bug_report_mail.php	Mon Oct 31 11:22:28 2005
@@ -0,0 +1,39 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	# This page receives an E-Mail via POP3 and generates an Report
+	header("Content-type: text/plain");
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'string_api.php' );
+	require_once( $t_core_path . 'bug_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$t_mailaccounts = mail_get_accounts();
+
+	foreach ($t_mailaccounts as $t_mailaccount) {
+		if ( config_get( 'mail_debug' ) ) {
+			print_r($t_mailaccounts);
+		}
+		$t_mails = mail_get_all_mails($t_mailaccount);
+		foreach ($t_mails as $t_mail)
+		{
+			if ( config_get( 'mail_debug' ) ) {
+				print_r($t_mail);
+			}
+			$GLOBALS['g_cache_current_user_id'] = mail_get_user( $t_mail['From'] );
+			mail_add_bug($t_mail, $t_mailaccount);
+		}
+	}
+?>
+
diff -Nur mantis-0.19.3.orig/config_defaults_inc.php mantis-0.19.3/config_defaults_inc.php
--- mantis-0.19.3.orig/config_defaults_inc.php	Tue Oct 11 14:00:54 2005
+++ mantis-0.19.3/config_defaults_inc.php	Mon Oct 31 11:22:28 2005
@@ -1474,4 +1474,37 @@
 	# NOTE: These are meaningless under Windows! Just ignore them!
 	$g_dot_tool							= '/usr/bin/dot';
 	$g_neato_tool						= '/usr/bin/neato';
-?>
\ No newline at end of file
+
+	######################
+	# Mail Reporting
+	######################
+
+	# --- mail reporting settings -----
+	# This tells Mantis to report all the Mail with only one account
+	$g_mail_use_reporter	= ON;
+
+	# The account's name for mail reporting
+	# Also used for fallback if a user is not found in database
+	$g_mail_reporter	= 'Mail';
+
+	# Signup new users automatically (possible security risk!)
+	# Default is OFF, ignored if mail_use_reporter is ON
+	$g_mail_auto_signup	= OFF;
+
+	# Write complete mail into the "Additional Information"
+	$g_mail_additional	= OFF;
+
+	# Write sender of the message into the bug report
+	$g_mail_save_from	= OFF;
+
+	# Parse MIME mails (may require a lot of memory)
+	$g_mail_parse_mime	= OFF;
+
+	# How many mails should be fetched at the same time
+	# If big mails with attachments should be received, specify only one
+	$g_mail_fetch_max	= 1;
+
+	# Signup new users automatically (possible security risk!)
+	# Default is OFF, ignored if mail_use_reporter is ON
+	$g_mail_debug		= OFF;
+?>
diff -Nur mantis-0.19.3.orig/core/category_api.php mantis-0.19.3/core/category_api.php
--- mantis-0.19.3.orig/core/category_api.php	Thu Apr  8 20:04:52 2004
+++ mantis-0.19.3/core/category_api.php	Mon Oct 31 11:22:49 2005
@@ -186,7 +186,7 @@
 
 		$t_project_category_table = config_get( 'mantis_project_category_table' );
 
-		$query = "SELECT category, user_id
+		$query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass
 				FROM $t_project_category_table
 				WHERE project_id='$c_project_id' AND
 					category='$c_category'";
@@ -206,7 +206,7 @@
 
 		$t_project_category_table = config_get( 'mantis_project_category_table' );
 
-		$query = "SELECT category, user_id
+		$query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass
 				FROM $t_project_category_table
 				WHERE project_id='$c_project_id'
 				ORDER BY category";
@@ -221,4 +221,4 @@
 
 		return $rows;
 	}
-?>
\ No newline at end of file
+?>
diff -Nur mantis-0.19.3.orig/core/file_api.php mantis-0.19.3/core/file_api.php
--- mantis-0.19.3.orig/core/file_api.php	Sun Oct 17 03:58:56 2004
+++ mantis-0.19.3/core/file_api.php	Mon Oct 31 11:22:28 2005
@@ -509,7 +509,7 @@
 			trigger_error( ERROR_DUPLICATE_FILE, ERROR );
 		}  
 
-		if ( is_uploaded_file( $p_tmp_file ) ) {
+		if ( is_uploaded_file( $p_tmp_file )  || $GLOBALS['_mail_file_']  == $p_file_name ) {
 			if ( 'bug' == $p_table ) {
 				$t_project_id	= bug_get_field( $p_bug_id, 'project_id' );
 				$t_bug_id		= bug_format_id( $p_bug_id );
diff -Nur mantis-0.19.3.orig/core/mail_api.php mantis-0.19.3/core/mail_api.php
--- mantis-0.19.3.orig/core/mail_api.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.3/core/mail_api.php	Mon Oct 31 11:22:28 2005
@@ -0,0 +1,443 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
+
+	require_once( $t_core_dir . 'bug_api.php' );
+	require_once( $t_core_dir . 'bugnote_api.php' );
+	require_once( $t_core_dir . 'user_api.php' );
+	require_once( $t_core_dir . 'project_api.php' );
+	require_once( $t_core_dir . 'file_api.php' );
+
+	# This page receives an E-Mail via POP3 and generates an Report
+
+	require_once( 'Net/POP3.php' );
+	require_once( 'Mail/mimeDecode.php' );
+
+	# --------------------
+	# Return mail account data for the specified project
+	function mail_get_account_data( $p_project_id ) {
+		$v_project_id = db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories
+				FROM $t_project_table 
+				WHERE id='$v_project_id'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data for a project
+	function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_pop3_host	= db_prepare_string( $p_pop3_host );
+		$v_pop3_user	= db_prepare_string( $p_pop3_user );
+		$v_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+			 	SET pop3_host='$v_pop3_host',
+				pop3_user='$v_pop3_user',
+				pop3_pass='$v_pop3_pass'
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data from a project
+	function mail_delete( $p_project_id ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Activate the 'Mail per Category' feature for a project
+	function mail_categories( $p_project_id, $p_active ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		if ($p_active == 'On') {
+			$v_active = 1;
+		} else {
+			$v_active = 0;
+		}
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_categories='$v_active'
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Return mail account data for the specified project and category
+	function mail_category_get_account_data( $p_project_id, $p_category ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass
+				FROM $t_project_category_table 
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data for a category
+	function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+		$v_pop3_host	= db_prepare_string( $p_pop3_host );
+		$v_pop3_user	= db_prepare_string( $p_pop3_user );
+		$v_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host='$v_pop3_host',
+				pop3_user='$v_pop3_user',
+				pop3_pass='$v_pop3_pass'
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data for a category
+	function mail_category_delete( $p_project_id, $p_category ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+		
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# return all mailaccounts
+	#  return an empty array if there are no
+	function mail_get_accounts() {
+		$v_accounts = array();
+		$t_projects = mail_project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_categories']) {
+				$v_categories = mail_categories_get_all_rows( $t_project['id'] );
+				$v_accounts = array_merge($v_accounts, $v_categories);
+			} else {
+				array_push($v_accounts, $t_project);
+			}
+		}
+
+		return $v_accounts;
+	}
+
+	# --------------------
+	# return all projects with valid data for mail access
+	#  return an empty array if there are no such projects
+	function mail_project_get_all_rows() {
+		$v_projects = array();
+		$t_projects = project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_host'] || $t_project['pop3_categories']) {
+				array_push($v_projects, $t_project);
+			}
+		}
+
+		return $v_projects;
+	}
+
+	# --------------------
+	# return all categories from a project with valid data for mail access
+	#  return an empty array if there are no such categories
+	function mail_categories_get_all_rows( $p_project_id ) {
+		$v_categories = array();
+		$t_categories = category_get_all_rows( $p_project_id );
+
+		foreach ($t_categories as $t_category) {
+			if ($t_category['pop3_host']) {
+				$t_category['id'] = $p_project_id;
+				array_push($v_categories, $t_category);
+			}
+		}
+
+		return $v_categories;
+	}
+
+	# --------------------
+	# return all mails for an account
+	#  return an empty array if there are no new mails
+	function mail_get_all_mails( $p_account ) {
+		$t_mail_parse_mime	= config_get( 'mail_parse_mime' );
+		$t_mail_fetch_max	= config_get( 'mail_fetch_max' );
+		$t_mail_additional	= config_get( 'mail_additional' );
+		
+		$v_mails = array();
+		$t_pop3 = &new Net_POP3();
+		$t_pop3_host = $p_account['pop3_host'];
+		$t_pop3_user = $p_account['pop3_user'];
+		$t_pop3_password = $p_account['pop3_pass'];
+		$t_pop3->connect($t_pop3_host, 110);
+		$t_pop3->login($t_pop3_user, $t_pop3_password);
+
+		if ( 0 == $t_pop3->numMsg() ) {
+			return $v_mails;
+		}
+		for ($i = 1; $i <= $t_mail_fetch_max; $i++) {
+			$t_headers = $t_pop3->getParsedHeaders($i);
+			$t_msg = $t_pop3->getMsg($i);
+			if (true == $t_mail_parse_mime &&
+				true == isset( $t_headers['MIME-Version'] ) &&
+				'multipart' == strtolower ( substr( $t_headers['Content-Type'], 0, 9 ) ) ) {
+				$t_mail = mail_parse_content( $t_msg );
+			} else {
+				$t_mail = $t_headers;
+				$t_mail['X-Mantis-Body'] = $t_pop3->getBody($i);
+			}
+
+			if (true == $t_mail_additional) {
+				$t_mail['X-Mantis-Complete'] = $t_msg;
+			}
+
+			array_push($v_mails, $t_mail);
+			$t_pop3->deleteMsg($i);
+		}
+
+		$t_pop3->disconnect();
+		return $v_mails;
+	}
+
+	# --------------------
+	# return the mail parsed for Mantis
+	function mail_parse_content ( $p_mail ) {
+		$v_mail = array ();
+		$t_decoder = new Mail_mimeDecode($p_mail);
+		$t_params['include_bodies'] = true;
+		$t_params['decode_bodies']  = true;
+		$t_params['decode_headers'] = true;
+		$t_structure = $t_decoder->decode($t_params);
+		$v_mail['To'] = $t_structure->headers['to'];
+		$v_mail['From'] = $t_structure->headers['from'];
+		$v_mail['Subject'] = $t_structure->headers['subject'];
+		if (is_array($t_structure->parts)) {
+			$t_parts = mail_parse_parts( $t_structure->parts );
+		} else {
+                	$t_parts = array ( mail_parse_part( $t_structure ) );
+		}
+		if (strtolower($t_parts[0]['Content-Type']) == 'text/plain' ||
+			strtolower($t_parts[0]['Content-Type']) == 'text/html' ) {
+			$t_body['Body'] = $t_parts[0]['Body'];
+		} else {
+			$t_body['Body'] = "It seems, there is no text... :-o";
+		}
+		$v_mail['X-Mantis-Parts'] = $t_parts;
+		$v_mail['X-Mantis-Body'] = $t_body['Body'];
+
+		return $v_mail;
+	}
+
+	# --------------------
+	# return the parsed parts from the mail
+	function mail_parse_parts ( $p_parts ) {
+		$v_parts = array ();
+		foreach ( $p_parts as $t_part ) {
+			array_push($v_parts, mail_parse_part( $t_part ));
+		}
+
+		return $v_parts;
+	}
+
+	# --------------------
+	# return one parsed part
+	function mail_parse_part ( $p_part ) {
+		$v_part = array ();
+		$v_part['Content-Type'] = $p_part->ctype_primary."/".$p_part->ctype_secondary;
+		$v_part['Name'] = $p_part->ctype_parameters['name'];
+		$v_part['Body'] = $p_part->body;
+
+		return $v_part;
+	}
+
+	# --------------------
+	# return the mailadress from the mail's 'From'
+	function mail_parse_address ( $p_mailaddress ) {
+		if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) {
+			$v_mailaddress = $matches[1];
+		}
+
+		return $v_mailaddress;
+	}
+
+	# --------------------
+	# return the a valid username from an email address
+	function mail_user_name_from_address ( $p_mailaddress ) {
+		return preg_replace("/[@\.-]/", '_', $p_mailaddress);
+	}
+
+	# --------------------
+	# return true if there is a valid mantis bug referernce in subject
+	function mail_is_a_bugnote ( $p_mail_subject ) {
+		return preg_match("/\[([A-Za-z0-9-_\. ]*\s[0-9]{7})\]/", $p_mail_subject);
+	}
+
+	# --------------------
+	# return the bug's id from the subject
+	function mail_get_bug_id_from_subject ( $p_mail_subject ) {
+		preg_match("/\[([A-Za-z0-9-_\. ]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches);
+
+		return $v_matches[2];
+	}
+
+	# --------------------
+	# return the user id for the mail reporting user
+	function mail_get_user ($p_mailaddress) {
+		$t_mail_use_reporter	= config_get( 'mail_use_reporter' );
+		$t_mail_auto_signup	= config_get( 'mail_auto_signup' );
+		$t_mail_reporter	= config_get( 'mail_reporter' );
+		
+		$v_mailaddress = mail_parse_address( $p_mailaddress );
+
+		if ( $t_mail_use_reporter ) {
+			// Always report as mail_reporter
+			$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+		} else {
+			// Try to get the reporting users id
+			$t_reporter_id = user_get_id_by_mail ( $v_mailaddress );
+			if ( ! $t_reporter_id && $t_mail_auto_signup ) {
+				// So, we've to sign up a new user...
+				$t_user_name = mail_user_name_from_address ( $v_mailaddress );
+				user_signup($t_user_name, $v_mailaddress);
+				$t_reporter_id = user_get_id_by_name($t_user_name);
+			} elseif ( ! $t_reporter_id ) {
+				// Fall back to the default mail_reporter
+				$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+			}
+		}
+
+		// dirty: Set the identified user's id
+		// required if bug_report_mail is run via command line
+		$GLOBAL['g_cache_current_user_id'] = $t_reporter_id;
+
+		return $t_reporter_id;
+	}
+
+	# --------------------
+	# Very dirty: Adds a file to a bug.
+	function mail_add_file( $p_bug_id, $p_part ) {
+		$GLOBALS['_mail_file_'] = $p_part['Name'];
+		if ( 0 < strlen($p_part['Name']) ) {
+			$t_file_name = '/tmp/'.$p_part['Name'];
+			file_put_contents($t_file_name, $p_part['Body']);
+			file_add($p_bug_id, $t_file_name,  $p_part['Name'], $p_part['Content-Type'], 'bug');
+			unlink($t_file_name);
+		}
+	}
+
+	# --------------------
+	# Adds a bug which is reported via email
+	# Taken from bug_report.php and 
+	function mail_add_bug ( $p_mail, $p_account ) {
+		$t_mail_save_from	= config_get( 'mail_save_from' );
+
+		$t_bug_data = new BugData;
+		$t_bug_data->build			= gpc_get_string( 'build', '' );
+		$t_bug_data->platform			= gpc_get_string( 'platform', '' );
+		$t_bug_data->os				= gpc_get_string( 'os', '' );
+		$t_bug_data->os_build			= gpc_get_string( 'os_build', '' );
+		$t_bug_data->version			= gpc_get_string( 'product_version', '' );
+		$t_bug_data->profile_id			= gpc_get_int( 'profile_id', 0 );
+		$t_bug_data->handler_id			= gpc_get_int( 'handler_id', 0 );
+		$t_bug_data->view_state			= gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
+
+		if ( $p_account['category']) {
+			$t_bug_data->category			= gpc_get_string( 'category', $p_account['category'] );
+		} else {
+			$t_bug_data->category			= gpc_get_string( 'category', '' );
+		}
+		$t_bug_data->reproducibility		= 10;
+		$t_bug_data->severity			= 50;
+		$t_bug_data->priority			= gpc_get_int( 'priority', NORMAL );
+		$t_bug_data->summary			= $p_mail['Subject'];
+		if ( $t_mail_save_from ) {
+			$t_bug_data->description	= "Report from: ".$p_mail['From']."\n\n".$p_mail['X-Mantis-Body'];
+		}
+		else {
+			$t_bug_data->description	= $p_mail['X-Mantis-Body'];
+		}
+		$t_bug_data->steps_to_reproduce		= gpc_get_string( 'steps_to_reproduce', '' );
+		$t_bug_data->additional_information	= $p_mail['X-Mantis-Complete'];
+
+		$t_bug_data->project_id			= $p_account['id'];
+
+		$t_bug_data->reporter_id		= mail_get_user( $p_mail['From'] );
+
+		if ( mail_is_a_bugnote( $p_mail['Subject'] ) ) {
+			# Add a bug note
+			$t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] );
+			if ( ! bug_is_readonly( $t_bug_id ) ) {
+				bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] );
+				email_bugnote_add ( $t_bug_id );
+			}
+		} else	{
+			# Create the bug
+			$t_bug_id = bug_create( $t_bug_data );
+			email_new_bug( $t_bug_id );
+		}
+		# Add files
+		if ( null != $p_mail['X-Mantis-Parts'] ) {
+			foreach ($p_mail['X-Mantis-Parts'] as $part) {
+				mail_add_file ( $t_bug_id, $part );
+			}
+		}
+
+	}
+
+?>
+
diff -Nur mantis-0.19.3.orig/core/user_api.php mantis-0.19.3/core/user_api.php
--- mantis-0.19.3.orig/core/user_api.php	Fri Nov 19 13:29:00 2004
+++ mantis-0.19.3/core/user_api.php	Mon Oct 31 11:22:28 2005
@@ -477,6 +477,24 @@
 		}
 	}
 
+	# get a user id from an mail address
+	#  return false if the mail address does not exist
+	function user_get_id_by_mail( $p_mailaddress ) {
+		$c_mailaddress = db_prepare_string( $p_mailaddress );
+		$t_user_table = config_get( 'mantis_user_table' );
+
+		$query = "SELECT id
+				  FROM $t_user_table
+				  WHERE email='$c_mailaddress'";
+		$result = db_query( $query );
+
+		if ( 0 == db_num_rows( $result ) ) {
+			return false;
+		} else {
+			return db_result( $result );
+		}
+	}
+
 	# --------------------
 	# return all data associated with a particular user name
 	#  return false if the username does not exist
diff -Nur mantis-0.19.3.orig/doc/README.bug_report_mail mantis-0.19.3/doc/README.bug_report_mail
--- mantis-0.19.3.orig/doc/README.bug_report_mail	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.3/doc/README.bug_report_mail	Mon Oct 31 11:23:39 2005
@@ -0,0 +1,116 @@
+The current version of bug_report_mail support plain text and MIME
+encoded e-mails via POP3 Mailaccounts with PEAR's Net_POP3 package.
+
+bug_report_mail is able to recognize if mail is a reply to an already opened
+bug and adds the content as a bugnote.
+
+If you are alway running Mantis you have to alter your projects table
+with the sql/bug_report_mail.sql script.
+If not, you can create the database tables in the way described in
+the doc/INSTALL file.
+
+This patch changes the following files:
+    core/category_api.php
+    core/file_api.php
+    core/user_api.php
+    sql/db_generate.sql
+    config_defaults_inc.php
+    manage_proj_cat_edit_page.php
+    manage_proj_edit_page.php
+These files are new:
+    core/mail_api.php
+    doc/README.bug_report_mail
+    sql/bug_report_mail.sql
+    bug_report_mail.php
+    manage_proj_cat_mail_delete.php
+    manage_proj_cat_mail_update.php
+    manage_proj_mail_categories.php
+    manage_proj_mail_delete.php
+    manage_proj_mail_update.php
+
+After installing this patch, you can add a POP3 server's hostname
+and authentication data for each of your projects with the project edit form.
+
+There are two ways to receive mail with bug_report_mail:
+The secure (and default) way is to use a standard reporting user:
+You have to create a reporter account, for example 'Mail'.
+The name for this reporter account you have to write in your config_inc.php file:
+	$g_mail_reporter = "Mail";
+and then, bug_report_mail must be informed to behave like this:
+	$g_mail_use_reporter = ON;
+
+The other way is to signup new user accounts automatically.
+For using this, you have to change this
+	$g_mail_auto_signup     = OFF;
+from OFF to ON.
+Now, bug_report_mail will look for an user named like the mail's sender
+or an user which mail adress is identical.
+If no user is found, then a new account will be created.
+The new user's name will be the mail address.
+
+This could be used for attacks, but there is no other way in the moment.
+
+If you like to parse MIME encoded mails, you have to install the PEAR
+Mail_Mime package and set
+	$g_mail_parse_mime	= OFF;
+from OFF to ON.
+
+For debugging controls there is the switch
+	$g_mail_additional	= OFF;
+which puts the complete message into the Additional Information field,
+if it is activated.
+
+In this case you should decrease the amount of fetched messages via
+	$g_mail_fetch_max	= 1;
+because the mime decoding needs a lot of memory.
+
+If you'd like to use the Mail Reporter but don't save the whole message for
+making the sender's address available, set
+	$g_mail_save_from	= OFF;
+to ON.
+
+After this, bug_report_mail can be used via cron like this:
+
+*/5 *   *   *   * lynx --dump http://mantis.homepage.com/bug_report_mail.php
+or via command line interface
+*/5 *   *   *   * /usr/local/bin/php /path/to/mantis/bug_report_mail.php
+
+This line fetch bug reports from via POP3 every 5 minutes. 
+
+This addon is distributed under the same conditions as Mantis itself.
+
+Gerrit Beine, August 2004
+
+Changelog:
+Oct 2005
+	- update to Mantis 0.19.3
+Sep 2005:
+	- update to Mantis 1.0.0rc2
+	- fixed a bug in getting all categories for a project
+		category_get_all_rows in core/category_api.php
+Aug 2005:
+	- update to Mantis 1.0.0rc1
+	- include the additional patches submitted by
+		- gernot (Fixed MIME handling and save the mail's sender)
+		  mail_get_all_mails in core/mail_api.php
+		  mail_parse_content in core/mail_api.php
+		  mail_add_bug in core/mail_api.php
+		- stevenc (Fixed MIME handling)
+		  mail_parse_content in core/mail_api.php
+		- rainman (Fixed empty files bug and regex for finding a bug id)
+		  mail_add_file in core/mail_api.php
+		  mail_get_bug_id_from_subject in core/mail_api.php
+Dec 2004:
+	- update to Mantis 0.19.2
+	- add config: g_mail_parse_mime
+	- add config: g_mail_additional
+	- add config: g_mail_fetch_max
+	- make it working via CLI
+Nov 2004:
+	- update to Mantis 0.19.1
+	- add support for MIME decoding
+Sep 2004:
+	- update to Mantis 0.19.0
+Aug 2004:
+	- create patch for Mantis 0.18.3
+
diff -Nur mantis-0.19.3.orig/manage_proj_cat_edit_page.php mantis-0.19.3/manage_proj_cat_edit_page.php
--- mantis-0.19.3.orig/manage_proj_cat_edit_page.php	Mon Apr 12 23:04:34 2004
+++ mantis-0.19.3/manage_proj_cat_edit_page.php	Mon Oct 31 11:22:28 2005
@@ -15,6 +15,7 @@
 	$t_core_path = config_get( 'core_path' );
 	
 	require_once( $t_core_path.'category_api.php' );
+	require_once( $t_core_path.'mail_api.php' );
 ?>
 <?php
 	$f_project_id	= gpc_get_int( 'project_id' );
@@ -24,6 +25,10 @@
 
 	$t_row = category_get_row( $f_project_id, $f_category );
 	$t_assigned_to = $t_row['user_id'];
+	$t_mail = mail_get_account_data( $f_project_id );
+	if ( $t_mail['pop3_categories'] ) {
+		$t_category_mail = mail_category_get_account_data( $f_project_id, $f_category );
+	}
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -84,4 +89,59 @@
 	</form>
 </div>
 
+<?php  if ( $t_mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_cat_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Category Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+			<td colspan="2">
+				<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_cat_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<?php } ?>
+ 
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.3.orig/manage_proj_cat_mail_delete.php mantis-0.19.3/manage_proj_cat_mail_delete.php
--- mantis-0.19.3.orig/manage_proj_cat_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.3/manage_proj_cat_mail_delete.php	Mon Oct 31 11:22:28 2005
@@ -0,0 +1,44 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_category_delete( $f_project_id, $f_category );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-0.19.3.orig/manage_proj_cat_mail_update.php mantis-0.19.3/manage_proj_cat_mail_update.php
--- mantis-0.19.3.orig/manage_proj_cat_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.3/manage_proj_cat_mail_update.php	Mon Oct 31 11:22:28 2005
@@ -0,0 +1,59 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+		}
+	}
+
+	mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-0.19.3.orig/manage_proj_edit_page.php mantis-0.19.3/manage_proj_edit_page.php
--- mantis-0.19.3.orig/manage_proj_edit_page.php	Wed Sep 22 12:15:32 2004
+++ mantis-0.19.3/manage_proj_edit_page.php	Mon Oct 31 11:22:28 2005
@@ -18,6 +18,7 @@
 	require_once( $t_core_path . 'version_api.php' );
 	require_once( $t_core_path . 'custom_field_api.php' );
 	require_once( $t_core_path . 'icon_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
 ?>
 <?php
 	$f_project_id = gpc_get_int( 'project_id' );
@@ -25,6 +26,7 @@
 	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
 
 	$row = project_get_row( $f_project_id );
+	$mail = mail_get_account_data( $f_project_id );
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -550,5 +552,77 @@
 	</tr>
 	</table>
 </div>
+
+<?php  if ( ! $mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<br />
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="On" />
+		<input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } else { ?>
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="Off" />
+		<input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } ?>
+
 
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-0.19.3.orig/manage_proj_mail_categories.php mantis-0.19.3/manage_proj_mail_categories.php
--- mantis-0.19.3.orig/manage_proj_mail_categories.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.3/manage_proj_mail_categories.php	Mon Oct 31 11:22:28 2005
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_activate	= gpc_get_string( 'categories' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_categories( $f_project_id, $f_activate );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-0.19.3.orig/manage_proj_mail_delete.php mantis-0.19.3/manage_proj_mail_delete.php
--- mantis-0.19.3.orig/manage_proj_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.3/manage_proj_mail_delete.php	Mon Oct 31 11:22:28 2005
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_delete( $f_project_id );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-0.19.3.orig/manage_proj_mail_update.php mantis-0.19.3/manage_proj_mail_update.php
--- mantis-0.19.3.orig/manage_proj_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.3/manage_proj_mail_update.php	Mon Oct 31 11:22:28 2005
@@ -0,0 +1,58 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+		}
+	}
+
+	mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-0.19.3.orig/sql/bug_report_mail.sql mantis-0.19.3/sql/bug_report_mail.sql
--- mantis-0.19.3.orig/sql/bug_report_mail.sql	Thu Jan  1 01:00:00 1970
+++ mantis-0.19.3/sql/bug_report_mail.sql	Mon Oct 31 11:22:28 2005
@@ -0,0 +1,12 @@
+ALTER TABLE `mantis_project_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_categories` ENUM( '0', '1' ) DEFAULT '0' NOT NULL ;
+
+ALTER TABLE `mantis_project_category_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ;
+
+INSERT INTO mantis_user_table (username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_in_progress_count, failed_login_count, cookie_string) VALUES ('Mail', 'Mail Reporter', 'nomail', 'a268462c3c679a9027658c5aa723f97c', '2004-12-25 15:41:49', '2004-12-25 15:41:49', 1, 0, 25, 0, 0, 0, CONCAT(MD5(RAND()),MD5(NOW())));
diff -Nur mantis-0.19.3.orig/sql/db_generate.sql mantis-0.19.3/sql/db_generate.sql
--- mantis-0.19.3.orig/sql/db_generate.sql	Sat Nov  6 12:07:30 2004
+++ mantis-0.19.3/sql/db_generate.sql	Mon Oct 31 11:22:28 2005
@@ -330,6 +330,9 @@
   project_id int(7) unsigned NOT NULL default '0',
   category varchar(64) NOT NULL default '',
   user_id int(7) unsigned NOT NULL default '0',
+  pop3_host varchar( 255 ) default NULL,
+  pop3_user varchar( 255 ) default NULL,
+  pop3_pass varchar( 255 ) default NULL,
   PRIMARY KEY  (project_id,category)
 ) TYPE=MyISAM;
 
@@ -379,6 +382,10 @@
   access_min int(2) NOT NULL default '10',
   file_path varchar(250) NOT NULL default '',
   description text NOT NULL,
+  pop3_host varchar( 255 ) default NULL,
+  pop3_user varchar( 255 ) default NULL,
+  pop3_pass varchar( 255 ) default NULL,
+  pop3_categories enum( '0', '1' ) NOT NULL default '0',
   PRIMARY KEY  (id),
   UNIQUE KEY name (name),
   KEY id (id)
@@ -881,3 +888,5 @@
 #
 
 INSERT INTO mantis_user_table VALUES (1, 'administrator', '', 'admin', '63a9f0ea7bb98050796b649e85481845', '2003-02-16 02:03:48', '2004-07-08 23:59:22', 1, 1, 90, 3, 0, 0, CONCAT(MD5(RAND()),MD5(NOW())));
+INSERT INTO mantis_user_table VALUES (2, 'Mail', 'Mail Reporter', 'nomail', 'a268462c3c679a9027658c5aa723f97c', '2004-12-25 15:41:49', '2004-12-25 15:41:49', 1, 0, 25, 0, 0, 0, CONCAT(MD5(RAND()),MD5(NOW())));
+
mantis-0.19.3.patch (40,912 bytes)   
mantis-1.0.0rc3.patch (41,385 bytes)   
diff -Nur mantis-1.0.0rc3.orig/admin/schema.php mantis-1.0.0rc3/admin/schema.php
--- mantis-1.0.0rc3.orig/admin/schema.php	Wed Aug  3 16:20:34 2005
+++ mantis-1.0.0rc3/admin/schema.php	Mon Oct 31 11:18:41 2005
@@ -192,7 +192,10 @@
 $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_project_category_table'),"
   project_id 		 I  UNSIGNED NOTNULL PRIMARY DEFAULT '0',
   category 		C(64) NOTNULL PRIMARY DEFAULT \" '' \",
-  user_id 		 I  UNSIGNED NOTNULL DEFAULT '0'
+  user_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  pop3_host		C(250) NULL,
+  pop3_user		C(250) NULL,
+  pop3_pass		C(250) NULL
 ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS')));
 
 $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_project_file_table'),"
@@ -222,7 +225,11 @@
   view_state 		I2 NOTNULL DEFAULT '10',
   access_min 		I2 NOTNULL DEFAULT '10',
   file_path 		C(250) NOTNULL DEFAULT \" '' \",
-  description 		XS NOTNULL
+  description 		XS NOTNULL,
+  pop3_host		C(250) NULL,
+  pop3_user		C(250) NULL,
+  pop3_pass		C(250) NULL,
+  pop3_categories	L NOTNULL DEFAULT '0'
 ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS')));
 $upgrade[] = Array('CreateIndexSQL',Array('idx_project_id',config_get('mantis_project_table'),'id'));
 $upgrade[] = Array('CreateIndexSQL',Array('idx_project_name',config_get('mantis_project_table'),'name',Array('UNIQUE')));
@@ -340,5 +347,9 @@
 $upgrade[] = Array('InsertData', Array( config_get('mantis_user_table'), 
     "(username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES 
         ('administrator', '', 'root@localhost', '63a9f0ea7bb98050796b649e85481845', " . db_now() . ", " . db_now() . ", 1, 0, 90, 3, 0, 0, '" . 
+             md5( mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() ) ) . md5( time() ) . "')" ) );
+$upgrade[] = Array('InsertData', Array( config_get('mantis_user_table'), 
+    "(username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES 
+        ('mail', 'Mail Reporter', 'root@nomail@localhost', 'a268462c3c679a9027658c5aa723f97c', " . db_now() . ", " . db_now() . ", 1, 0, 25, 0, 0, 0, '" . 
              md5( mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() ) ) . md5( time() ) . "')" ) );
 ?>
diff -Nur mantis-1.0.0rc3.orig/bug_report_mail.php mantis-1.0.0rc3/bug_report_mail.php
--- mantis-1.0.0rc3.orig/bug_report_mail.php	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc3/bug_report_mail.php	Mon Oct 31 11:18:41 2005
@@ -0,0 +1,40 @@
+<?php
+error_reporting(E_ALL);
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	# This page receives an E-Mail via POP3 and generates an Report
+	header("Content-type: text/plain");
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'string_api.php' );
+	require_once( $t_core_path . 'bug_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$t_mailaccounts = mail_get_accounts();
+
+	foreach ($t_mailaccounts as $t_mailaccount) {
+		if ( config_get( 'mail_debug' ) ) {
+			print_r($t_mailaccounts);
+		}
+		$t_mails = mail_get_all_mails($t_mailaccount);
+		foreach ($t_mails as $t_mail)
+		{
+			if ( config_get( 'mail_debug' ) ) {
+				print_r($t_mail);
+			}
+			$GLOBALS['g_cache_current_user_id'] = mail_get_user( $t_mail['From'] );
+			mail_add_bug($t_mail, $t_mailaccount);
+		}
+	}
+?>
+
diff -Nur mantis-1.0.0rc3.orig/config_defaults_inc.php mantis-1.0.0rc3/config_defaults_inc.php
--- mantis-1.0.0rc3.orig/config_defaults_inc.php	Sat Oct 29 01:36:32 2005
+++ mantis-1.0.0rc3/config_defaults_inc.php	Mon Oct 31 11:18:41 2005
@@ -1617,4 +1617,37 @@
 	#   )
 	# );
 	$g_custom_group_actions = array();
+
+	######################
+	# Mail Reporting
+	######################
+
+	# --- mail reporting settings -----
+	# This tells Mantis to report all the Mail with only one account
+	$g_mail_use_reporter	= ON;
+
+	# The account's name for mail reporting
+	# Also used for fallback if a user is not found in database
+	$g_mail_reporter	= 'Mail';
+
+	# Signup new users automatically (possible security risk!)
+	# Default is OFF, ignored if mail_use_reporter is ON
+	$g_mail_auto_signup	= OFF;
+
+	# Write complete mail into the "Additional Information"
+	$g_mail_additional	= OFF;
+
+	# Write sender of the message into the bug report
+	$g_mail_save_from	= OFF;
+
+	# Parse MIME mails (may require a lot of memory)
+	$g_mail_parse_mime	= OFF;
+
+	# How many mails should be fetched at the same time
+	# If big mails with attachments should be received, specify only one
+	$g_mail_fetch_max	= 1;
+
+	# Signup new users automatically (possible security risk!)
+	# Default is OFF, ignored if mail_use_reporter is ON
+	$g_mail_debug		= OFF;
 ?>
diff -Nur mantis-1.0.0rc3.orig/core/category_api.php mantis-1.0.0rc3/core/category_api.php
--- mantis-1.0.0rc3.orig/core/category_api.php	Sat Feb 12 21:01:10 2005
+++ mantis-1.0.0rc3/core/category_api.php	Mon Oct 31 11:18:41 2005
@@ -186,7 +186,7 @@
 
 		$t_project_category_table = config_get( 'mantis_project_category_table' );
 
-		$query = "SELECT category, user_id
+		$query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass
 				FROM $t_project_category_table
 				WHERE project_id='$c_project_id' AND
 					category='$c_category'";
@@ -206,7 +206,7 @@
 
 		$t_project_category_table = config_get( 'mantis_project_category_table' );
 
-		$query = "SELECT category, user_id
+		$query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass
 				FROM $t_project_category_table
 				WHERE project_id='$c_project_id'
 				ORDER BY category";
diff -Nur mantis-1.0.0rc3.orig/core/mail_api.php mantis-1.0.0rc3/core/mail_api.php
--- mantis-1.0.0rc3.orig/core/mail_api.php	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc3/core/mail_api.php	Mon Oct 31 11:18:41 2005
@@ -0,0 +1,443 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
+
+	require_once( $t_core_dir . 'bug_api.php' );
+	require_once( $t_core_dir . 'bugnote_api.php' );
+	require_once( $t_core_dir . 'user_api.php' );
+	require_once( $t_core_dir . 'project_api.php' );
+	require_once( $t_core_dir . 'file_api.php' );
+
+	# This page receives an E-Mail via POP3 and generates an Report
+
+	require_once( 'Net/POP3.php' );
+	require_once( 'Mail/mimeDecode.php' );
+
+	# --------------------
+	# Return mail account data for the specified project
+	function mail_get_account_data( $p_project_id ) {
+		$v_project_id = db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories
+				FROM $t_project_table 
+				WHERE id='$v_project_id'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data for a project
+	function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_pop3_host	= db_prepare_string( $p_pop3_host );
+		$v_pop3_user	= db_prepare_string( $p_pop3_user );
+		$v_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+			 	SET pop3_host='$v_pop3_host',
+				pop3_user='$v_pop3_user',
+				pop3_pass='$v_pop3_pass'
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data from a project
+	function mail_delete( $p_project_id ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Activate the 'Mail per Category' feature for a project
+	function mail_categories( $p_project_id, $p_active ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+
+		if ($p_active == 'On') {
+			$v_active = 1;
+		} else {
+			$v_active = 0;
+		}
+
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$query = "UPDATE $t_project_table 
+				SET pop3_categories='$v_active'
+				WHERE id='$v_project_id'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Return mail account data for the specified project and category
+	function mail_category_get_account_data( $p_project_id, $p_category ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "SELECT pop3_host, pop3_user, pop3_pass
+				FROM $t_project_category_table 
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		$result = db_query( $query );
+
+		return db_fetch_array( $result );
+	}
+
+	# --------------------
+	# Update the mail account data for a category
+	function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+		$v_pop3_host	= db_prepare_string( $p_pop3_host );
+		$v_pop3_user	= db_prepare_string( $p_pop3_user );
+		$v_pop3_pass	= db_prepare_string( $p_pop3_pass );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host='$v_pop3_host',
+				pop3_user='$v_pop3_user',
+				pop3_pass='$v_pop3_pass'
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# Removes the mail account data for a category
+	function mail_category_delete( $p_project_id, $p_category ) {
+		$v_project_id	= db_prepare_int( $p_project_id );
+		$v_category	= db_prepare_string( $p_category );
+		
+		$t_project_table = config_get( 'mantis_project_table' );
+
+		$t_project_category_table = config_get( 'mantis_project_category_table' );
+
+		$query = "UPDATE $t_project_category_table 
+			 	SET pop3_host=NULL,
+				pop3_user=NULL,
+				pop3_pass=NULL
+				WHERE project_id='$v_project_id' AND category='$v_category'";
+
+		db_query( $query );
+
+		return true;
+	}
+
+	# --------------------
+	# return all mailaccounts
+	#  return an empty array if there are no
+	function mail_get_accounts() {
+		$v_accounts = array();
+		$t_projects = mail_project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_categories']) { echo 1;
+				$v_categories = mail_categories_get_all_rows( $t_project['id'] );
+				$v_accounts = array_merge($v_accounts, $v_categories);
+			} else {
+				array_push($v_accounts, $t_project);
+			}
+		}
+
+		return $v_accounts;
+	}
+
+	# --------------------
+	# return all projects with valid data for mail access
+	#  return an empty array if there are no such projects
+	function mail_project_get_all_rows() {
+		$v_projects = array();
+		$t_projects = project_get_all_rows();
+
+		foreach ($t_projects as $t_project) {
+			if ($t_project['pop3_host'] || $t_project['pop3_categories']) {
+				array_push($v_projects, $t_project);
+			}
+		}
+
+		return $v_projects;
+	}
+
+	# --------------------
+	# return all categories from a project with valid data for mail access
+	#  return an empty array if there are no such categories
+	function mail_categories_get_all_rows( $p_project_id ) {
+		$v_categories = array();
+		$t_categories = category_get_all_rows( $p_project_id );
+
+		foreach ($t_categories as $t_category) {
+			if ($t_category['pop3_host']) {
+				$t_category['id'] = $p_project_id;
+				array_push($v_categories, $t_category);
+			}
+		}
+
+		return $v_categories;
+	}
+
+	# --------------------
+	# return all mails for an account
+	#  return an empty array if there are no new mails
+	function mail_get_all_mails( $p_account ) {
+		$t_mail_parse_mime	= config_get( 'mail_parse_mime' );
+		$t_mail_fetch_max	= config_get( 'mail_fetch_max' );
+		$t_mail_additional	= config_get( 'mail_additional' );
+		
+		$v_mails = array();
+		$t_pop3 = &new Net_POP3();
+		$t_pop3_host = $p_account['pop3_host'];
+		$t_pop3_user = $p_account['pop3_user'];
+		$t_pop3_password = $p_account['pop3_pass'];
+		$t_pop3->connect($t_pop3_host, 110);
+		$t_pop3->login($t_pop3_user, $t_pop3_password);
+
+		if ( 0 == $t_pop3->numMsg() ) {
+			return $v_mails;
+		}
+		for ($i = 1; $i <= $t_mail_fetch_max; $i++) {
+			$t_headers = $t_pop3->getParsedHeaders($i);
+			$t_msg = $t_pop3->getMsg($i);
+			if (true == $t_mail_parse_mime &&
+				true == isset( $t_headers['MIME-Version'] ) &&
+				'multipart' == strtolower ( substr( $t_headers['Content-Type'], 0, 9 ) ) ) {
+				$t_mail = mail_parse_content( $t_msg );
+			} else {
+				$t_mail = $t_headers;
+				$t_mail['X-Mantis-Body'] = $t_pop3->getBody($i);
+			}
+
+			if (true == $t_mail_additional) {
+				$t_mail['X-Mantis-Complete'] = $t_msg;
+			}
+
+			array_push($v_mails, $t_mail);
+			#$t_pop3->deleteMsg($i);
+		}
+
+		$t_pop3->disconnect();
+		return $v_mails;
+	}
+
+	# --------------------
+	# return the mail parsed for Mantis
+	function mail_parse_content ( $p_mail ) {
+		$v_mail = array ();
+		$t_decoder = new Mail_mimeDecode($p_mail);
+		$t_params['include_bodies'] = true;
+		$t_params['decode_bodies']  = true;
+		$t_params['decode_headers'] = true;
+		$t_structure = $t_decoder->decode($t_params);
+		$v_mail['To'] = $t_structure->headers['to'];
+		$v_mail['From'] = $t_structure->headers['from'];
+		$v_mail['Subject'] = $t_structure->headers['subject'];
+		if (is_array($t_structure->parts)) {
+			$t_parts = mail_parse_parts( $t_structure->parts );
+		} else {
+                	$t_parts = array ( mail_parse_part( $t_structure ) );
+		}
+		if (strtolower($t_parts[0]['Content-Type']) == 'text/plain' ||
+			strtolower($t_parts[0]['Content-Type']) == 'text/html' ) {
+			$t_body['Body'] = $t_parts[0]['Body'];
+		} else {
+			$t_body['Body'] = "It seems, there is no text... :-o";
+		}
+		$v_mail['X-Mantis-Parts'] = $t_parts;
+		$v_mail['X-Mantis-Body'] = $t_body['Body'];
+
+		return $v_mail;
+	}
+
+	# --------------------
+	# return the parsed parts from the mail
+	function mail_parse_parts ( $p_parts ) {
+		$v_parts = array ();
+		foreach ( $p_parts as $t_part ) {
+			array_push($v_parts, mail_parse_part( $t_part ));
+		}
+
+		return $v_parts;
+	}
+
+	# --------------------
+	# return one parsed part
+	function mail_parse_part ( $p_part ) {
+		$v_part = array ();
+		$v_part['Content-Type'] = $p_part->ctype_primary."/".$p_part->ctype_secondary;
+		$v_part['Name'] = $p_part->ctype_parameters['name'];
+		$v_part['Body'] = $p_part->body;
+
+		return $v_part;
+	}
+
+	# --------------------
+	# return the mailadress from the mail's 'From'
+	function mail_parse_address ( $p_mailaddress ) {
+		if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) {
+			$v_mailaddress = $matches[1];
+		}
+
+		return $v_mailaddress;
+	}
+
+	# --------------------
+	# return the a valid username from an email address
+	function mail_user_name_from_address ( $p_mailaddress ) {
+		return preg_replace("/[@\.-]/", '_', $p_mailaddress);
+	}
+
+	# --------------------
+	# return true if there is a valid mantis bug referernce in subject
+	function mail_is_a_bugnote ( $p_mail_subject ) {
+		return preg_match("/\[([A-Za-z0-9-_\. ]*\s[0-9]{7})\]/", $p_mail_subject);
+	}
+
+	# --------------------
+	# return the bug's id from the subject
+	function mail_get_bug_id_from_subject ( $p_mail_subject ) {
+		preg_match("/\[([A-Za-z0-9-_\. ]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches);
+
+		return $v_matches[2];
+	}
+
+	# --------------------
+	# return the user id for the mail reporting user
+	function mail_get_user ($p_mailaddress) {
+		$t_mail_use_reporter	= config_get( 'mail_use_reporter' );
+		$t_mail_auto_signup	= config_get( 'mail_auto_signup' );
+		$t_mail_reporter	= config_get( 'mail_reporter' );
+		
+		$v_mailaddress = mail_parse_address( $p_mailaddress );
+
+		if ( $t_mail_use_reporter ) {
+			// Always report as mail_reporter
+			$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+		} else {
+			// Try to get the reporting users id
+			$t_reporter_id = user_get_id_by_mail ( $v_mailaddress );
+			if ( ! $t_reporter_id && $t_mail_auto_signup ) {
+				// So, we've to sign up a new user...
+				$t_user_name = mail_user_name_from_address ( $v_mailaddress );
+				user_signup($t_user_name, $v_mailaddress);
+				$t_reporter_id = user_get_id_by_name($t_user_name);
+			} elseif ( ! $t_reporter_id ) {
+				// Fall back to the default mail_reporter
+				$t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+			}
+		}
+
+		// dirty: Set the identified user's id
+		// required if bug_report_mail is run via command line
+		$GLOBAL['g_cache_current_user_id'] = $t_reporter_id;
+
+		return $t_reporter_id;
+	}
+
+	# --------------------
+	# Very dirty: Adds a file to a bug.
+	function mail_add_file( $p_bug_id, $p_part ) {
+		$GLOBALS['_mail_file_'] = $p_part['Name'];
+		if ( 0 < strlen($p_part['Name']) ) {
+			$t_file_name = '/tmp/'.$p_part['Name'];
+			file_put_contents($t_file_name, $p_part['Body']);
+			file_add($p_bug_id, $t_file_name,  $p_part['Name'], $p_part['Content-Type'], 'bug');
+			unlink($t_file_name);
+		}
+	}
+
+	# --------------------
+	# Adds a bug which is reported via email
+	# Taken from bug_report.php and 
+	function mail_add_bug ( $p_mail, $p_account ) {
+		$t_mail_save_from	= config_get( 'mail_save_from' );
+
+		$t_bug_data = new BugData;
+		$t_bug_data->build			= gpc_get_string( 'build', '' );
+		$t_bug_data->platform			= gpc_get_string( 'platform', '' );
+		$t_bug_data->os				= gpc_get_string( 'os', '' );
+		$t_bug_data->os_build			= gpc_get_string( 'os_build', '' );
+		$t_bug_data->version			= gpc_get_string( 'product_version', '' );
+		$t_bug_data->profile_id			= gpc_get_int( 'profile_id', 0 );
+		$t_bug_data->handler_id			= gpc_get_int( 'handler_id', 0 );
+		$t_bug_data->view_state			= gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
+
+		if ( $p_account['category']) {
+			$t_bug_data->category			= gpc_get_string( 'category', $p_account['category'] );
+		} else {
+			$t_bug_data->category			= gpc_get_string( 'category', '' );
+		}
+		$t_bug_data->reproducibility		= 10;
+		$t_bug_data->severity			= 50;
+		$t_bug_data->priority			= gpc_get_int( 'priority', NORMAL );
+		$t_bug_data->summary			= $p_mail['Subject'];
+		if ( $t_mail_save_from ) {
+			$t_bug_data->description	= "Report from: ".$p_mail['From']."\n\n".$p_mail['X-Mantis-Body'];
+		}
+		else {
+			$t_bug_data->description	= $p_mail['X-Mantis-Body'];
+		}
+		$t_bug_data->steps_to_reproduce		= gpc_get_string( 'steps_to_reproduce', '' );
+		$t_bug_data->additional_information	= $p_mail['X-Mantis-Complete'];
+
+		$t_bug_data->project_id			= $p_account['id'];
+
+		$t_bug_data->reporter_id		= mail_get_user( $p_mail['From'] );
+
+		if ( mail_is_a_bugnote( $p_mail['Subject'] ) ) {
+			# Add a bug note
+			$t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] );
+			if ( ! bug_is_readonly( $t_bug_id ) ) {
+				bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] );
+				email_bugnote_add ( $t_bug_id );
+			}
+		} else	{
+			# Create the bug
+			$t_bug_id = bug_create( $t_bug_data );
+			email_new_bug( $t_bug_id );
+		}
+		# Add files
+		if ( null != $p_mail['X-Mantis-Parts'] ) {
+			foreach ($p_mail['X-Mantis-Parts'] as $part) {
+				mail_add_file ( $t_bug_id, $part );
+			}
+		}
+
+	}
+
+?>
+
diff -Nur mantis-1.0.0rc3.orig/core/user_api.php mantis-1.0.0rc3/core/user_api.php
--- mantis-1.0.0rc3.orig/core/user_api.php	Fri Jul 22 17:34:02 2005
+++ mantis-1.0.0rc3/core/user_api.php	Mon Oct 31 11:18:41 2005
@@ -526,6 +526,24 @@
 		}
 	}
 
+	# get a user id from an mail address
+	#  return false if the mail address does not exist
+	function user_get_id_by_mail( $p_mailaddress ) {
+		$c_mailaddress = db_prepare_string( $p_mailaddress );
+		$t_user_table = config_get( 'mantis_user_table' );
+
+		$query = "SELECT id
+				  FROM $t_user_table
+				  WHERE email='$c_mailaddress'";
+		$result = db_query( $query );
+
+		if ( 0 == db_num_rows( $result ) ) {
+			return false;
+		} else {
+			return db_result( $result );
+		}
+	}
+
 	# --------------------
 	# return all data associated with a particular user name
 	#  return false if the username does not exist
diff -Nur mantis-1.0.0rc3.orig/doc/README.bug_report_mail mantis-1.0.0rc3/doc/README.bug_report_mail
--- mantis-1.0.0rc3.orig/doc/README.bug_report_mail	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc3/doc/README.bug_report_mail	Mon Oct 31 11:19:12 2005
@@ -0,0 +1,116 @@
+The current version of bug_report_mail support plain text and MIME
+encoded e-mails via POP3 Mailaccounts with PEAR's Net_POP3 package.
+
+bug_report_mail is able to recognize if mail is a reply to an already opened
+bug and adds the content as a bugnote.
+
+If you are alway running Mantis you have to alter your projects table
+with the sql/bug_report_mail.sql script.
+If not, you can create the database tables in the way described in
+the doc/INSTALL file.
+
+This patch changes the following files:
+    core/category_api.php
+    core/user_api.php
+    admin/schema.php
+    config_defaults_inc.php
+    manage_proj_cat_edit_page.php
+    manage_proj_edit_page.php
+These files are new:
+    core/mail_api.php
+    doc/README.bug_report_mail
+    doc/bug_report_mail.sql
+    bug_report_mail.php
+    manage_proj_cat_mail_delete.php
+    manage_proj_cat_mail_update.php
+    manage_proj_mail_categories.php
+    manage_proj_mail_delete.php
+    manage_proj_mail_update.php
+
+After installing this patch, you can add a POP3 server's hostname
+and authentication data for each of your projects with the project edit form.
+
+There are two ways to receive mail with bug_report_mail:
+The secure (and default) way is to use a standard reporting user:
+You have to create a reporter account, for example 'Mail'.
+The name for this reporter account you have to write in your config_inc.php file:
+	$g_mail_reporter = "Mail";
+and then, bug_report_mail must be informed to behave like this:
+	$g_mail_use_reporter = ON;
+
+The other way is to signup new user accounts automatically.
+For using this, you have to change this
+	$g_mail_auto_signup     = OFF;
+from OFF to ON.
+Now, bug_report_mail will look for an user named like the mail's sender
+or an user which mail adress is identical.
+If no user is found, then a new account will be created.
+The new user's name will be the mail address.
+
+This could be used for attacks, but there is no other way in the moment.
+
+If you like to parse MIME encoded mails, you have to install the PEAR
+Mail_Mime package and set
+	$g_mail_parse_mime	= OFF;
+from OFF to ON.
+
+For debugging controls there is the switch
+	$g_mail_additional	= OFF;
+which puts the complete message into the Additional Information field,
+if it is activated.
+
+In this case you should decrease the amount of fetched messages via
+	$g_mail_fetch_max	= 1;
+because the mime decoding needs a lot of memory.
+
+If you'd like to use the Mail Reporter but don't save the whole message for
+making the sender's address available, set
+	$g_mail_save_from	= OFF;
+to ON.
+
+After this, bug_report_mail can be used via cron like this:
+
+*/5 *   *   *   * lynx --dump http://mantis.homepage.com/bug_report_mail.php
+or via command line interface
+*/5 *   *   *   * /usr/local/bin/php /path/to/mantis/bug_report_mail.php
+
+This line fetch bug reports from via POP3 every 5 minutes. 
+
+This addon is distributed under the same conditions as Mantis itself.
+
+Gerrit Beine, August 2004
+
+Changelog:
+Oct 2005
+	- update to Mantis 1.0.0rc3
+	- update to Mantis 0.19.3
+Sep 2005:
+	- update to Mantis 1.0.0rc2
+	- fixed a bug in getting all categories for a project
+		category_get_all_rows in core/category_api.php
+Aug 2005:
+	- update to Mantis 1.0.0rc1
+	- include the additional patches submitted by
+		- gernot (Fixed MIME handling and save the mail's sender)
+		  mail_get_all_mails in core/mail_api.php
+		  mail_parse_content in core/mail_api.php
+		  mail_add_bug in core/mail_api.php
+		- stevenc (Fixed MIME handling)
+		  mail_parse_content in core/mail_api.php
+		- rainman (Fixed empty files bug and regex for finding a bug id)
+		  mail_add_file in core/mail_api.php
+		  mail_get_bug_id_from_subject in core/mail_api.php
+Dec 2004:
+	- update to Mantis 0.19.2
+	- add config: g_mail_parse_mime
+	- add config: g_mail_additional
+	- add config: g_mail_fetch_max
+	- make it working via CLI
+Nov 2004:
+	- update to Mantis 0.19.1
+	- add support for MIME decoding
+Sep 2004:
+	- update to Mantis 0.19.0
+Aug 2004:
+	- create patch for Mantis 0.18.3
+
diff -Nur mantis-1.0.0rc3.orig/doc/bug_report_mail.sql mantis-1.0.0rc3/doc/bug_report_mail.sql
--- mantis-1.0.0rc3.orig/doc/bug_report_mail.sql	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc3/doc/bug_report_mail.sql	Mon Oct 31 11:18:41 2005
@@ -0,0 +1,12 @@
+ALTER TABLE `mantis_project_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_categories` ENUM( '0', '1' ) DEFAULT '0' NOT NULL ;
+
+ALTER TABLE `mantis_project_category_table`
+ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL ,
+ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ;
+
+INSERT INTO mantis_user_table (username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES ('Mail', 'Mail Reporter', 'nomail', 'a268462c3c679a9027658c5aa723f97c', '2004-12-25 15:41:49', '2004-12-25 15:41:49', 1, 0, 25, 0, 0, 0, CONCAT(MD5(RAND()),MD5(NOW())));
diff -Nur mantis-1.0.0rc3.orig/manage_proj_cat_edit_page.php mantis-1.0.0rc3/manage_proj_cat_edit_page.php
--- mantis-1.0.0rc3.orig/manage_proj_cat_edit_page.php	Sat Feb 12 21:01:06 2005
+++ mantis-1.0.0rc3/manage_proj_cat_edit_page.php	Mon Oct 31 11:18:41 2005
@@ -15,6 +15,7 @@
 	$t_core_path = config_get( 'core_path' );
 
 	require_once( $t_core_path.'category_api.php' );
+	require_once( $t_core_path.'mail_api.php' );
 ?>
 <?php
 	$f_project_id	= gpc_get_int( 'project_id' );
@@ -24,6 +25,10 @@
 
 	$t_row = category_get_row( $f_project_id, $f_category );
 	$t_assigned_to = $t_row['user_id'];
+	$t_mail = mail_get_account_data( $f_project_id );
+	if ( $t_mail['pop3_categories'] ) {
+		$t_category_mail = mail_category_get_account_data( $f_project_id, $f_category );
+	}
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -84,4 +89,59 @@
 	</form>
 </div>
 
+<?php  if ( $t_mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_cat_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Category Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+			<td colspan="2">
+				<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_cat_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<?php } ?>
+ 
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-1.0.0rc3.orig/manage_proj_cat_mail_delete.php mantis-1.0.0rc3/manage_proj_cat_mail_delete.php
--- mantis-1.0.0rc3.orig/manage_proj_cat_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc3/manage_proj_cat_mail_delete.php	Mon Oct 31 11:18:41 2005
@@ -0,0 +1,44 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_category_delete( $f_project_id, $f_category );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-1.0.0rc3.orig/manage_proj_cat_mail_update.php mantis-1.0.0rc3/manage_proj_cat_mail_update.php
--- mantis-1.0.0rc3.orig/manage_proj_cat_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc3/manage_proj_cat_mail_update.php	Mon Oct 31 11:18:41 2005
@@ -0,0 +1,59 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+	$f_category	= gpc_get_string( 'category' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+		}
+	}
+
+	mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-1.0.0rc3.orig/manage_proj_edit_page.php mantis-1.0.0rc3/manage_proj_edit_page.php
--- mantis-1.0.0rc3.orig/manage_proj_edit_page.php	Tue Jul 26 14:41:02 2005
+++ mantis-1.0.0rc3/manage_proj_edit_page.php	Mon Oct 31 11:18:41 2005
@@ -18,6 +18,7 @@
 	require_once( $t_core_path . 'version_api.php' );
 	require_once( $t_core_path . 'custom_field_api.php' );
 	require_once( $t_core_path . 'icon_api.php' );
+	require_once( $t_core_path . 'mail_api.php' );
 ?>
 <?php
 	$f_project_id = gpc_get_int( 'project_id' );
@@ -25,6 +26,7 @@
 	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
 
 	$row = project_get_row( $f_project_id );
+	$mail = mail_get_account_data( $f_project_id );
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -689,5 +691,76 @@
 	</tr>
 	</table>
 </div>
+
+<?php  if ( ! $mail['pop3_categories'] ) { ?>
+<!-- MAIL ACCOUNT CHANGE -->
+<br />
+<div align="center">
+	<form method="post" action="manage_proj_mail_update.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<table class="width75" cellspacing="1">
+			<tr>
+				<td class="form-title" colspan="4">
+					<?php echo 'Mail Account Settings' ?>
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Host"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 User"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" />
+				</td>
+			</tr>
+			<tr class="row-1">
+				<td class="category" width="25%">
+					<?php echo "POP3 Password"?>
+				</td>
+				<td width="75%">
+					<input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" />
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					<input type="submit" value="<?php echo 'Set Mail Account Data' ?>" />
+				</td>
+			</tr>
+		</table>
+	</form>
+</div>
+<!-- MAIL ACCOUNT RESET -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_delete.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" />
+	</form>
+</div>
+<br />
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="On" />
+		<input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } else { ?>
+<!-- MAIL ACCOUNT CATEGORIES -->
+<div class="border-center">
+	<form method="post" action="manage_proj_mail_categories.php">
+		<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
+		<input type="hidden" name="categories" value="Off" />
+		<input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" />
+	</form>
+</div>
+<?php } ?>
 
 <?php html_page_bottom1( __FILE__ ) ?>
diff -Nur mantis-1.0.0rc3.orig/manage_proj_mail_categories.php mantis-1.0.0rc3/manage_proj_mail_categories.php
--- mantis-1.0.0rc3.orig/manage_proj_mail_categories.php	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc3/manage_proj_mail_categories.php	Mon Oct 31 11:18:41 2005
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_activate	= gpc_get_string( 'categories' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_categories( $f_project_id, $f_activate );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-1.0.0rc3.orig/manage_proj_mail_delete.php mantis-1.0.0rc3/manage_proj_mail_delete.php
--- mantis-1.0.0rc3.orig/manage_proj_mail_delete.php	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc3/manage_proj_mail_delete.php	Mon Oct 31 11:18:41 2005
@@ -0,0 +1,43 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	mail_delete( $f_project_id );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
diff -Nur mantis-1.0.0rc3.orig/manage_proj_mail_update.php mantis-1.0.0rc3/manage_proj_mail_update.php
--- mantis-1.0.0rc3.orig/manage_proj_mail_update.php	Thu Jan  1 01:00:00 1970
+++ mantis-1.0.0rc3/manage_proj_mail_update.php	Mon Oct 31 11:18:41 2005
@@ -0,0 +1,58 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+	# Copyright (C) 2004  Gerrit Beine - gerrit.beine@pitcom.de
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+
+	# --------------------------------------------------------
+	# $Id$
+	# --------------------------------------------------------
+
+	require_once( 'core.php' );
+
+	$t_core_path = config_get( 'core_path' );
+
+	require_once( $t_core_path . 'mail_api.php' );
+
+	$f_project_id	= gpc_get_int( 'project_id' );
+	$f_pop3_host	= gpc_get_string( 'pop3_host' );
+	$f_pop3_user	= gpc_get_string( 'pop3_user' );
+	$f_pop3_pass	= gpc_get_string( 'pop3_pass' );
+
+	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
+
+	if ( is_blank( $f_pop3_host ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+	else {
+		if ( is_blank( $f_pop3_user ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+	}
+		if ( is_blank( $f_pop3_pass ) ) {
+			trigger_error( ERROR_EMPTY_FIELD, ERROR );
+		}
+	}
+
+	mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass );
+
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+
+	html_page_top1();
+
+	html_meta_redirect( $t_redirect_url );
+
+	html_page_top2();
+?>
+
+<br />
+<div align="center">
+<?php
+	echo lang_get( 'operation_successful' ) . '<br />';
+
+	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
+?>
+</div>
+
+<?php html_page_bottom1( __FILE__ ) ?>
+
mantis-1.0.0rc3.patch (41,385 bytes)   
mantis-1.0.3.patch.gz (34,492 bytes)
mantis-1.0.5.patch.gz (109,299 bytes)
Parser.php (5,175 bytes)   
<?php

require_once( 'Mail/mimeDecode.php' );

class Mail_Parser
{
    private $_parse_html = false;
    private $_parse_mime = false;
    private $_htmlparser = "/usr/bin/w3m -T text/html -dump";
    private $_htmltmpdir = "/tmp";

    private $_file;
    private $_content;
    
    private $_from;
    private $_subject;
    private $_transferencoding;
    private $_body;
    private $_parts = array ( );
    private $_ctype = array ( );

    function __construct( $options = array() ) {
	$this->_parse_mime = $options['parse_mime'];
	$this->_parse_html = $options['parse_html'];
	$this->_htmlparser = $options['htmlparser'];
	$this->_htmltmpdir = $options['htmltmpdir'];
    }
    
    public function setInputString ( $content ) {
        $this->_content = $content;
    }
    
    public function setInputFile( $file ) {
        $this->_file = $file;
        $this->_content = file_get_contents( $this->_file );
    }

    public function parse() {
        $decoder = new Mail_mimeDecode( $this->_content );
        $params['include_bodies'] = true;
        $params['decode_bodies'] = true;
        $params['decode_headers'] = true;
        $structure = $decoder->decode( $params );
	$this->parseStructure( $structure );
	unset( $this->_content );
    }
    
    public function from() {
	return $this->_from;
    }

    public function subject() {
	return $this->_subject;
    }

    public function priority() {
	return $this->_priority;
    }

    public function body() {
	return $this->_body;
    }

    public function parts() {
	return $this->_parts;
    }
    
    private function parseStructure( $structure ) {
	$this->setFrom( $structure->headers['from'] );
	$this->setSubject( $structure->headers['subject'] );
	$this->setContentType( $structure->ctype_primary, $structure->ctype_secondary );
	if ( isset( $structure->headers['x-priority'] ) ) {
	    $this->setPriority( $structure->headers['x-priority'] );
	}
	if ( isset( $structure->headers['content-transfer-encoding'] ) ) {
	    $this->setTransferEncoding( $structure->headers['content-transfer-encoding'] );
	}
	if ( isset( $structure->body ) ) {
	    $this->setBody( $structure->body );
	}
	if ( $this->_parse_mime && isset( $structure->parts ) ) {
	    $this->setParts( $structure->parts );
	}
    }

    private function setFrom( $from ) {
	$this->_from = quoted_printable_decode( $from );
    }

    private function setSubject( $subject ) {
	$this->_subject = quoted_printable_decode( $subject );
    }

    private function setPriority( $priority ) {
	$this->_priority = $priority;
    }

    private function setTransferEncoding( $transferencoding ) {
	$this->_transferencoding = $transferencoding;
    }
    
    private function setContentType( $primary, $secondary ) {
        $this->_ctype['primary'] = $primary;
	$this->_ctype['secondary'] = $secondary;
    }

    private function setBody( $body ) {
        if ( 0 == strlen( $body ) || 0 != strlen( $this->_body ) ) {
	    	return;
		}
		if ( 'text' == $this->_ctype['primary'] &&
		     'plain' == $this->_ctype['secondary'] ) {
		    switch ( $this->_transferencoding ) {
		        case 'base64':
		        case '8bit':
		        case 'quoted-printable':
			    $this->_body = quoted_printable_decode( $body );
			    break;
			default:
			    $this->_body = $body;
			    break;
		    }
		} elseif ( $this->_parse_html &&
		           'text' == $this->_ctype['primary'] &&
		           'html' == $this->_ctype['secondary'] ) {
	            $file = $this->_htmltmpdir . "/" . md5 ( $body );
	            file_put_contents( $file, $body );
// (brody):
// unix/piped:	$this->_body = shell_exec("cat " . $file . " | " . $this->_htmlparser);
// windows and parameter:
	            $this->_body = shell_exec($this->_htmlparser . " " . $file);
	            unlink($file);
		}
    }
    
    private function setParts( &$parts) {
		$i = 0;
		if ( 'multipart' == $parts[$i]->ctype_primary ) {
		    $this->setParts( $parts[$i]->parts ); 
		    $i++;
		}
		// FIX(brody): use parts of type (text/plain,html) as body , if not classified as attachment (disposition)
	    if ( 'text' == $parts[$i]->ctype_primary &&
		    in_array( $parts[$i]->ctype_secondary, array( 'plain', 'html' ) ) && (! isset ($parts[$i]->disposition)) ) {
		    $this->setContentType( $parts[$i]->ctype_primary, $parts[$i]->ctype_secondary );
		    $this->setTransferEncoding( $parts[$i]->headers['content-transfer-encoding'] );
		    $this->setBody( $parts[$i]->body );
		    $i++;
		}
	        if ( isset( $parts[$i] ) &&
		    'text' == $parts[$i]->ctype_primary &&
		    'html' == $parts[$i]->ctype_secondary ) {
		    $i++;
		}
		for ( $i; $i < count( $parts ); $i++ ) {
		    $this->addPart( $parts[$i] );
		}
    }
    
    private function addPart( &$part ) {
	$p['ctype'] = $part->ctype_primary . "/" . $part->ctype_secondary;
	if ( isset( $part->ctype_parameters['name'] ) ) {
	    $p['name'] = $part->ctype_parameters['name'];
	}
	$p['body'] = $part->body;
	$this->_parts[] = $p;
    }
}

?>
Parser.php (5,175 bytes)   
Parser.php.patch (801 bytes)   
128c128
<             $ this ->_body = shell_exec( " cat " . $file . " | " . $this->_htmlparser) ;
---
>             / / ( brody ) :
128a129,131
> // unix/piped:	$this->_body = shell_exec("cat " . $file . " | " . $this->_htmlparser);
> // windows and parameter:
> 	            $this->_body = shell_exec($this->_htmlparser . " " . $file);
133c136
<     private function setParts( &$parts ) {	$i = 0;
---
>     private function setParts( &$parts) {		$i = 0;
137a141
> 		// FIX(brody): use parts of type (text/plain,html) as body , if not classified as attachment (disposition)
139c143
< 		    in_array( $parts[$i]->ctype_secondary, array( 'plain', 'html' ) )  ) {
---
> 		    in_array( $parts[$i]->ctype_secondary, array( 'plain', 'html' ) ) && (! isset ($parts[$i]->disposition)) ) {
Parser.php.patch (801 bytes)   
mail_api.php.patch (2,517 bytes)   
220a221
> 		$t_mail_debug		 = config_get( 'mail_debug' );
221a223,224
> 		// get stamp of (prev) last processed mail
> 		$t_mail_last_processed = config_get( 'pop3_last_mail_ds',null ,null ,$p_account['id']);
251a255
> 				if ( null == $t_mail_last_processed || $t_mail['Datestamp'] > $t_mail_last_processed ) {
253a258,263
> 					$t_mail_last_processed = $t_mail['Datestamp'];
> 				} else {
> 					if ( $t_mail_debug ) {
> 						echo "\nMail skipped - to old against last checked mail!\n";
> 					}
> 				}
261a272,273
> 		// save stamp of last processed mail
> 		config_set( 'pop3_last_mail_ds', $t_mail_last_processed , null, $p_account['id']);
287a300,301
> 		$t_mail['Datestamp'] = strtotime($t_mp->date());		
> 		
302c316
< 		if ( true == $t_mail_use_bug_priority ) {
---
> 		/ / FIXED( wb  ) 
302a317
>         if ( $t_mail_use_bug_priority ) {
308,309c323,324
< 		if ( true == $t_mail_additional ) {
<  $ t_mail [ ' X-Mantis-Complete'] = $t_msg;
---
> 		/ / FIXED( wb  ) 
> if ( $ t_mail_additional ) { 
309a325
>         	$t_mail['X-Mantis-Complete'] = $p_mail;
383c401
< 	function mail_add_file( $p_bug_id, $p_part, $number  ) {
---
> 	function mail_add_file( $p_bug_id, $p_part, $number = 0 ) {
384a403,405
> 		$t_attachment_directory	= config_get( 'mail_tmp_directory' );
> 		
> 		if ( is_dir($t_attachment_directory) && is_writeable($t_attachment_directory) ) {
386c407
< 				$t_file_name =  ' /tmp/'.$p_part['name'];
---
> 				$t_file_name = $t_attachment_directory . ' /'.$p_part['name'];
388c409
< 			file_add($ p_bug_id, $t_file_name,  $number . " -".$p_part['name'], $p_part['ctype'], 'bug') ;
---
> 			if($ number > 0 ) {
388a410,413
> 					file_add($p_bug_id, $t_file_name,  $number."_".$p_part['name'], $p_part['ctype'], 'bug');
> 				} else {
> 					file_add($p_bug_id, $t_file_name,  $p_part['name'], $p_part['ctype'], 'bug');
> 				}
391a417
> 	}
395c421
< 		$t_mail_directory	= config_get( 'mail_directory' );
---
> 		$t_mail_directory	= config_get( 'mail_tmp_directory' );
443a470,473
> 				# FIX(wb) Wo made (optionally) the note (From)
> 				if ( $t_mail_save_from ) {
> 					bugnote_add ( $t_bug_id, "(<b>".$p_mail['From']."</b>):\n".$p_mail['X-Mantis-Body'] );
> 				} else {
444a475
> 				}
456c487
< 		# Add files
---
> 		# Add files, number removed
458c489
< 			$number = 1;
---
> #			$number = 1;
460c491
< 				mail_add_file ( $t_bug_id, $part, $number );
---
> 				mail_add_file ( $t_bug_id, $part );
mail_api.php.patch (2,517 bytes)   
mail_api.php.patch-v2 (2,616 bytes)
1202890957da93014a9e1d86b8b0fc26e66b637721 (12,353 bytes)   
Received: from dapozzom01 ([10.221.4.105])
          by servpro.lispa.it (Lotus Domino Release 7.0.2FP2)
          with ESMTP id 2008021309202397-6980 ;
          Wed, 13 Feb 2008 09:20:23 +0100 
From: "Marco Da Pozzo" <marco.dapozzo@lombardia-servizi.it>
To: "mantisLoto" <mantis.Loto@lombardia-servizi.it>
Subject: oggetto
Date: Wed, 13 Feb 2008 09:22:25 +0100
MIME-Version: 1.0
X-Mailer: Microsoft Office Outlook, Build 11.0.5510
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
Thread-Index: AchuGY7No6xm4wacSNy1ptxAWPileA==
X-MIMETrack: Itemize by SMTP Server on SERVPRO/Lombardia Informatica/IT(Release 7.0.2FP2|May
 14, 2007) at 13/02/2008 09:20:24,
	Serialize by Router on SERVPRO/Lombardia Informatica/IT(Release 7.0.2FP2|May
 14, 2007) at 13/02/2008 09:20:25,
	Serialize complete at 13/02/2008 09:20:25,
	Itemize by Router on SERVPRO/Lombardia Informatica/IT(Release 7.0.2FP2|May
 14, 2007) at 13/02/2008 09:20:25,
	Serialize by POP3 Server on SERVPRO/Lombardia Informatica/IT(Release
 7.0.2FP2|May 14, 2007) at 13/02/2008 09:20:36,
	Serialize complete at 13/02/2008 09:20:36
Message-ID: <OFA1C24376.35B8287E-ONC12573EE.002DD070@lispa.it>
Content-Type: multipart/mixed;
	boundary="----=_NextPart_000_00BE_01C86E21.F267BC80"


------=_NextPart_000_00BE_01C86E21.F267BC80
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset="US-ASCII"

Corpo mail
Corpo mail
Corpo mail
Corpo mailCorpo mail
Corpo mailCorpo mail
Corpo mailCorpo mail
Corpo mailCorpo mail
Corpo mailCorpo mail
Corpo mailCorpo mail
Corpo mailCorpo mail
Corpo mail

------=_NextPart_000_00BE_01C86E21.F267BC80
Content-Type: application/octet-stream;
	name="README.bug_report_mail"
Content-Disposition: attachment;
	filename="README.bug_report_mail"
Content-Transfer-Encoding: base64

VGhlIGN1cnJlbnQgdmVyc2lvbiBvZiBidWdfcmVwb3J0X21haWwgc3VwcG9ydCBwbGFpbiB0ZXh0
IGFuZCBNSU1FDQplbmNvZGVkIGUtbWFpbHMgdmlhIFBPUDMgTWFpbGFjY291bnRzIHdpdGggUEVB
UidzIE5ldF9QT1AzIHBhY2thZ2UuDQoNCmJ1Z19yZXBvcnRfbWFpbCBpcyBhYmxlIHRvIHJlY29n
bml6ZSBpZiBtYWlsIGlzIGEgcmVwbHkgdG8gYW4gYWxyZWFkeSBvcGVuZWQNCmJ1ZyBhbmQgYWRk
cyB0aGUgY29udGVudCBhcyBhIGJ1Z25vdGUuDQoNCklmIHlvdSBhcmUgYWx3YXkgcnVubmluZyBN
YW50aXMgeW91IGhhdmUgdG8gYWx0ZXIgeW91ciBwcm9qZWN0cyB0YWJsZQ0Kd2l0aCB0aGUgc3Fs
L2J1Z19yZXBvcnRfbWFpbC5zcWwgc2NyaXB0Lg0KSWYgbm90LCB5b3UgY2FuIGNyZWF0ZSB0aGUg
ZGF0YWJhc2UgdGFibGVzIGluIHRoZSB3YXkgZGVzY3JpYmVkIGluDQp0aGUgZG9jL0lOU1RBTEwg
ZmlsZS4NCg0KVGhpcyBwYXRjaCBjaGFuZ2VzIHRoZSBmb2xsb3dpbmcgZmlsZXM6DQogICAgY29y
ZS9jYXRlZ29yeV9hcGkucGhwDQogICAgY29yZS9maWxlX2FwaS5waHANCiAgICBjb3JlL3VzZXJf
YXBpLnBocA0KICAgIGFkbWluL3NjaGVtYS5waHANCiAgICBjb25maWdfZGVmYXVsdHNfaW5jLnBo
cA0KICAgIG1hbmFnZV9wcm9qX2NhdF9lZGl0X3BhZ2UucGhwDQogICAgbWFuYWdlX3Byb2pfZWRp
dF9wYWdlLnBocA0KVGhlc2UgZmlsZXMgYXJlIG5ldzoNCiAgICBNYWlsL21pbWUucGhwDQogICAg
TWFpbC9taW1lRGVjb2RlLnBocA0KICAgIE1haWwvbWltZVBhcnQucGhwDQogICAgTWFpbC9QYXJz
ZXIucGhwDQogICAgTmV0L1BPUDMucGhwDQogICAgTmV0L1NvY2tldC5waHANCiAgICBjb3JlL21h
aWxfYXBpLnBocA0KICAgIGRvYy9SRUFETUUuYnVnX3JlcG9ydF9tYWlsDQogICAgZG9jL2J1Z19y
ZXBvcnRfbWFpbC5zcWwNCiAgICBQRUFSLnBocA0KICAgIGJ1Z19yZXBvcnRfbWFpbC5waHANCiAg
ICBtYW5hZ2VfcHJval9jYXRfbWFpbF9kZWxldGUucGhwDQogICAgbWFuYWdlX3Byb2pfY2F0X21h
aWxfdXBkYXRlLnBocA0KICAgIG1hbmFnZV9wcm9qX21haWxfY2F0ZWdvcmllcy5waHANCiAgICBt
YW5hZ2VfcHJval9tYWlsX2RlbGV0ZS5waHANCiAgICBtYW5hZ2VfcHJval9tYWlsX3VwZGF0ZS5w
aHANCg0KQWZ0ZXIgaW5zdGFsbGluZyB0aGlzIHBhdGNoLCB5b3UgY2FuIGFkZCBhIFBPUDMgc2Vy
dmVyJ3MgaG9zdG5hbWUNCmFuZCBhdXRoZW50aWNhdGlvbiBkYXRhIGZvciBlYWNoIG9mIHlvdXIg
cHJvamVjdHMgd2l0aCB0aGUgcHJvamVjdCBlZGl0IGZvcm0uDQoNClRoZXJlIGFyZSB0d28gd2F5
cyB0byByZWNlaXZlIG1haWwgd2l0aCBidWdfcmVwb3J0X21haWw6DQpUaGUgc2VjdXJlIChhbmQg
ZGVmYXVsdCkgd2F5IGlzIHRvIHVzZSBhIHN0YW5kYXJkIHJlcG9ydGluZyB1c2VyOg0KWW91IGhh
dmUgdG8gY3JlYXRlIGEgcmVwb3J0ZXIgYWNjb3VudCwgZm9yIGV4YW1wbGUgJ01haWwnLg0KVGhl
IG5hbWUgZm9yIHRoaXMgcmVwb3J0ZXIgYWNjb3VudCB5b3UgaGF2ZSB0byB3cml0ZSBpbiB5b3Vy
IGNvbmZpZ19pbmMucGhwIGZpbGU6DQoJJGdfbWFpbF9yZXBvcnRlciA9ICJNYWlsIjsNCmFuZCB0
aGVuLCBidWdfcmVwb3J0X21haWwgbXVzdCBiZSBpbmZvcm1lZCB0byBiZWhhdmUgbGlrZSB0aGlz
Og0KCSRnX21haWxfdXNlX3JlcG9ydGVyID0gT047DQoNClRoZSBvdGhlciB3YXkgaXMgdG8gc2ln
bnVwIG5ldyB1c2VyIGFjY291bnRzIGF1dG9tYXRpY2FsbHkuDQpGb3IgdXNpbmcgdGhpcywgeW91
IGhhdmUgdG8gY2hhbmdlIHRoaXMNCgkkZ19tYWlsX2F1dG9fc2lnbnVwICAgICA9IE9GRjsNCmZy
b20gT0ZGIHRvIE9OLg0KTm93LCBidWdfcmVwb3J0X21haWwgd2lsbCBsb29rIGZvciBhbiB1c2Vy
IG5hbWVkIGxpa2UgdGhlIG1haWwncyBzZW5kZXINCm9yIGFuIHVzZXIgd2hpY2ggbWFpbCBhZHJl
c3MgaXMgaWRlbnRpY2FsLg0KSWYgbm8gdXNlciBpcyBmb3VuZCwgdGhlbiBhIG5ldyBhY2NvdW50
IHdpbGwgYmUgY3JlYXRlZC4NClRoZSBuZXcgdXNlcidzIG5hbWUgd2lsbCBiZSB0aGUgbWFpbCBh
ZGRyZXNzLg0KDQpUaGlzIGNvdWxkIGJlIHVzZWQgZm9yIGF0dGFja3MsIGJ1dCB0aGVyZSBpcyBu
byBvdGhlciB3YXkgaW4gdGhlIG1vbWVudC4NCg0KSWYgeW91IGxpa2UgdG8gcGFyc2UgTUlNRSBl
bmNvZGVkIG1haWxzLCB5b3UgaGF2ZSB0byBpbnN0YWxsIHRoZSBQRUFSDQpNYWlsX01pbWUgcGFj
a2FnZSBhbmQgc2V0DQoJJGdfbWFpbF9wYXJzZV9taW1lCT0gT0ZGOw0KZnJvbSBPRkYgdG8gT04u
DQoNCkZvciBwYXJzaW5nIEhUTUwgbWFpbHMsIHNldCANCgkkZ19tYWlsX3BhcnNlX2h0bWwJPSBP
TjsNCmFuZCBzZXQgDQoJJGdfbWFpbF9odG1sX3BhcnNlcg0KdG8gYSB2YWxpZCB0b29sIGZvciBk
dW1waW5nIEhUTUwgY29udGVudHMgKCIvdXNyL2Jpbi93M20gLVQgdGV4dC9odG1sIC1kdW1wIikN
CkFsc28sIA0KCSRnX21haWxfdG1wX2RpcmVjdG9yeQ0KaGFzIHRvIGJlIGEgdmFsaWQgZGlyZWN0
b3J5IHRvIGhhbmRsZSB3cml0ZSB0aGUgdGVtcG9yYXJ5IEhUTUwgZmlsZXMuDQoNCkZvciBkZWJ1
Z2dpbmcgY29udHJvbHMgdGhlcmUgaXMgdGhlIHN3aXRjaA0KCSRnX21haWxfYWRkaXRpb25hbAk9
IE9GRjsNCndoaWNoIHB1dHMgdGhlIGNvbXBsZXRlIG1lc3NhZ2UgaW50byB0aGUgQWRkaXRpb25h
bCBJbmZvcm1hdGlvbiBmaWVsZCwNCmlmIGl0IGlzIGFjdGl2YXRlZC4NCg0KSWYgeW91IGxpa2Ug
dG8gc2VlIHdoYXQgYnVnX3JlcG9ydF9tYWlsLnBocCBpcyBkb2luZywgc2V0DQoJJGdfbWFpbF9k
ZWJ1ZyA9IE9OOw0KDQpJZiAkZ19tYWlsX2RpcmVjdG9yeSBpcyBhIHZhbGlkIGRpcmVjdG9yeSBh
bmQgYWxzbyB3cml0ZWFibGUsDQp0aGUgY29tcGxldGUgbWFpbHMgd2lsbCBiZSBzYXZlZCB0byB0
aGlzIGRpcmVjdG9yeS4NCg0KSW4gdGhpcyBjYXNlIHlvdSBzaG91bGQgZGVjcmVhc2UgdGhlIGFt
b3VudCBvZiBmZXRjaGVkIG1lc3NhZ2VzIHZpYQ0KCSRnX21haWxfZmV0Y2hfbWF4CT0gMTsNCmJl
Y2F1c2UgdGhlIG1pbWUgZGVjb2RpbmcgbmVlZHMgYSBsb3Qgb2YgbWVtb3J5Lg0KDQpJZiB5b3Un
ZCBsaWtlIHRvIHVzZSB0aGUgTWFpbCBSZXBvcnRlciBidXQgZG9uJ3Qgc2F2ZSB0aGUgd2hvbGUg
bWVzc2FnZSBmb3INCm1ha2luZyB0aGUgc2VuZGVyJ3MgYWRkcmVzcyBhdmFpbGFibGUsIHNldA0K
CSRnX21haWxfc2F2ZV9mcm9tCT0gT0ZGOw0KdG8gT04uDQoNCklmIHlvdSBkb24ndCB3YW50IGJ1
Z19yZXBvcnRfbWFpbC5waHAgdG8gZGVsZXRlIHRoZSBtYWlscyBmcm9tIHlvdXIgUE9QMw0Kc2Vy
dmVyIHNldA0KCSRnX21haWxfZGVsZXRlID0gT0ZGOw0KVXNlIHRoaXMgY2FyZWZ1bGx5IQ0KDQpX
aXRoIA0KCSRnX21haWxfYXV0aF9tZXRob2QNCnlvdSBtYXkgc2V0IHRoZSBBVVRIIG1ldGhvZCBm
b3IgeW91ciBQT1AzIHNlcnZlci4gRGVmYXVsdCBpcyAnVVNFUicsDQpidXQgJ0RJR0VTVC1NRDUn
LCdDUkFNLU1ENScsJ0xPR0lOJywnUExBSU4nLCdBUE9QJyBhcmUgYWxzbyBwb3NzaWJsZQ0KDQpG
b3IgdXNpbmcgdGhlIHByaW9yaXR5IG9mIHRoZSBtYWlscyBmb3IgdGhlIGJ1ZyBwcmlvcml0eSwg
c2V0DQoJJGdfbWFpbF91c2VfYnVnX3ByaW9yaXR5ID0gT047DQpUaGUNCgkkZ19tYWlsX2J1Z19w
cmlvcml0eV9kZWZhdWx0ID0gTk9STUFMOw0KaXMgdGhlIGRlZmF1bHQgdmFsdWUgZm9yIHRoZSBw
cmlvcml0eSBvZiBuZXcgYnVnIGVudHJpZXMuDQoNCkRlZmF1bHQgYnVnIGNhdGVnb3J5IGZvciBt
YWlsIHJlcG9ydGVkIGJ1Z3MgKERlZmF1bHRzIHRvICJkZWZhdWx0X2J1Z19jYXRlZ29yeSIpDQpC
ZWNhdXNlIGluIE1hbnRpcyAxLjEuMGEzIGEgY2F0ZWdvcnkgaXMgcmVxdWlyZWQsIHdlIG5lZWQg
YSBkZWZhdWx0IGNhdGVnb3J5IGZvciBpc3N1ZXMgcmVwb3J0ZWQgYnkgZW1haWwuDQpNYWtlIHN1
cmUgdGhlIGNhdGVnb3J5IGV4aXN0cyBhbmQgaXQgaGFzIGJlZW4gY29uZmlndXJlZCBjb3JyZWN0
bHkNCgkkZ19tYWlsX2RlZmF1bHRfYnVnX2NhdGVnb3J5ID0gJyVkZWZhdWx0X2J1Z19jYXRlZ29y
eSUnOw0KDQpBZnRlciB0aGlzLCBidWdfcmVwb3J0X21haWwgY2FuIGJlIHVzZWQgdmlhIGNyb24g
bGlrZSB0aGlzOg0KDQoqLzUgKiAgICogICAqICAgKiBseW54IC0tZHVtcCBodHRwOi8vbWFudGlz
LmhvbWVwYWdlLmNvbS9idWdfcmVwb3J0X21haWwucGhwDQpvciB2aWEgY29tbWFuZCBsaW5lIGlu
dGVyZmFjZQ0KKi81ICogICAqICAgKiAgICogL3Vzci9sb2NhbC9iaW4vcGhwIC9wYXRoL3RvL21h
bnRpcy9idWdfcmVwb3J0X21haWwucGhwDQoNClRoaXMgbGluZSBmZXRjaCBidWcgcmVwb3J0cyBm
cm9tIHZpYSBQT1AzIGV2ZXJ5IDUgbWludXRlcy4gDQoNClRoaXMgYWRkb24gaXMgZGlzdHJpYnV0
ZWQgdW5kZXIgdGhlIHNhbWUgY29uZGl0aW9ucyBhcyBNYW50aXMgaXRzZWxmLg0KDQpHZXJyaXQg
QmVpbmUsIEF1Z3VzdCAyMDA0DQoNCkNoYW5nZWxvZzoNCkp1biAyMDA3DQoJLSB1cGRhdGUgdG8g
TWFudGlzIDEuMS4wYTMNCgktIFN1cHBvcnQgZm9yIFBIUCA0ICggfjEzODA1ICkNCgktIEZpeGVk
IGEgYnVnIHdpdGggcHJvY2Vzc2luZyBwcmlvcml0eSdzIG9mIGVtYWlscyAocHJpb3JpdHkgY2xh
c3MgdmFyaWFibGUgZGlkbid0IGV4aXN0IGluIE1haWwvUGFyc2VyLnBocCkNCgktIFVwZGF0ZXMg
dG8gdGhlIGxhdGVzdCBQRUFSIHBhY2thZ2VzDQoJLSBwcmludF9yIGNoYW5nZWQgdG8gdmFyX2R1
bXAncyAoV29ya3MgYmV0dGVyIGlmIHlvdSBoYXZlIHhkZWJ1ZyBleHRlbnNpb24gaW5zdGFsbGVk
KQ0KCS0gTmV3IGNvbmZpZyBzZXR0aW5nIGNhbGxlZDoNCgkJIyBEZWZhdWx0IGJ1ZyBjYXRlZ29y
eSBmb3IgbWFpbCByZXBvcnRlZCBidWdzIChEZWZhdWx0cyB0byAiZGVmYXVsdF9idWdfY2F0ZWdv
cnkiKQ0KCQkjIEJlY2F1c2UgaW4gTWFudGlzIDEuMS4wYTMgYSBjYXRlZ29yeSBpcyByZXF1aXJl
ZCwgd2UgbmVlZCBhIGRlZmF1bHQgY2F0ZWdvcnkgZm9yIGlzc3VlcyByZXBvcnRlZCBieSBlbWFp
bC4NCgkJIyBNYWtlIHN1cmUgdGhlIGNhdGVnb3J5IGV4aXN0cyBhbmQgaXQgaGFzIGJlZW4gY29u
ZmlndXJlZCBjb3JyZWN0bHkNCgkJJGdfbWFpbF9kZWZhdWx0X2J1Z19jYXRlZ29yeSA9ICclZGVm
YXVsdF9idWdfY2F0ZWdvcnklJzsNCgktIEZpeGVkIGEgbWlzc2luZyB2YXJpYWJsZSBpbiB0aGUg
ZnVuY3Rpb246ICJtYWlsX3Byb2Nlc3NfYWxsX21haWxzIg0KCQkkdF9tYWlsX2RlYnVnIHdhcyBu
b3Qgc2V0IGFuZCB3b3VsZCBjYXVzZSBub3RpY2UgbGV2ZWwgZXJyb3JzIGFuZCBkZWJ1ZyBtb2Rl
IGluIHRoaXMgZnVuY3Rpb24gd291bGRuJ3Qgd29yayAoIH4xMzg1NCApDQoJLSBFbWFpbHMgYXJl
IG5vdyBub3QgYWxsd2F5cyBzYXZlZCB0byBkaXNrICggfjEzODU0ICkNCgktIE1hZGUgc3VyZSAk
dF9tYWlsWydYLU1hbnRpcy1Db21wbGV0ZSddIHdvdWxkIGFsbHdheXMgYmUgcG9wdWxhdGVkICgg
d2l0aCBudWxsIHZhbHVlIGlmIHRoZSBjb25maWcgIm1haWxfYWRkaXRpb25hbCIgd2FzIGRpc2Fi
bGVkICkNCgktIEFkZGluZyBhdHRhY2htZW50cyB0byBidWcgaXRlbXMgbm93IGFsc28gd29ya3Mg
b24gV2luZG93cyBzeXN0ZW1zIChSZW1vdmVkIGhhcmRjb2RlZCBkaXJlY3RvcnkgcGFydCAiL3Rt
cC8iKS4NCgktIFRoZSBzdWJqZWN0IG9mIGFuIGVtYWlsIGlzIG5vdyBhbHNvIHRyaW1tZWQgYmVm
b3JlIHN0b3JpbmcgaXQgaW4gJHRfYnVnX2RhdGEtPnN1bW1hcnkuIExpa2UgaXQgaXMgaW4gYnVn
X3JlcG9ydC5waHANCgktIEZpeGVkIHByb2JsZW0gd2l0aCBkdXBsaWNhdGUgYXR0YWNobWVudHMg
KCB+MTQyNTUgYW5kIH4xNDI1NiApDQpBdWcgMjAwNg0KCS0gdXBkYXRlIHRvIE1hbnRpcyAxLjAu
NQ0KCS0gbWFpbCBwYXJzaW5nIGNvbXBsZXRlbHkgcmV3cml0dGVuDQoJLSBpbmNsdWRlIGFkZGl0
aW9uYWwgcGF0Y2hlcyBzdWJtaXR0ZWQgYnkNCgkJLSBjYXMgKGhhbmRsaW5nIG9mIGF0dGFjaG1l
bnRzIGFuZCBlbXB0eSBmaWVsZHMpDQoJCSAgbWFpbF9hZGRfZmlsZSBpbiBjb3JlL21haWwuYXBp
DQoJCSAgbWFpbF9hZGRfYnVnIGluIGNvcmUvbWFpbC5hcGkNCk1heSAyMDA2DQoJLSB1cGRhdGUg
dG8gTWFudGlzIDEuMC4zDQoJLSBhZGRlZCBzdXBwb3J0IGZvciBIVE1MIG1haWwNCgktIGFkZGVk
IHN1cHBvcnQgZm9yIGVuY29kZWQgbWFpbCBib2RpZXMgYW5kIHN1YmplY3RzDQoJLSBjaGFuZ2Vk
IGhhbmRsaW5nIG9mIG1haWwNCgktIHRoZSBnbG9iYWwgbWFpbF9kZWJ1ZyBjb25maWd1cmF0aW9u
IG9wdGlvbiBpcyBub3cgc2V0IE9GRiBieSBkZWZhdWx0DQoJLSBpbmNsdWRlIHRoZSBhZGRpdGlv
bmFsIHBhdGNoZXMgc3VibWl0dGVkIGJ5DQoJCS0gRUJZIChzdXBwb3J0IGZvciBwcmlvcml0aWVz
IGFuZCBmaWxlIHVwbG9hZHMpDQoJCSAgZmlsZV9hZGQgaW4gY29yZS9maWxlX2FwaS5waHANCgkJ
ICBtYWlsX3BhcnNlX2NvbnRlbnQgaW4gY29yZS9tYWlsX2FwaS5waHANCgkJICBjb25maWdfZGVm
YXVsdHNfaW5jLnBocA0KRGVjIDIwMDUNCgktIHVwZGF0ZSB0byBNYW50aXMgMS4wLjByYzQNCgkt
IHVwZGF0ZSB0byBNYW50aXMgMC4xOS40DQpPY3QgMjAwNQ0KCS0gdXBkYXRlIHRvIE1hbnRpcyAx
LjAuMHJjMw0KCS0gdXBkYXRlIHRvIE1hbnRpcyAwLjE5LjMNClNlcCAyMDA1Og0KCS0gdXBkYXRl
IHRvIE1hbnRpcyAxLjAuMHJjMg0KCS0gZml4ZWQgYSBidWcgaW4gZ2V0dGluZyBhbGwgY2F0ZWdv
cmllcyBmb3IgYSBwcm9qZWN0DQoJCWNhdGVnb3J5X2dldF9hbGxfcm93cyBpbiBjb3JlL2NhdGVn
b3J5X2FwaS5waHANCkF1ZyAyMDA1Og0KCS0gdXBkYXRlIHRvIE1hbnRpcyAxLjAuMHJjMQ0KCS0g
aW5jbHVkZSB0aGUgYWRkaXRpb25hbCBwYXRjaGVzIHN1Ym1pdHRlZCBieSAgICAgIA0KCQktIGdl
cm5vdCAoRml4ZWQgTUlNRSBoYW5kbGluZyBhbmQgc2F2ZSB0aGUgbWFpbCdzIHNlbmRlcikNCgkJ
ICBtYWlsX2dldF9hbGxfbWFpbHMgaW4gY29yZS9tYWlsX2FwaS5waHANCgkJICBtYWlsX3BhcnNl
X2NvbnRlbnQgaW4gY29yZS9tYWlsX2FwaS5waHANCgkJICBtYWlsX2FkZF9idWcgaW4gY29yZS9t
YWlsX2FwaS5waHANCgkJLSBzdGV2ZW5jIChGaXhlZCBNSU1FIGhhbmRsaW5nKQ0KCQkgIG1haWxf
cGFyc2VfY29udGVudCBpbiBjb3JlL21haWxfYXBpLnBocA0KCQktIHJhaW5tYW4gKEZpeGVkIGVt
cHR5IGZpbGVzIGJ1ZyBhbmQgcmVnZXggZm9yIGZpbmRpbmcgYSBidWcgaWQpDQoJCSAgbWFpbF9h
ZGRfZmlsZSBpbiBjb3JlL21haWxfYXBpLnBocA0KCQkgIG1haWxfZ2V0X2J1Z19pZF9mcm9tX3N1
YmplY3QgaW4gY29yZS9tYWlsX2FwaS5waHANCkRlYyAyMDA0Og0KCS0gdXBkYXRlIHRvIE1hbnRp
cyAwLjE5LjINCgktIGFkZCBjb25maWc6IGdfbWFpbF9wYXJzZV9taW1lDQoJLSBhZGQgY29uZmln
OiBnX21haWxfYWRkaXRpb25hbA0KCS0gYWRkIGNvbmZpZzogZ19tYWlsX2ZldGNoX21heA0KCS0g
bWFrZSBpdCB3b3JraW5nIHZpYSBDTEkNCk5vdiAyMDA0Og0KCS0gdXBkYXRlIHRvIE1hbnRpcyAw
LjE5LjENCgktIGFkZCBzdXBwb3J0IGZvciBNSU1FIGRlY29kaW5nDQpTZXAgMjAwNDoNCgktIHVw
ZGF0ZSB0byBNYW50aXMgMC4xOS4wDQpBdWcgMjAwNDoNCgktIGNyZWF0ZSBwYXRjaCBmb3IgTWFu
dGlzIDAuMTguMw0KDQo=


------=_NextPart_000_00BE_01C86E21.F267BC80--
NOURL-patches.zip (1,214 bytes)
Recmail.zip (60,416 bytes)
recmail.patch (3,954 bytes)   
diff -ur Recmail-orig/pages/recmail_add.php Recmail/pages/recmail_add.php
--- Recmail-orig/pages/recmail_add.php	2009-02-10 16:58:06.000000000 +0530
+++ Recmail/pages/recmail_add.php	2009-02-10 16:59:40.000000000 +0530
@@ -1,6 +1,6 @@
 <?php
 $t_plugin_path = config_get( 'plugin_path' ); 
-require_once( $t_plugin_path . 'Recmail\api\mail_api.php' );
+require_once( $t_plugin_path . 'Recmail/api/mail_api.php' );
 # Update mailbox
 $f_mailbox_name	  	= gpc_get_string( 'mailbox_name' );
 $f_pop3_host	  	= gpc_get_string( 'mail_pop3_host' );
@@ -29,4 +29,4 @@
 	echo '</div>';
 	html_page_bottom1(); 
 }
-?>
\ No newline at end of file
+?>
diff -ur Recmail-orig/pages/recmail_delete.php Recmail/pages/recmail_delete.php
--- Recmail-orig/pages/recmail_delete.php	2009-02-10 16:58:06.000000000 +0530
+++ Recmail/pages/recmail_delete.php	2009-02-10 17:00:20.000000000 +0530
@@ -1,8 +1,8 @@
 <?php
 $t_plugin_path = config_get( 'plugin_path' ); 
-require_once( $t_plugin_path . 'Recmail\api\mail_api.php' );
+require_once( $t_plugin_path . 'Recmail/api/mail_api.php' );
 $f_box_id = gpc_get_int( 'mailbox_id' );
 $query = "delete from $g_mantis_recmail_table  where mailbox_id=$f_box_id limit 1  ";
 $result = db_query( $query );
 print_successful_redirect( plugin_page( 'setpop',TRUE ) );
-?>
\ No newline at end of file
+?>
diff -ur Recmail-orig/pages/recmail_edit_page.php Recmail/pages/recmail_edit_page.php
--- Recmail-orig/pages/recmail_edit_page.php	2009-02-10 16:58:06.000000000 +0530
+++ Recmail/pages/recmail_edit_page.php	2009-02-10 16:59:00.000000000 +0530
@@ -18,7 +18,7 @@
 html_page_top2();
 
 $t_plugin_path = config_get( 'plugin_path' ); 
-require_once( $t_plugin_path . 'Recmail\api\mail_api.php' );
+require_once( $t_plugin_path . 'Recmail/api/mail_api.php' );
 
 print_manage_menu();
 
diff -ur Recmail-orig/pages/recmail_update.php Recmail/pages/recmail_update.php
--- Recmail-orig/pages/recmail_update.php	2009-02-10 16:58:06.000000000 +0530
+++ Recmail/pages/recmail_update.php	2009-02-10 16:58:34.000000000 +0530
@@ -1,6 +1,6 @@
 <?php
 $t_plugin_path = config_get( 'plugin_path' ); 
-require_once( $t_plugin_path . 'Recmail\api\mail_api.php' );
+require_once( $t_plugin_path . 'Recmail/api/mail_api.php' );
 # Update mailbox
 $f_mailbox_name	  	= gpc_get_string( 'mailbox_name' );
 $f_pop3_host	  	= gpc_get_string( 'pop3_host' );
@@ -10,4 +10,4 @@
 $query = "update $g_mantis_recmail_table set mailbox_name='$f_mailbox_name', pop3_host='$f_pop3_host', pop3_user='$f_pop3_user', pop3_pass='$f_pop3_pass' where mailbox_id=$f_box_id";
 $results = mysql_query( $query );
 print_successful_redirect( plugin_page( 'setpop',TRUE ) );
-?>
\ No newline at end of file
+?>
diff -ur Recmail-orig/pages/recmail_verify.php Recmail/pages/recmail_verify.php
--- Recmail-orig/pages/recmail_verify.php	2009-02-10 16:58:06.000000000 +0530
+++ Recmail/pages/recmail_verify.php	2009-02-10 17:00:47.000000000 +0530
@@ -1,6 +1,6 @@
 <?php
 $t_plugin_path = config_get( 'plugin_path' ); 
-require_once( $t_plugin_path . 'Recmail\api\mail_api.php' );
+require_once( $t_plugin_path . 'Recmail/api/mail_api.php' );
 
 $f_mailbox_id = gpc_get_int( 'mailbox_id' );
 
@@ -44,4 +44,4 @@
 } else{
 	print_successful_redirect( plugin_page( 'setpop',TRUE ) );
 }
-?>
\ No newline at end of file
+?>
diff -ur Recmail-orig/pages/setpop.php Recmail/pages/setpop.php
--- Recmail-orig/pages/setpop.php	2009-02-10 16:58:06.000000000 +0530
+++ Recmail/pages/setpop.php	2009-02-10 17:00:02.000000000 +0530
@@ -5,7 +5,7 @@
 html_page_top2();
 
 $t_plugin_path = config_get( 'plugin_path' ); 
-require_once( $t_plugin_path . 'Recmail\api\mail_api.php' );
+require_once( $t_plugin_path . 'Recmail/api/mail_api.php' );
 
 print_manage_menu();
 ?>
@@ -147,4 +147,4 @@
 </div>
 <?php # Edit/Delete ext_db Form END ?>
 
-<?php html_page_bottom1( __FILE__ ) ?>
\ No newline at end of file
+<?php html_page_bottom1( __FILE__ ) ?>
recmail.patch (3,954 bytes)   
recmail_reply_attach.patch (1,725 bytes)   
diff -ubr Recmail/api/mail_api.php Recmail.new/api/mail_api.php
--- Recmail/api/mail_api.php	2009-01-21 20:34:52.000000000 -0500
+++ Recmail.new/api/mail_api.php	2009-02-18 21:32:22.000000000 -0500
@@ -162,12 +162,15 @@
 	# --------------------
 	# return true if there is a valid mantis bug referernce in subject
 	function mail_is_a_bugnote ( $p_mail_subject ) {
-		if ( preg_match("/\[([A-Za-z0-9-_\. ]*\s[0-9]{1,7})\]/", $p_mail_subject) && bug_exists( $t_bug_id )){
-    		$t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] );
+        if (preg_match("/\[([A-Za-z0-9-_\. ]*\s([0-9]{1,7}))\]/", $p_mail_subject, $v_matches)) {
+            $t_bug_title = $v_matches[1];
+            $t_bug_id = $v_matches[2];
+            if (bug_exists( $t_bug_id )) {
+                return true;
+                //$t_bug_id = mail_get_bug_id_from_subject( $p_mail_['Subject'] );
 		}
-		else{
-    		return false;
 		}
+        return false;
 	}
 
 	# --------------------
@@ -223,7 +226,8 @@
 	# Handle the file upload
  		$GLOBALS['_mail_file_'] = $p_part['name'];
 		if ( 0 < strlen($p_part['name']) ) {
-			$t_file_name = ini_get( 'upload_tmp_dir' ) . '/' . $p_part['name'];
+            #$t_file_name = ini_get( 'upload_tmp_dir' ) . '/' . $p_part['name'];
+            $t_file_name = plugin_config_get( 'mail_tmp_directory' ) . '/' . $p_part['name'];
 			$t_method = config_get( 'file_upload_method' );
 			file_put_contents($t_file_name, $p_part['body']);
 			mail_file_add($p_bug_id, realpath( $t_file_name ),  $number."-".$p_part['name'], $p_part['ctype'], 'bug');
@@ -298,10 +302,7 @@
 			}
 		} else	{
 			# Create the bug
-	
-
 	$t_bug_id = bug_create( $t_bug_data );
-
 			email_new_bug( $t_bug_id );
 		}
 		
recmail_reply_attach.patch (1,725 bytes)   
Recmail095.zip (60,670 bytes)
Recmail095a.zip (60,666 bytes)
reject-mail.patch (6,313 bytes)   
diff -rb Recmail095a/Recmail.php Recmail.new/Recmail.php
24c24
< 			'mail_auto_signup'			=> OFF,
---
> 			'mail_unknown_address'		=> 'fallback',
36a37
> 			'mail_rejection_notice'		=> lang_get( 'mail_rejection_notice_default' ),
diff -rb Recmail095a/Recmail_api.php Recmail.new/Recmail_api.php
68c68,77
< 				mail_add_bug( $t_mail, $proj,$cat );
---
> 
> 				$t_reporter_id = mail_get_user( $t_mail['From'] );
> 				if ($t_reporter_id == 0) {
> 					// Reject the unknown sender
> 					mail_reject_unknown( $t_mail );
> 				} else {
> 					// Proceed normally
> 					mail_add_bug( $t_mail, $proj, $cat, $t_reporter_id );
> 				}
> 
179c188,190
< 		$t_mail_auto_signup	= plugin_config_get( 'mail_auto_signup' );
---
>         $t_mail_auto_signup 	= (plugin_config_get( 'mail_unknown_address' ) == 'signup');
>         $t_mail_auto_fallback	= (plugin_config_get( 'mail_unknown_address' ) == 'fallback');
>         $t_mail_auto_reject		= (plugin_config_get( 'mail_unknown_address' ) == 'reject');
199a211,215
>             } elseif ( ! $t_reporter_id && $t_mail_auto_reject ) {
>             	// Reject the unknown mail
>             	echo "Rejected unknown sender: $v_mailaddress<br />";
>             	return 0;
>             
243c259,265
< 	function mail_add_bug ( &$p_mail,$proj ,$cat ) {
---
>     function mail_add_bug ( &$p_mail,$proj, $cat, $reporter_id = -1 ) {
>     	if ($reporter_id == -1) {
> 	        $t_bug_data->reporter_id = mail_get_user( $p_mail['From'] );
> 	    } else {
> 	    	$t_bug_data->reporter_id = $reporter_id;
> 	    }
>     
280,281d301
< 		$t_bug_data->reporter_id		= mail_get_user( $p_mail['From'] );
< 	
287c307,308
< 				email_bugnote_add ( $t_bug_id );
---
>                 //// bugnote_add() already sent the email
>                 //email_bugnote_add ( $t_bug_id );
442a464,476
> 
> 
> 	# Send a rejection notice to the unrecognized sender.
> 	function mail_reject_unknown( $p_mail ) {
> 		$t_recipient = mail_parse_address($p_mail['From']);
> 		$t_subject = 're: '.$p_mail['Subject'];
> 		$t_message = plugin_config_get( 'mail_rejection_notice' );
> 		$t_message = str_replace('#address#', $t_recipient, $t_message);
> 
> 		email_store( $t_recipient, $t_subject, $t_message );
> 	}
> 
> 
diff -rb Recmail095a/lang/strings_english.txt Recmail.new/lang/strings_english.txt
7a8
> $s_mail_unknown_address         = 'How to handle mail from unknown addresses (see Doc)';
8a10,11
> $s_mail_auto_fallback           = 'Use default reporting account';
> $s_mail_auto_reject             = 'Reject';
41a45,46
> $s_mail_rejection_notice		= 'Mail Rejection Notice';
> $s_mail_rejection_notice_default= 'Our Mantis bug tracking system has received an email from your address. Normally the system would automatically add a new bug report using the email, but we are sorry that we do not recognize your email address of #address#. It is necessary that you use the same address that is in your Mantis user account. You may log in to our Mantis website and update your email address there, so that the system can properly accept emails from you in the future. Thank you.';
\ No newline at end of file
diff -rb Recmail095a/pages/bug_report_mail.php Recmail.new/pages/bug_report_mail.php
17c17
< 	header("Content-type: text/plain");
---
> 	//header("Content-type: text/plain");
23a24,26
> 
> 	plugin_push_current( 'Recmail' );
> 
diff -rb Recmail095a/pages/checkuser.php Recmail.new/pages/checkuser.php
13c13
< 	$mail .="@recmail.com";
---
> 	$mail .="@example.com";
diff -rb Recmail095a/pages/config.php Recmail.new/pages/config.php
59,63c59
< 		<?php echo lang_get( 'mail_auto_signup' ) ?>
< 	</td>
< 	<td class="center" width="20%">
< 		<label><input type="radio" name="mail_auto_signup" value="1" <?php echo ( ON == plugin_config_get( 'mail_auto_signup' ) ) ? 'checked="checked" ' : ''?>/>
< 			<?php echo lang_get( 'mail_format_enabled' ) ?></label>
---
> 		<?php echo lang_get( 'mail_unknown_address' ) ?>
64a61
> 
66,67c63,88
< 		<label><input type="radio" name="mail_auto_signup" value="0" <?php echo ( OFF == plugin_config_get( 'mail_auto_signup' ) ) ? 'checked="checked" ' : ''?>/>
< 			<?php echo lang_get( 'mail_format_disabled' ) ?></label>
---
> 		<?php 
> 			if (!$t_mail_auto_signup_default = plugin_config_get('mail_unknown_address')) {
> 				if (ON == plugin_config_get( 'mail_auto_signup' )) {
> 					$t_mail_auto_signup_default = 'signup';
> 				} else {
> 					$t_mail_auto_signup_default = 'fallback';
> 				}
> 			}
> 			$t_options = array(
> 				'signup' => lang_get( 'mail_auto_signup' ),
> 				'fallback' => lang_get( 'mail_auto_fallback' ),
> 				'reject' => lang_get( 'mail_auto_reject' ),
> 			);
> 		?>
> 		<label><select name="mail_unknown_address">
> 			<?php
> 				foreach ($t_options as $t_key => $t_val) {
> 					echo '<option value="'.$t_key.'"';
> 					if ($t_key == $t_mail_auto_signup_default) {
> 						echo ' selected';
> 					}
> 					echo '>'.$t_val.'</option>';
> 				}
> 			?>
> 		</select></label>
> 		
68a90
> 	<td></td>
287c309,318
< 
---
> <tr <?php echo helper_alternate_class() ?>>
> 	<td class="category" width="60%">
> 		<?php echo lang_get( 'mail_rejection_notice' ) ?>
> 	</td>
> 	<td class="center" colspan="2">
> 		<textarea name="mail_rejection_notice" rows="10" cols="60"><?php
> 			echo str_replace('"', '&quot;', plugin_config_get( 'mail_rejection_notice' )); 
> 		?></textarea>
> 	</td>
> </tr>
diff -rb Recmail095a/pages/config_edit.php Recmail.new/pages/config_edit.php
7c7
< $f_mail_auto_signup				= gpc_get_int('mail_auto_signup', OFF);
---
> $f_mail_unknown_address			= gpc_get_string('mail_unknown_address', 'fallback');
19a20
> $f_mail_rejection_notice		= gpc_get_string('mail_rejection_notice', lang_get('mail_rejection_notice_default'));
28c29,30
< plugin_config_set('mail_auto_signup'			, $f_mail_auto_signup);				
---
> //plugin_config_set('mail_auto_signup'			, $f_mail_auto_signup);				
> plugin_config_set('mail_unknown_address'        , $f_mail_unknown_address);
40a43
> plugin_config_set('mail_rejection_notice'		, $f_mail_rejection_notice);
Only in Recmail.new/pages: error_log
diff -rb Recmail095a/pages/setpop.php Recmail.new/pages/setpop.php
76c76
< 		<input type="text" name="mail_pop3_host" size="30" maxlength="30" />
---
> 		<input type="text" name="mail_pop3_host" size="30" maxlength="50" />
reject-mail.patch (6,313 bytes)   
Screenshot-folder-structure.png (47,578 bytes)   
Screenshot-folder-structure.png (47,578 bytes)   
CategoryBySubject.zip (11,942 bytes)
obones_feature_branch.patch (21,367 bytes)   
From 316d2b9ed4390660d1a9a59da213a3c17840f3a9 Mon Sep 17 00:00:00 2001
From: unknown <o.sannier@.siege.ldlc.com>
Date: Wed, 24 Mar 2010 10:18:53 +0100
Subject: [PATCH 1/4] Add the "category by subject" management

---
 core/mail_api.php              |   10 +++
 lang/strings_english.txt       |    1 +
 pages/maintainmailbox.php      |   34 +++++++++++
 pages/maintainmailbox_edit.php |  127 ++++++++++++++++++++++++----------------
 4 files changed, 122 insertions(+), 50 deletions(-)

diff --git a/core/mail_api.php b/core/mail_api.php
index cc76985..c36f8f8 100644
--- a/core/mail_api.php
+++ b/core/mail_api.php
@@ -724,6 +724,16 @@
 			$t_bug_data->view_state				= gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
 
 			$t_bug_data->category_id			= gpc_get_int( 'category_id', $p_mailbox[ 'mailbox_global_category' ] );
+			
+      foreach ($p_mailbox[ 'mailbox_keyword_categories' ] as $expression_pair)
+      {
+        if (preg_match($expression_pair[ 'expression' ], $p_mail[ 'Subject' ]) == 1)
+        {
+          $t_bug_data->category_id = $expression_pair[ 'category' ];
+        }
+      }
+			
+			
 			$t_bug_data->reproducibility		= config_get( 'default_bug_reproducibility', 10 );
 			$t_bug_data->severity				= config_get( 'default_bug_severity', 50 );
 			$t_bug_data->priority				= $p_mail[ 'Priority' ];
diff --git a/lang/strings_english.txt b/lang/strings_english.txt
index f6a2809..7e60b90 100644
--- a/lang/strings_english.txt
+++ b/lang/strings_english.txt
@@ -61,6 +61,7 @@ $s_plugin_EmailReporting_mailbox_basefolder = 'Mailbox basefolder (IMAP)';
 $s_plugin_EmailReporting_mailbox_createfolderstructure = 'Create project subfolder structure (IMAP)';
 $s_plugin_EmailReporting_mailbox_project = 'Select a project (N/A if above is set to "yes")';
 $s_plugin_EmailReporting_mailbox_global_category = 'Select a global category';
+$s_plugin_EmailReporting_mailbox_keyword_categories = 'Indicate your regular expression / category pairs (see <a href="http://www.php.net/manual/en/function.preg-match.php">preg_match</a> for details)';
 
 $s_plugin_EmailReporting_unknown_setting = 'Unknown setting encountered. Setting ignored';
 $s_plugin_EmailReporting_missing_reporter = 'Please select a user account';
diff --git a/pages/maintainmailbox.php b/pages/maintainmailbox.php
index 1b7ce01..076ce38 100644
--- a/pages/maintainmailbox.php
+++ b/pages/maintainmailbox.php
@@ -84,6 +84,11 @@ $t_config_array = array(
 		'type'  => 'dropdown_global_categories',
 		'value' => '',
 	),
+	array(
+	  'name'  => 'mailbox_keyword_categories',
+		'type'  => 'list_keywords_categories',
+		'value' => '',
+  )
 );
 
 foreach( $t_config_array AS $t_config )
@@ -233,6 +238,35 @@ foreach( $t_config_array AS $t_config )
 </tr>
 <?php
 			break;
+			
+		case 'list_keywords_categories':
+?>
+<tr <?php echo helper_alternate_class( )?>>
+	<td class="category" width="60%">
+		<?php echo plugin_lang_get( $t_config[ 'name' ] )?>
+	</td>
+	<td class="center" width="40%" colspan="2">
+	  <?php
+      if (is_array($t_config[ 'value' ]))
+      { 
+        $i = 0;
+        foreach ($t_config[ 'value' ] as $expression_pair)
+        {
+          echo "<label><input type=\"text\" size=\"25\" maxlength=\"50\" name=\"".$t_config[ 'name' ]."_expression_".$i."\" value=\"". $expression_pair[ 'expression' ]."\"/></label>";
+          echo "<label><select name=\"".$t_config[ 'name' ]."_category_".$i."\"> ";
+          print_category_option_list( $expression_pair[ 'category' ], ALL_PROJECTS );
+          echo "</select></label>\n";
+          ++$i;
+        }
+      } 
+    ?> 
+		
+		<label><input type="text" size="25" maxlength="50" name="<?php echo $t_config[ 'name' ] ?>_expression_new" value=""/></label><label><select name="<?php echo $t_config[ 'name' ] ?>_category_new"> <?php print_category_option_list('', ALL_PROJECTS ) ?></select></label>
+	</td>
+</tr>
+<?php
+			break;
+
 		default: echo '<tr><td colspan="3">' . plugin_lang_get( 'unknown_setting' ) . '</td></tr>';
 	}
 }
diff --git a/pages/maintainmailbox_edit.php b/pages/maintainmailbox_edit.php
index 9f57174..94fa9f3 100644
--- a/pages/maintainmailbox_edit.php
+++ b/pages/maintainmailbox_edit.php
@@ -9,81 +9,108 @@ $t_mailboxes = plugin_config_get( 'mailboxes' );
 
 if ( $f_mailbox_action === 'add' || ( ( $f_mailbox_action === 'edit' || $f_mailbox_action === 'test' ) && $f_select_mailbox >= 0 ) )
 {
-	$t_mailbox = array(
-		'mailbox_description'			=> gpc_get_string( 'mailbox_description' ),
-		'mailbox_type'					=> gpc_get_string( 'mailbox_type', 'POP3' ),
-		'mailbox_hostname'				=> gpc_get_string( 'mailbox_hostname' ),
-		'mailbox_encryption'			=> gpc_get_string( 'mailbox_encryption', 'None' ),
-		'mailbox_username'				=> gpc_get_string( 'mailbox_username' ),
-		'mailbox_password'				=> base64_encode( gpc_get_string( 'mailbox_password' ) ),
-		'mailbox_auth_method'			=> gpc_get_string( 'mailbox_auth_method', 'USER' ),
-		'mailbox_basefolder'			=> trim( str_replace( '\\', '/', gpc_get_string( 'mailbox_basefolder', '' ) ), '/ ' ),
-		'mailbox_createfolderstructure'	=> gpc_get_bool( 'mailbox_createfolderstructure', OFF ),
-		'mailbox_project'				=> gpc_get_int( 'mailbox_project' ),
-		'mailbox_global_category'		=> gpc_get_int( 'mailbox_global_category' ),
-	);
+  $t_mailbox = array(
+    'mailbox_description'     => gpc_get_string( 'mailbox_description' ),
+    'mailbox_type'          => gpc_get_string( 'mailbox_type', 'POP3' ),
+    'mailbox_hostname'        => gpc_get_string( 'mailbox_hostname' ),
+    'mailbox_encryption'      => gpc_get_string( 'mailbox_encryption', 'None' ),
+    'mailbox_username'        => gpc_get_string( 'mailbox_username' ),
+    'mailbox_password'        => base64_encode( gpc_get_string( 'mailbox_password' ) ),
+    'mailbox_auth_method'     => gpc_get_string( 'mailbox_auth_method', 'USER' ),
+    'mailbox_basefolder'      => trim( str_replace( '\\', '/', gpc_get_string( 'mailbox_basefolder', '' ) ), '/ ' ),
+    'mailbox_createfolderstructure' => gpc_get_bool( 'mailbox_createfolderstructure', OFF ),
+    'mailbox_project'       => gpc_get_int( 'mailbox_project' ),
+    'mailbox_global_category'   => gpc_get_int( 'mailbox_global_category' ),
+    'mailbox_keyword_categories' => array(),
+  );
+
+  // Add existing pairs, only if they are filled in 
+  $i = 0;
+  while (gpc_get_string('mailbox_keyword_categories_expression_'.$i, null) != null)
+  {
+    $expression = gpc_get_string('mailbox_keyword_categories_expression_'.$i);
+    if (!empty($expression))
+    {
+      array_push($t_mailbox['mailbox_keyword_categories'], array('expression' => $expression, 
+                                                                 'category' => gpc_get_int('mailbox_keyword_categories_category_'.$i)
+                                                                 )
+                );
+    } 
+    
+    ++$i;
+  }
+  
+  // Add a new pair, if filled in
+  $expression = gpc_get_string('mailbox_keyword_categories_expression_new');
+  if (!empty($expression))
+  {
+    array_push($t_mailbox['mailbox_keyword_categories'], array('expression' => $expression, 
+                                                               'category' => gpc_get_int('mailbox_keyword_categories_category_new')
+                                                               )
+              );
+  }
 }
 
 if ( $f_mailbox_action === 'add' )
 {
-	array_push( $t_mailboxes, $t_mailbox );
+  array_push( $t_mailboxes, $t_mailbox );
 }
 elseif ( $f_mailbox_action === 'edit' && $f_select_mailbox >= 0 )
 {
-	$t_mailboxes[ $f_select_mailbox ] = $t_mailbox;
+  $t_mailboxes[ $f_select_mailbox ] = $t_mailbox;
 }
 elseif ( $f_mailbox_action === 'delete' && $f_select_mailbox >= 0 )
 {
-	unset( $t_mailboxes[ $f_select_mailbox ] );
+  unset( $t_mailboxes[ $f_select_mailbox ] );
 }
 elseif ( $f_mailbox_action === 'test' && $f_select_mailbox >= 0 )
 {
-	# Verify mailbox - from Recmail by Cas Nuy
-	require_once( 'mail_api.php' );
+  # Verify mailbox - from Recmail by Cas Nuy
+  require_once( 'mail_api.php' );
 
-	$t_result = mail_process_all_mails( $t_mailbox, true );
+  $t_result = mail_process_all_mails( $t_mailbox, true );
 
-	if ( ( is_array( $t_result ) && $t_result[ 'ERROR_TYPE' ] === 'NON-PEAR-ERROR' ) || PEAR::isError( $t_result ) )
-	{
-		$t_no_redirect = true;
+  if ( ( is_array( $t_result ) && $t_result[ 'ERROR_TYPE' ] === 'NON-PEAR-ERROR' ) || PEAR::isError( $t_result ) )
+  {
+    $t_no_redirect = true;
 
-		html_page_top1();
-		html_page_top2();
+    html_page_top1();
+    html_page_top2();
 ?>
 <br /><div class="center">
-		<?php echo plugin_lang_get( 'test_failure' ); ?>
-	<br><br>
-		<?php echo plugin_lang_get( 'mailbox_description' ) . ': ' . $t_mailbox[ 'mailbox_description' ]; ?>
-	<br>
-		<?php echo plugin_lang_get( 'mailbox_type' ) . ': ' . $t_mailbox[ 'mailbox_type' ]; ?>
-	<br>
-		<?php echo plugin_lang_get( 'mailbox_hostname' ) . ': ' . $t_mailbox[ 'mailbox_hostname' ]; ?>
-	<br>
-		<?php echo plugin_lang_get( 'mailbox_encryption' ) . ': ' . $t_mailbox[ 'mailbox_encryption' ]; ?>
-	<br>
-		<?php echo plugin_lang_get( 'mailbox_username' ) . ': ' . $t_mailbox[ 'mailbox_username' ]; ?>
-	<br>
-		<?php echo plugin_lang_get( 'mailbox_password' ) . ': ******'; ?>
-	<br>
-		<?php echo plugin_lang_get( 'mailbox_auth_method' ) . ': ' . $t_mailbox[ 'mailbox_auth_method' ]; ?>
-	<br>
-		<?php echo plugin_lang_get( 'mailbox_basefolder' ) . ': ' . $t_mailbox[ 'mailbox_basefolder' ]; ?>
-	<br><br>
-		<?php echo ( ( is_array( $t_result ) && $t_result[ 'ERROR_TYPE' ] === 'NON-PEAR-ERROR' ) ? $t_result[ 'ERROR_MESSAGE' ] : $t_result->toString() ); ?>
-	<br><br>
-		<?php print_bracket_link( plugin_page( 'maintainmailbox', TRUE ), lang_get( 'proceed' ) ); ?>
+    <?php echo plugin_lang_get( 'test_failure' ); ?>
+  <br><br>
+    <?php echo plugin_lang_get( 'mailbox_description' ) . ': ' . $t_mailbox[ 'mailbox_description' ]; ?>
+  <br>
+    <?php echo plugin_lang_get( 'mailbox_type' ) . ': ' . $t_mailbox[ 'mailbox_type' ]; ?>
+  <br>
+    <?php echo plugin_lang_get( 'mailbox_hostname' ) . ': ' . $t_mailbox[ 'mailbox_hostname' ]; ?>
+  <br>
+    <?php echo plugin_lang_get( 'mailbox_encryption' ) . ': ' . $t_mailbox[ 'mailbox_encryption' ]; ?>
+  <br>
+    <?php echo plugin_lang_get( 'mailbox_username' ) . ': ' . $t_mailbox[ 'mailbox_username' ]; ?>
+  <br>
+    <?php echo plugin_lang_get( 'mailbox_password' ) . ': ******'; ?>
+  <br>
+    <?php echo plugin_lang_get( 'mailbox_auth_method' ) . ': ' . $t_mailbox[ 'mailbox_auth_method' ]; ?>
+  <br>
+    <?php echo plugin_lang_get( 'mailbox_basefolder' ) . ': ' . $t_mailbox[ 'mailbox_basefolder' ]; ?>
+  <br><br>
+    <?php echo ( ( is_array( $t_result ) && $t_result[ 'ERROR_TYPE' ] === 'NON-PEAR-ERROR' ) ? $t_result[ 'ERROR_MESSAGE' ] : $t_result->toString() ); ?>
+  <br><br>
+    <?php print_bracket_link( plugin_page( 'maintainmailbox', TRUE ), lang_get( 'proceed' ) ); ?>
 </div>
 <?php
-		html_page_bottom1(); 
-	}
+    html_page_bottom1(); 
+  }
 }
 
 if( plugin_config_get( 'mailboxes' ) != $t_mailboxes && ( $f_mailbox_action === 'add' || ( ( $f_mailbox_action === 'edit' || $f_mailbox_action === 'delete' ) && $f_select_mailbox >= 0 ) ) )
 {
-	plugin_config_set( 'mailboxes', $t_mailboxes );
+  plugin_config_set( 'mailboxes', $t_mailboxes );
 }
 
 if ( !isset( $t_no_redirect ) )
 {
-	print_successful_redirect( plugin_page( 'maintainmailbox', true ) );
-}
+  print_successful_redirect( plugin_page( 'maintainmailbox', true ) );
+}
\ No newline at end of file
-- 
1.7.0.2.msysgit.0


From 4d401197225df12e5b64131c0a9b7bd5121de6d1 Mon Sep 17 00:00:00 2001
From: unknown <o.sannier@.siege.ldlc.com>
Date: Mon, 29 Mar 2010 10:59:44 +0200
Subject: [PATCH 2/4] Better Regex for accented characters in project names

---
 core/mail_api.php |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/mail_api.php b/core/mail_api.php
index c36f8f8..e29fcc0 100644
--- a/core/mail_api.php
+++ b/core/mail_api.php
@@ -454,7 +454,7 @@
 	# --------------------
 	# return true if there is a valid mantis bug refererence in subject or return false if not found
 	function mail_is_a_bugnote ( $p_mail_subject ) {
-		if ( preg_match( "/\[([A-Za-z0-9-_\. ]*\s[0-9]{1,7})\]/", $p_mail_subject ) ){
+		if ( preg_match( "/\[([[:alnum:]\p{L}-_\. ]*\s[0-9]{1,7})\]/iu", $p_mail_subject ) ){
 			$t_bug_id = mail_get_bug_id_from_subject( $p_mail_subject );
 			if ( bug_exists( $t_bug_id ) && !bug_is_readonly( $t_bug_id ) ){
 				return true;
@@ -467,7 +467,7 @@
 	# --------------------
 	# return the bug's id from the subject
 	function mail_get_bug_id_from_subject ( $p_mail_subject ) {
-		preg_match( "/\[([A-Za-z0-9-_\. ]*\s([0-9]{1,7}?))\]/", $p_mail_subject, $v_matches );
+		preg_match( "/\[([[:alnum:]\p{L}-_\. ]*\s([0-9]{1,7}?))\]/iu", $p_mail_subject, $v_matches );
 
 		return $v_matches[ 2 ];
 	}
-- 
1.7.0.2.msysgit.0


From 3cc04e323a8a692d357d2a4bab4c776f7c0f79dc Mon Sep 17 00:00:00 2001
From: unknown <o.sannier@.siege.ldlc.com>
Date: Tue, 6 Apr 2010 12:05:23 +0200
Subject: [PATCH 3/4] Can now use the email as the username (optionally stripping the domain name) and use the previous username as the realname.

---
 EmailReporting.php       |    9 ++++++++-
 core/mail_api.php        |   37 ++++++++++++++++++++++++++++++++-----
 lang/strings_english.txt |    2 ++
 pages/config.php         |    8 ++++++++
 pages/config_edit.php    |   10 ++++++++++
 5 files changed, 60 insertions(+), 6 deletions(-)

diff --git a/EmailReporting.php b/EmailReporting.php
index 604bd61..3c2bb5e 100644
--- a/EmailReporting.php
+++ b/EmailReporting.php
@@ -10,7 +10,7 @@ class EmailReportingPlugin extends MantisPlugin {
 		$this->description = plugin_lang_get( 'description' );
 		$this->page = 'config';
 
-		$this->version = '0.7.9';
+		$this->version = '0.7.9-DEV';
 		$this->requires = array(
 			'MantisCore' => '1.2',
 		);
@@ -50,6 +50,13 @@ class EmailReportingPlugin extends MantisPlugin {
 			# Default is OFF, if mail_use_reporter is OFF and this is OFF then it will
 			# fallback to the mail_reporter account above
 			'mail_auto_signup'			=> OFF,
+			
+			# Use the email as a username if auto signing up
+			'mail_use_email_as_username'  => OFF,
+			
+			# Strip the domain name (the part after the @) when using the email as a 
+      # username and auto signing up
+			'mail_strip_domain_from_username'  => OFF,
 		
 			# How many mails should be fetched at the same time
 			# If big mails with attachments should be received, specify only one
diff --git a/core/mail_api.php b/core/mail_api.php
index e29fcc0..3c7202a 100644
--- a/core/mail_api.php
+++ b/core/mail_api.php
@@ -286,7 +286,8 @@
 
 		if ( $t_mail_delete )
 		{
-			$p_mailbox_connection->deleteMsg( $p_i );
+			if (!$p_mailbox_connection->deleteMsg( $p_i ))
+        echo 'deleteMsg failed';
 		}
 	}
 
@@ -423,17 +424,33 @@
 		{
 			$v_mailaddress = array(
 				'username' => trim( $matches[ 1 ], '"\' ' ),
+				'realname' => '',
 				'email' => trim( $matches[ 2 ] ),
 			);
+			
+  		$t_mail_use_email_as_username = plugin_config_get( 'mail_use_email_as_username' );
+  		$t_mail_strip_domain_from_username = plugin_config_get( 'mail_strip_domain_from_username' );
+  		
+  		if ($t_mail_use_email_as_username)
+  		{
+  		  $v_mailaddress['realname'] = $v_mailaddress['username'];
+  		  $email = $v_mailaddress['email'];
+  		  
+  		  if ($t_mail_strip_domain_from_username)
+  		    $v_mailaddress['username'] = substr($email, 0, strpos($email, '@')); 
+  		  else
+          $v_mailaddress['username'] = $email; 		  
+      }
 		}
 		else
 		{
 			$v_mailaddress = array(
-				'name' => '',
+				'username' => '',
+				'realname' => '',
 				'email' => $p_mailaddress,
 			);
 		}
-
+		
 		return $v_mailaddress;
 	}
 
@@ -502,11 +519,15 @@
 					if ( user_is_name_valid( $t_reporter ) &&
 						user_is_name_unique( $t_reporter ) )
 					{
-						# notify the selected group a new user has signed-up
+						# notify the selected group a new user has signed-up and set realname
 						if( user_signup( $t_reporter, $v_mailaddress[ 'email' ] ) )
 						{
-							email_notify_new_account( $t_reporter, $v_mailaddress[ 'email' ] );
+						  if (ON == config_get('enable_email_notification'))
+							 email_notify_new_account( $t_reporter, $v_mailaddress[ 'email' ] );
+							
 							$t_reporter_id = user_get_id_by_name ( $t_reporter );
+							if ($v_mailaddress['realname'] != '')
+							 user_set_realname($t_reporter_id, $v_mailaddress['realname']);
 						}
 					}
 
@@ -698,6 +719,7 @@
 			$t_resolved = config_get( 'bug_resolved_status_threshold' );
 			$t_status = bug_get_field( $t_bug_id, 'status' );
 
+      config_set('email_receive_own', ON);
 			if ( $t_resolved <= $t_status )
 			{
 				# Reopen issue and add a bug note
@@ -708,6 +730,8 @@
 				# Add a bug note
 				bugnote_add( $t_bug_id, $t_description );
 			}
+      global $g_email_receive_own;
+      config_set('email_receive_own', $g_email_receive_own);
 		}
 		else
 		{
@@ -763,7 +787,10 @@
 			# Create the bug
 			$t_bug_id = $t_bug_data->create();
 
+      config_set('email_receive_own', ON);
 			email_new_bug( $t_bug_id );
+      global $g_email_receive_own;
+      config_set('email_receive_own', $g_email_receive_own);
 		}
 		
 		# Add files
diff --git a/lang/strings_english.txt b/lang/strings_english.txt
index 7e60b90..2bfc623 100644
--- a/lang/strings_english.txt
+++ b/lang/strings_english.txt
@@ -25,6 +25,8 @@ $s_plugin_EmailReporting_mail_check_timer = 'How often should the mailboxes be c
 $s_plugin_EmailReporting_mail_use_reporter = 'Use one account for issues created by email';
 $s_plugin_EmailReporting_mail_reporter = 'The account name for issues created by email';
 $s_plugin_EmailReporting_mail_auto_signup = 'Signup new users automatically (possible security risk!, see documentation)';
+$s_plugin_EmailReporting_mail_use_email_as_username = 'Use email as username';
+$s_plugin_EmailReporting_mail_strip_domain_from_username = 'Strip domain name from username';
 $s_plugin_EmailReporting_mail_fetch_max = 'How many emails per mailbox should be fetched every time this script is executed (see documentation)';
 $s_plugin_EmailReporting_mail_add_complete_email = 'Add the complete email into the attachments';
 $s_plugin_EmailReporting_mail_save_from = 'Write the sender of the message into the issue report';
diff --git a/pages/config.php b/pages/config.php
index defac6d..b5fbe17 100644
--- a/pages/config.php
+++ b/pages/config.php
@@ -68,6 +68,14 @@ $t_config_array = array(
 		'type' => 'boolean',
 	),
 	array(
+	  'name' => 'mail_use_email_as_username',
+	  'type' => 'boolean',
+  ),
+	array(
+	  'name' => 'mail_strip_domain_from_username',
+	  'type' => 'boolean',
+  ),
+	array(
 		'name' => 'mail_fetch_max',
 		'type' => 'integer',
 	),
diff --git a/pages/config_edit.php b/pages/config_edit.php
index b68e6a5..ceefe70 100644
--- a/pages/config_edit.php
+++ b/pages/config_edit.php
@@ -9,6 +9,8 @@ $f_mail_check_timer = gpc_get_int( 'mail_check_timer', 300 );
 $f_mail_use_reporter = gpc_get_bool( 'mail_use_reporter', ON );
 $f_mail_reporter = gpc_get_string( 'mail_reporter', 'Mail' );
 $f_mail_auto_signup = gpc_get_bool( 'mail_auto_signup', OFF );
+$f_mail_use_email_as_username = gpc_get_bool('mail_use_email_as_username', OFF);
+$f_mail_strip_domain_from_username = gpc_get_bool('mail_strip_domain_from_username', OFF);
 $f_mail_fetch_max = gpc_get_int( 'mail_fetch_max', 1 );
 $f_mail_add_complete_email = gpc_get_bool( 'mail_add_complete_email', OFF );
 $f_mail_save_from = gpc_get_bool( 'mail_save_from', OFF );
@@ -73,6 +75,14 @@ if( plugin_config_get( 'mail_auto_signup' ) != $f_mail_auto_signup ) {
 	plugin_config_set( 'mail_auto_signup', $f_mail_auto_signup );
 }
 
+if( plugin_config_get( 'mail_use_email_as_username', false ) != $f_mail_use_email_as_username ) {
+	plugin_config_set( 'mail_use_email_as_username', $f_mail_use_email_as_username );
+}
+
+if( plugin_config_get( 'mail_strip_domain_from_username', false ) != $f_mail_strip_domain_from_username ) {
+	plugin_config_set( 'mail_strip_domain_from_username', $f_mail_strip_domain_from_username );
+}
+
 if( plugin_config_get( 'mail_fetch_max' ) != $f_mail_fetch_max ) {
 	plugin_config_set( 'mail_fetch_max', $f_mail_fetch_max );
 }
-- 
1.7.0.2.msysgit.0


From 68bd57285282e4800e5b56b05fd7c2b93e597692 Mon Sep 17 00:00:00 2001
From: unknown <o.sannier@.siege.ldlc.com>
Date: Tue, 6 Apr 2010 14:24:08 +0200
Subject: [PATCH 4/4] Disable the signup email, it never finishes and prevents the rest of the code to work

---
 core/mail_api.php |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/mail_api.php b/core/mail_api.php
index 3c7202a..407cca9 100644
--- a/core/mail_api.php
+++ b/core/mail_api.php
@@ -522,8 +522,8 @@
 						# notify the selected group a new user has signed-up and set realname
 						if( user_signup( $t_reporter, $v_mailaddress[ 'email' ] ) )
 						{
-						  if (ON == config_get('enable_email_notification'))
-							 email_notify_new_account( $t_reporter, $v_mailaddress[ 'email' ] );
+//						  if (ON == config_get('enable_email_notification'))
+//							 email_notify_new_account( $t_reporter, $v_mailaddress[ 'email' ] );
 							
 							$t_reporter_id = user_get_id_by_name ( $t_reporter );
 							if ($v_mailaddress['realname'] != '')
-- 
1.7.0.2.msysgit.0

obones_feature_branch.patch (21,367 bytes)   
events.patch (5,650 bytes)   
Index: core/config_api.php
===================================================================
--- core/config_api.php	(revision 994)
+++ core/config_api.php	(working copy)
@@ -164,7 +164,14 @@
 ?>
 <tr <?php echo helper_alternate_class( )?>>
 	<td class="category" width="60%">
-		<?php echo plugin_lang_get( $p_name )?>
+		<?php 
+      $plugin_name = event_signal('EVENT_ERP_GET_EXTRA_FIELD_NAME', $p_name);
+      if ($plugin_name != null)
+        echo $plugin_name;
+      else
+        echo plugin_lang_get( $p_name );
+      
+    ?>
 	</td>
 <?php
 				switch ( $p_type )
@@ -439,7 +446,19 @@
 <?php
 				break;
 
-			default: echo '<tr><td colspan="3">' . plugin_lang_get( 'unknown_setting' ) . $p_name . ' -> level 1</td></tr>';
+			default:
+        $plugin_name = event_signal('EVENT_ERP_GET_EXTRA_FIELD_NAME', $p_name);
+        if ($plugin_name != null)
+        {
+          echo '<tr '.helper_alternate_class( ).'>';
+        	echo '<td class="category" width="60%">'.$plugin_name.'</td>';
+        	echo event_signal('EVENT_ERP_OUTPUT_EXTRA_FIELD_TYPE', array($p_name, $p_type, $t_value));
+        	echo '</tr>';
+        }
+        else
+        {
+          echo '<tr><td colspan="3">' . plugin_lang_get( 'unknown_setting' ) . $p_name . ' -> level 1</td></tr>';
+        }
 		}
 	}
 
Index: core/mail_api.php
===================================================================
--- core/mail_api.php	(revision 994)
+++ core/mail_api.php	(working copy)
@@ -592,6 +592,8 @@
 
 			$t_status = bug_get_field( $t_bug_id, 'status' );
 
+			$t_description = event_signal( 'EVENT_ERP_PROCESS_BUGNOTE_DATA', $t_description, array($p_email, $this->_mailbox) );
+
 			if ( $this->_bug_resolved_status_threshold <= $t_status )
 			{
 				# Reopen issue and add a bug note
@@ -662,6 +664,7 @@
 
 			# Allow plugins to pre-process bug data
 			$t_bug_data = event_signal( 'EVENT_REPORT_BUG_DATA', $t_bug_data );
+			$t_bug_data = event_signal( 'EVENT_ERP_PROCESS_BUG_DATA', $t_bug_data, array($p_email, $this->_mailbox) );
 
 			# Create the bug
 			$t_bug_id = $t_bug_data->create();
Index: EmailReporting.php
===================================================================
--- EmailReporting.php	(revision 995)
+++ EmailReporting.php	(working copy)
@@ -215,6 +215,46 @@
 		}
 	}
 
+	function events() {
+		return array(
+			# Allow other plugins to process bugdata before the bug is added
+			# Parameters are BugData, Email details array, Mailbox data
+			# Result is BugData
+			'EVENT_ERP_PROCESS_BUG_DATA' => EVENT_TYPE_CHAIN,
+
+			# Allow other plugins to process bugnote data before the bug is added
+			# Parameters are bugnote text, Email details array, Mailbox data
+			# Result is bugnote text
+			'EVENT_ERP_PROCESS_BUGNOTE_DATA' => EVENT_TYPE_CHAIN,
+
+      # Allow other plugins to add configuration elements in the form displayed
+      # by manage_mailbox.php in the mailbox_settings_issue section
+      # Parameters are extra fields from other plugins and mailbox data (value of $t_mailbox) 
+      # Result is an array of key/value pairs used as the first two parameters 
+      # in a call to ERP_output_config_options
+			'EVENT_ERP_GET_EXTRA_MAILBOX_SETTINGS_ISSUE_FIELDS' => EVENT_TYPE_CHAIN,
+			
+			# Allow other plugins to add elements in the mailbox data that is saved in the config
+			# Parameters are extra data from other plugins and Mailbox data from manage_mailbox_edit.php
+			# Result is Mailbox data
+			'EVENT_ERP_GET_EXTRA_MAILBOX_DATA' => EVENT_TYPE_CHAIN,
+			
+			# Allow other plugins to give the name for an extra field added via the
+			# EVENT_ERP_GET_EXTRA_MAILBOX_SETTINGS_ISSUE_FIELDS event
+			# Parameter is the name of the extra field
+			# Result is the displayable string as returned by plugin_lang_get 
+			'EVENT_ERP_GET_EXTRA_FIELD_NAME' => EVENT_TYPE_FIRST,
+
+			# Allow other plugins to output the input HTML elements for a specific type
+      # as given for an extra field added via the
+			# EVENT_ERP_GET_EXTRA_MAILBOX_SETTINGS_ISSUE_FIELDS event
+			# Parameters are the name, the type and the value of the extra field 
+			# Result is the HTML code that will be displayed on the right part of the table
+      # and must include the <td></td> tags 
+			'EVENT_ERP_OUTPUT_EXTRA_FIELD_TYPE' => EVENT_TYPE_FIRST,
+		);
+	}
+
 	/**
 	 * EmailReporting plugin hooks.
 	 */
Index: pages/manage_mailbox.php
===================================================================
--- pages/manage_mailbox.php	(revision 994)
+++ pages/manage_mailbox.php	(working copy)
@@ -73,6 +73,14 @@
 ERP_output_config_option( 'mailbox_project_id', 'dropdown_projects', -3, $t_mailbox );
 ERP_output_config_option( 'mailbox_global_category_id', 'dropdown_global_categories', -3, $t_mailbox );
 
+$extra_fields = event_signal('EVENT_ERP_GET_EXTRA_MAILBOX_SETTINGS_ISSUE_FIELDS', null, $t_mailbox);
+
+if (is_array($extra_fields))
+{
+  foreach ($extra_fields as $field_id => $field_type_id)
+    ERP_output_config_option( $field_id, $field_type_id, -3, $t_mailbox );
+}
+
 ERP_output_config_option( $f_mailbox_action . '_mailbox', 'submit' );
 
 ?>
Index: pages/manage_mailbox_edit.php
===================================================================
--- pages/manage_mailbox_edit.php	(revision 994)
+++ pages/manage_mailbox_edit.php	(working copy)
@@ -31,6 +31,11 @@
 
 		$t_mailbox += $t_mailbox_imap;
 	}
+	
+	$t_extra_data = event_signal('EVENT_ERP_GET_EXTRA_MAILBOX_DATA', null, array($t_mailbox));
+	
+	if (is_array($t_extra_data))
+	 $t_mailbox = array_merge($t_mailbox, $t_extra_data);
 }
 
 if ( $f_mailbox_action === 'add' || $f_mailbox_action === 'copy' )
events.patch (5,650 bytes)   
directory_trim.diff (1,400 bytes)   
Index: manage_config_edit.php
===================================================================
--- manage_config_edit.php	(revision 1000)
+++ manage_config_edit.php	(revision 1001)
@@ -9,7 +9,7 @@
 	'mail_add_complete_email'		=> gpc_get_bool( 'mail_add_complete_email' ),
 	'mail_auto_signup'				=> gpc_get_bool( 'mail_auto_signup' ),
 	'mail_debug'					=> gpc_get_bool( 'mail_debug' ),
-	'mail_debug_directory'			=> trim( str_replace( '\\', '/', gpc_get_string( 'mail_debug_directory' ) ), '/ ' ),
+	'mail_debug_directory'			=> rtrim(trim( str_replace( '\\', '/', gpc_get_string( 'mail_debug_directory' ) )), '/' ),
 	'mail_delete'					=> gpc_get_bool( 'mail_delete' ),
 	'mail_email_receive_own'		=> gpc_get_string( 'mail_email_receive_own' ),
 	'mail_encoding'					=> gpc_get_string( 'mail_encoding' ),
@@ -26,7 +26,7 @@
 	'mail_reporter_id'				=> gpc_get_int( 'mail_reporter_id' ),
 	'mail_save_from'				=> gpc_get_bool( 'mail_save_from' ),
 	'mail_secured_script'			=> gpc_get_bool( 'mail_secured_script' ),
-	'mail_tmp_directory'			=> trim( str_replace( '\\', '/', gpc_get_string( 'mail_tmp_directory' ) ), '/ ' ),
+	'mail_tmp_directory'			=> rtrim(trim( str_replace( '\\', '/', gpc_get_string( 'mail_tmp_directory' ) )), '/'),
 	'mail_use_bug_priority'			=> gpc_get_bool( 'mail_use_bug_priority' ),
 	'mail_use_reporter'				=> gpc_get_bool( 'mail_use_reporter' ),
 );
directory_trim.diff (1,400 bytes)   
file_upload.patch (8,952 bytes)   
Index: core/custom_file_api.php
===================================================================
--- core/custom_file_api.php	(revision 994)
+++ core/custom_file_api.php	(working copy)
@@ -1,123 +0,0 @@
-<?php
-/**
- * Add a file to the system using the configured storage method
- *
- * @param integer $p_bug_id the bug id
- * @param array $p_file the uploaded file info, as retrieved from gpc_get_file()
- * 
- * almost the same as its counterpart in the file_api.php from MantisBT version 1.2.0, but with small adjustments to the disk upload part
- */
-function ERP_custom_file_add( $p_bug_id, $p_file, $p_table = 'bug', $p_title = '', $p_desc = '', $p_user_id = null ) {
-
-	file_ensure_uploaded( $p_file );
-	$t_file_name = $p_file['name'];
-	$t_tmp_file = $p_file['tmp_name'];
-
-	if( !file_type_check( $t_file_name ) ) {
-		trigger_error( ERROR_FILE_NOT_ALLOWED, ERROR );
-	}
-
-	if( !file_is_name_unique( $t_file_name, $p_bug_id ) ) {
-		trigger_error( ERROR_DUPLICATE_FILE, ERROR );
-	}
-
-	if( 'bug' == $p_table ) {
-		$t_project_id = bug_get_field( $p_bug_id, 'project_id' );
-		$t_bug_id = bug_format_id( $p_bug_id );
-	} else {
-		$t_project_id = helper_get_current_project();
-		$t_bug_id = 0;
-	}
-
-	if( $p_user_id === null ) {
-		$c_user_id = auth_get_current_user_id();
-	} else {
-		$c_user_id = (int)$p_user_id;
-	}
-
-	# prepare variables for insertion
-	$c_bug_id = db_prepare_int( $p_bug_id );
-	$c_project_id = db_prepare_int( $t_project_id );
-	$c_file_type = db_prepare_string( $p_file['type'] );
-	$c_title = db_prepare_string( $p_title );
-	$c_desc = db_prepare_string( $p_desc );
-
-	if( $t_project_id == ALL_PROJECTS ) {
-		$t_file_path = config_get( 'absolute_path_default_upload_folder' );
-	} else {
-		$t_file_path = project_get_field( $t_project_id, 'file_path' );
-		if( $t_file_path == '' ) {
-			$t_file_path = config_get( 'absolute_path_default_upload_folder' );
-		}
-	}
-	$c_file_path = db_prepare_string( $t_file_path );
-	$c_new_file_name = db_prepare_string( $t_file_name );
-
-	$t_file_hash = ( 'bug' == $p_table ) ? $t_bug_id : config_get( 'document_files_prefix' ) . '-' . $t_project_id;
-	$t_unique_name = file_generate_unique_name( $t_file_hash . '-' . $t_file_name, $t_file_path );
-	$t_disk_file_name = $t_file_path . $t_unique_name;
-	$c_unique_name = db_prepare_string( $t_unique_name );
-
-	$t_file_size = filesize( $t_tmp_file );
-	if( 0 == $t_file_size ) {
-		trigger_error( ERROR_FILE_NO_UPLOAD_FAILURE, ERROR );
-	}
-	$t_max_file_size = (int) min( ini_get_number( 'upload_max_filesize' ), ini_get_number( 'post_max_size' ), config_get( 'max_file_size' ) );
-	if( $t_file_size > $t_max_file_size ) {
-		trigger_error( ERROR_FILE_TOO_BIG, ERROR );
-	}
-	$c_file_size = db_prepare_int( $t_file_size );
-
-	$t_method = config_get( 'file_upload_method' );
-
-	switch( $t_method ) {
-		case FTP:
-		case DISK:
-			file_ensure_valid_upload_path( $t_file_path );
-
-			if( !file_exists( $t_disk_file_name ) ) {
-				if( FTP == $t_method ) {
-					$conn_id = file_ftp_connect();
-					file_ftp_put( $conn_id, $t_disk_file_name, $t_tmp_file );
-					file_ftp_disconnect( $conn_id );
-				}
-
-				// move_uploaded_file replaced with rename function. Needed since files added through the EmailReporting method are not seen as such
-				if( !rename( $t_tmp_file, $t_disk_file_name ) ) {
-					// Corrected trigger error message name, FILE_MOVE_FAILED should have been ERROR_FILE_MOVE_FAILED
-					trigger_error( ERROR_FILE_MOVE_FAILED, ERROR );
-				}
-
-				chmod( $t_disk_file_name, config_get( 'attachments_file_permissions' ) );
-
-				$c_content = "''";
-			} else {
-				trigger_error( ERROR_FILE_DUPLICATE, ERROR );
-			}
-			break;
-		case DATABASE:
-			$c_content = db_prepare_binary_string( fread( fopen( $t_tmp_file, 'rb' ), $t_file_size ) );
-			break;
-		default:
-			trigger_error( ERROR_GENERIC, ERROR );
-	}
-
-	$t_file_table = db_get_table( 'mantis_' . $p_table . '_file_table' );
-	$c_id = ( 'bug' == $p_table ) ? $c_bug_id : $c_project_id;
-
-	$query = "INSERT INTO $t_file_table
-						(" . $p_table . "_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, user_id)
-					  VALUES
-						($c_id, '$c_title', '$c_desc', '$c_unique_name', '$c_new_file_name', '$c_file_path', $c_file_size, '$c_file_type', '" . db_now() . "', $c_content, $c_user_id)";
-	db_query( $query );
-
-	if( 'bug' == $p_table ) {
-
-		# updated the last_updated date
-		$result = bug_update_date( $p_bug_id );
-
-		# log new bug
-		history_log_event_special( $p_bug_id, FILE_ADDED, $t_file_name );
-	}
-}
-?>
Index: core/mail_api.php
===================================================================
--- core/mail_api.php	(revision 998)
+++ core/mail_api.php	(working copy)
@@ -13,8 +13,6 @@
 	require_once( 'user_api.php' );
 	require_once( 'file_api.php' );
 
-	require_once( plugin_config_get( 'path_erp', NULL, TRUE ) . 'core/custom_file_api.php' );
-
 	require_once( 'Net/POP3.php' );
 	require_once( plugin_config_get( 'path_erp', NULL, TRUE ) . 'core/Net/IMAP_1.0.3.php' );
 
@@ -735,7 +733,7 @@
 
 				foreach ( $p_email[ 'X-Mantis-Parts' ] as $part )
 				{
-					$t_file_rejected = $this->add_file( $t_bug_id, $part );
+					$t_file_rejected = $this->add_file( $t_bug_id, $p_email[ 'Reporter_id' ], $part );
 
 					if ( $t_file_rejected !== TRUE )
 					{
@@ -765,7 +763,7 @@
 	# --------------------
 	# Very dirty: Adds a file to a bug.
 	# returns true on success and the filename with reason on error
-	private function add_file( $p_bug_id, &$p_part )
+	private function add_file( $p_bug_id, $p_user_id, &$p_part )
 	{
 		# Handle the file upload
 		$t_part_name = ( ( isset( $p_part[ 'name' ] ) ) ? trim( $p_part[ 'name' ] ) : NULL );
@@ -794,17 +792,34 @@
 				$this->_file_number++;
 			}
 
-			$t_file_name = $this->_mail_tmp_directory . '/' . md5( microtime() );
+      $t_file_name = $this->_mail_tmp_directory . '/' . $this->_file_number . '-' . $t_part_name;
 
 			file_put_contents( $t_file_name, $p_part[ 'body' ] );
 
-			ERP_custom_file_add( $p_bug_id, array(
-				'tmp_name'	=> realpath( $t_file_name ),
-				'name'		=> $this->_file_number . '-' . $t_part_name,
-				'type'		=> $p_part[ 'ctype' ],
-				'error'		=> NULL
-			), 'bug' );
-
+      $ch = curl_init();
+      
+      $data = array('bug_id' => $p_bug_id,
+                    'user_id' => $p_user_id, 
+                    'file' => '@'.$t_file_name); // .';type='.$p_part[ 'ctype' ]); // the type part does not work under all versions of PHP (5.2.6 KO, 5.2.13 OK)
+      
+      $url = config_get_global( 'path' ).plugin_page('file_add.php', true);
+      echo $url."\n";
+      echo "\n\n";
+      print_r($data);
+      echo "\n\n";
+      
+      curl_setopt($ch, CURLOPT_URL, $url);
+      curl_setopt($ch, CURLOPT_POST, 1);
+      curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+      
+      if(curl_exec($ch) === false)
+      {
+        echo 'Curl error: ' . curl_error($ch) ."<br />\n";
+      }
+      
+      // Close handle
+      curl_close($ch);
+    
 			if ( is_file( $t_file_name ) )
 			{
 				unlink( $t_file_name );
Index: pages/file_add.php
===================================================================
--- pages/file_add.php	(revision 0)
+++ pages/file_add.php	(revision 0)
@@ -0,0 +1,49 @@
+<?php
+
+require_once('file_api.php');
+
+$t_address = $_SERVER['REMOTE_ADDR'];
+$t_valid = false;
+
+helper_begin_long_process();
+
+# Always allow the same machine to import
+if ( '127.0.0.1' == $t_address || '127.0.1.1' == $t_address
+     || 'localhost' == $t_address || '::1' == $t_address 
+     || $_SERVER['SERVER_ADDR'] == $t_address || $_SERVER['SERVER_NAME'] == $t_address ) {
+	$t_valid = true;
+}
+
+# Not validated by this point gets the boot!
+if ( !$t_valid ) {
+	die( plugin_lang_get( 'invalid_file_add_url' ) );
+}
+
+
+$f_bug_id	= gpc_get_int( 'bug_id', -1 );
+$f_user_id	= gpc_get_int( 'user_id', null );
+$f_file		= gpc_get_file( 'file', -1 );
+
+echo "Bug id : $f_bug_id<br />\n";
+echo "User id: $f_user_id<<br />\n";
+echo "File info:<br />\n";
+print_r($f_file);
+echo "<br />\n";
+
+if ( $f_bug_id == -1 && $f_file	== -1 ) {
+	# _POST/_FILES does not seem to get populated if you exceed size limit so check if bug_id is -1
+	trigger_error( ERROR_FILE_TOO_BIG, ERROR );
+}
+
+# Must set global current user id because file_add and other functions it calls
+# make calls to auth_get_current_user_id() and we obviously have no user logged 
+# in when run via the cron job  
+global $g_cache_current_user_id;
+$g_cache_current_user_id = $f_user_id;
+
+echo "Adding file<br />\n";
+file_add( $f_bug_id, $f_file, 'bug'); 
+echo "All done<br />\n";
+
+
+?>
\ No newline at end of file
file_upload.patch (8,952 bytes)   
file_number.patch (1,389 bytes)   
Index: core/mail_api.php
===================================================================
--- core/mail_api.php	(revision 1002)
+++ core/mail_api.php	(working copy)
@@ -35,8 +35,6 @@
 		'IMAP' => array( 'normal' => 143, 'encrypted' => 993 ),
 	);
 
-	private $_file_number = 1;
-
 	private $_validated_email_list = array();
 
 	private $_mail_add_bug_reports;
@@ -729,8 +727,6 @@
 			{
 				$t_rejected_files = NULL;
 
-				$this->_file_number = 1;
-
 				foreach ( $p_email[ 'X-Mantis-Parts' ] as $part )
 				{
 					$t_file_rejected = $this->add_file( $t_bug_id, $p_email[ 'Reporter_id' ], $part );
@@ -787,12 +783,14 @@
 		}
 		else
 		{
-			while ( !file_is_name_unique( $this->_file_number . '-' . $t_part_name, $p_bug_id ) )
+		  $file_number = 0;
+		  
+			while ( !file_is_name_unique( $t_file_name = (($file_number > 0)? preg_replace('/(\..+)$/', '-'.$file_number.'$1' , $t_part_name) : $t_part_name), $p_bug_id ) )
 			{
-				$this->_file_number++;
+				$file_number++;
 			}
 
-      $t_file_name = $this->_mail_tmp_directory . '/' . $this->_file_number . '-' . $t_part_name;
+      $t_file_name = $this->_mail_tmp_directory . '/' . $t_file_name;
 
 			file_put_contents( $t_file_name, $p_part[ 'body' ] );
 
@@ -824,8 +822,6 @@
 			{
 				unlink( $t_file_name );
 			}
-
-			$this->_file_number++;
 		}
 
 		return( TRUE );
file_number.patch (1,389 bytes)   
multi_string_reply_marker.patch (1,291 bytes)   
Index: core/config_api.php
===================================================================
--- core/config_api.php	(revision 1002)
+++ core/config_api.php	(working copy)
@@ -146,6 +146,7 @@
 				break;
 
 			case 'array':
+			case 'multi_string':
 			case 'boolean':
 			case 'directory_string':
 			case 'integer':
@@ -184,6 +185,14 @@
 <?php
 						break;
 
+					case 'multi_string':
+?>
+	<td class="center" width="40%" colspan="2">
+		<textarea cols="40" rows="6" name="<?php echo $p_name ?>"><?php echo $t_value; ?></textarea>
+	</td>
+<?php
+						break;
+
 					case 'boolean':
 ?>
 	<td class="center" width="20%">
Index: pages/manage_config.php
===================================================================
--- pages/manage_config.php	(revision 1002)
+++ pages/manage_config.php	(working copy)
@@ -76,7 +76,7 @@
 ERP_output_config_option( 'mail_nosubject', 'string', -2 );
 ERP_output_config_option( 'mail_nodescription', 'string', -2 );
 ERP_output_config_option( 'mail_removed_reply_text', 'string', -2 );
-ERP_output_config_option( 'mail_remove_replies_after', 'string', -2 );
+ERP_output_config_option( 'mail_remove_replies_after', 'multi_string', -2 );
 
 ERP_output_config_option( NULL, 'empty' );
 ERP_output_config_option( 'debug_options', 'header' );
reply_identification.patch (1,783 bytes)   
Index: core/mail_api.php
===================================================================
--- core/mail_api.php	(revision 1007)
+++ core/mail_api.php	(working copy)
@@ -1054,12 +1054,15 @@
 	# Removes replies from mails
 	private function identify_replies( $p_description )
 	{
+	  $t_description = $p_description;
+	
 		if ( $this->_mail_remove_replies )
 		{
-			$t_first_occurence = stripos( $p_description, $this->_mail_remove_replies_after );
+			$t_first_occurence = stripos( $t_description, $this->_mail_remove_replies_after );
+		
 			if ( $t_first_occurence !== FALSE )
 			{
-				$t_description = substr( $p_description, 0, $t_first_occurence ) . $this->_mail_removed_reply_text;
+				$t_description = substr( $t_description, 0, $t_first_occurence ) . $this->_mail_removed_reply_text;
 			}
 		}
 
@@ -1069,19 +1072,14 @@
 			# the version delivered with this package seems to be working OK though but just to be sure
 			$t_email_separator1 = substr( $this->_email_separator1, 0, -1 );
 
-			$t_first_occurence = strpos( $p_description, $t_email_separator1 );
-			if ( $t_first_occurence !== FALSE && substr_count( $p_description, $t_email_separator1, $t_first_occurence ) >= 5 )
+			$t_first_occurence = strpos( $t_description, $t_email_separator1 );
+			if ( $t_first_occurence !== FALSE && substr_count( $t_description, $t_email_separator1, $t_first_occurence ) >= 5 )
 			{
-				$t_description = substr( $p_description, 0, $t_first_occurence ) . $this->_mail_removed_reply_text;
+				$t_description = substr( $t_description, 0, $t_first_occurence ) . $this->_mail_removed_reply_text;
 			}
 		}
 
-		if ( isset( $t_description ) )
-		{
-			return( $t_description );
-		}
-
-		return( $p_description );
+		return $t_description;
 	}
 
 	# --------------------
reply_identification.patch (1,783 bytes)   
note_and_new_issue_add_subject_cc_date.patch (11,736 bytes)   
diff -Naur original/EmailReporting/core/Mail/Parser.php new/EmailReporting/core/Mail/Parser.php
--- original/EmailReporting/core/Mail/Parser.php	2011-09-15 10:04:38.000000000 +0200
+++ new/EmailReporting/core/Mail/Parser.php	2011-09-15 10:36:47.000000000 +0200
@@ -14,6 +14,8 @@
 
 	private $_from;
 	private $_subject;
+	private $_cc;
+	private $_date;
 	private $_charset = 'auto';
 	private $_priority;
 	private $_transferencoding;
@@ -100,6 +102,8 @@
 		{
 			$this->_from = $this->process_encoding( $this->_from );
 			$this->_subject = $this->process_encoding( $this->_subject );
+			$this->_cc = $this->process_encoding( $this->_cc );
+			$this->_date = $this->process_encoding( $this->_date );
 			$this->_body = $this->process_encoding( $this->_body );
 		}
 	}
@@ -114,6 +118,16 @@
 		return( $this->_subject );
 	}
 
+	public function cc()
+	{
+		return( $this->_cc );
+	}
+
+	public function mail_date()
+	{
+		return( $this->_date );
+	}
+
 	public function priority()
 	{
 		return( $this->_priority );
@@ -133,6 +147,17 @@
 	{
 		$this->setFrom( $structure->headers['from'] );
 		$this->setSubject( $structure->headers['subject'] );
+
+		if( isset( $structure->headers['cc'] ) )
+		{
+			$this->setCC( $structure->headers['cc'] );
+		}
+
+		if( isset( $structure->headers['date'] ) )
+		{
+			$this->setDate( $structure->headers['date'] );
+		}
+
 		$this->setContentType( $structure->ctype_primary, $structure->ctype_secondary );
 
 		if ( isset( $structure->ctype_parameters[ 'charset' ] ) )
@@ -171,6 +196,16 @@
 		$this->_subject = $subject;
 	}
 
+	private function setCC( $cc )
+	{
+		$this->_cc = $cc;
+	}
+
+	private function setDate( $date )
+	{
+		$this->_date = $date;
+	}
+
 	private function setCharset( $charset )
 	{
 		if ( extension_loaded( 'mbstring' ) && $this->_charset === 'auto' )
diff -Naur original/EmailReporting/core/mail_api.php new/EmailReporting/core/mail_api.php
--- original/EmailReporting/core/mail_api.php	2011-09-15 10:04:38.000000000 +0200
+++ new/EmailReporting/core/mail_api.php	2011-09-15 10:36:47.000000000 +0200
@@ -58,6 +58,9 @@
 	private $_mail_removed_reply_text;
 	private $_mail_reporter_id;
 	private $_mail_save_from;
+	private $_mail_save_note_subject;	
+	private $_mail_save_cc;
+	private $_mail_save_date;
 	private $_mail_tmp_directory;
 	private $_mail_use_bug_priority;
 	private $_mail_use_reporter;
@@ -109,6 +112,9 @@
 		$this->_mail_removed_reply_text			= plugin_config_get( 'mail_removed_reply_text' );
 		$this->_mail_reporter_id				= plugin_config_get( 'mail_reporter_id' );
 		$this->_mail_save_from					= plugin_config_get( 'mail_save_from' );
+		$this->_mail_save_note_subject			= plugin_config_get( 'mail_save_note_subject');
+		$this->_mail_save_cc					= plugin_config_get( 'mail_save_cc' );
+		$this->_mail_save_date					= plugin_config_get( 'mail_save_date' );
 		$this->_mail_tmp_directory				= plugin_config_get( 'mail_tmp_directory' );
 		$this->_mail_use_bug_priority			= plugin_config_get( 'mail_use_bug_priority' );
 		$this->_mail_use_reporter				= plugin_config_get( 'mail_use_reporter' );
@@ -447,15 +453,14 @@
 
 		$t_mp->parse();
 
-		$t_email[ 'From' ] = $t_mp->from();
-		$t_email[ 'From_parsed' ] = $this->parse_address( $t_email[ 'From' ] );
-		$t_email[ 'Reporter_id' ] = $this->get_user( $t_email[ 'From_parsed' ] );
-
-		$t_email[ 'Subject' ] = trim( $t_mp->subject() );
-
-		$t_email[ 'X-Mantis-Body' ] = trim( $t_mp->body() );
-
-		$t_email[ 'X-Mantis-Parts' ] = $t_mp->parts();
+		$t_email[ 'From' ]				= $t_mp->from();
+		$t_email[ 'From_parsed' ]		= $this->parse_address( $t_email[ 'From' ] );
+		$t_email[ 'Reporter_id' ]		= $this->get_user( $t_email[ 'From_parsed' ] );
+		$t_email[ 'Subject' ]			= trim( $t_mp->subject() );
+		$t_email[ 'CC' ]				= trim( $t_mp->cc() );
+		$t_email[ 'Date' ]				= trim( $t_mp->mail_date() );
+		$t_email[ 'X-Mantis-Body' ]		= trim( $t_mp->body() );
+		$t_email[ 'X-Mantis-Parts' ]	= $t_mp->parts();
 
 		if ( $this->_mail_use_bug_priority )
 		{
@@ -602,8 +607,12 @@
 			$t_description = $p_email[ 'X-Mantis-Body' ];
 
 			$t_description = $this->identify_replies( $t_description );
-			$t_description = $this->apply_mail_save_from( $p_email[ 'From' ], $t_description );
+			$t_description = $this->apply_mail_subject( $p_email[ 'Subject' ], $t_description );
+			$t_description = $this->apply_mail_save_date( $p_email[ 'Date' ], $t_description );
+			$t_description = $this->apply_mail_save_cc( $p_email[ 'CC' ], $t_description );
+			$t_description = $this->apply_mail_save_from( $p_email[ 'From' ], $t_description );			
 
+			
 			# Event integration
 			# Core mantis event already exists within bignote_add function
 			$t_bugnote_text = event_signal( 'EVENT_ERP_BUGNOTE_DATA', $t_description, $t_bug_id );
@@ -650,7 +659,13 @@
 			$t_bug_data->status					= $this->_bug_submit_status;
 			$t_bug_data->summary				= $p_email[ 'Subject' ];
 
-			$t_bug_data->description			= $this->apply_mail_save_from( $p_email[ 'From' ], $p_email[ 'X-Mantis-Body' ] );
+			$t_description						= $p_email[ 'X-Mantis-Body' ];
+			$t_description						= $this->apply_mail_subject( $p_email[ 'Subject' ], $t_description );
+			$t_description						= $this->apply_mail_save_date( $p_email[ 'Date' ], $t_description );
+			$t_description						= $this->apply_mail_save_cc( $p_email[ 'CC' ], $t_description );
+			$t_description						= $this->apply_mail_save_from( $p_email[ 'From' ], $t_description );
+
+			$t_bug_data->description			= $t_description;
 
 			$t_bug_data->steps_to_reproduce		= $this->_default_bug_steps_to_reproduce;
 			$t_bug_data->additional_information	= $this->_default_bug_additional_info;
@@ -1018,6 +1033,7 @@
 	private function mail_is_a_bugnote( $p_mail_subject )
 	{
 		$t_bug_id = $this->get_bug_id_from_subject( $p_mail_subject );
+		print("recognized t_bug_id=[".$t_bug_id."], subject=[".$p_mail_subject."]");
 
 		if ( $t_bug_id !== FALSE )
 		{
@@ -1034,7 +1050,7 @@
 	# return the bug's id from the subject
 	private function get_bug_id_from_subject( $p_mail_subject )
 	{
-		preg_match( "/\[.*?\s([0-9]{1,7}?)\]/u", $p_mail_subject, $v_matches );
+		preg_match( "/.*\[.*?(0*[0-9]{1,7}?)\s*\]/u", $p_mail_subject, $v_matches );
 
 		if ( isset( $v_matches[ 1 ] ) )
 		{
@@ -1119,12 +1135,49 @@
 	{
 		if ( $this->_mail_save_from )
 		{
-			return( 'Email from: ' . $p_from . "\n\n" . $p_description );
+			return( 'From: ' . $p_from . "\n" . $p_description );
+		}
+
+		return( $p_description );
+	}
+
+	# --------------------
+	# Add the save subject text if enabled
+	private function apply_mail_subject( $p_subject, $p_description )
+	{
+		if ( $this->_mail_save_note_subject )
+		{
+			return( 'Subject: ' . $p_subject . "\n\n\n" . $p_description );
+		}
+
+		return( $p_description );
+	}
+
+	# --------------------
+	# Add the save cc text if enabled
+	private function apply_mail_save_cc( $p_cc, $p_description )
+	{
+		if ( $this->_mail_save_cc )
+		{
+			return( 'CC: ' . $p_cc . "\n" . $p_description );
 		}
 
 		return( $p_description );
 	}
 
+
+	# --------------------
+	# Add the save date text if enabled
+	private function apply_mail_save_date( $p_date, $p_description )
+	{
+		if ( $this->_mail_save_date )
+		{
+			return( 'Date: ' . $p_date . "\n" . $p_description );
+		}
+
+		return( $p_description );
+	}	
+	
 	# --------------------
 	# Show memory usage in debug mode
 	private function show_memory_usage( $p_location )
diff -Naur original/EmailReporting/EmailReporting.php new/EmailReporting/EmailReporting.php
--- original/EmailReporting/EmailReporting.php	2011-09-15 10:04:37.000000000 +0200
+++ new/EmailReporting/EmailReporting.php	2011-09-15 10:36:47.000000000 +0200
@@ -48,6 +48,9 @@
 			# Is this plugin allowed to process and add bugnotes to existing issues
 			'mail_add_bugnotes'				=> ON,
 
+			# Add email subject to a note or new bug report
+			'mail_save_note_subject'		=> OFF,
+
 			# Add complete email into the attachments
 			'mail_add_complete_email'		=> OFF,
 
@@ -133,6 +136,12 @@
 			# Write sender of the message into the bug report
 			'mail_save_from'				=> ON,
 
+			# Write CC into the bug report
+			'mail_save_cc'					=> OFF,
+
+			# Write Date into the bug report
+			'mail_save_date'				=> OFF,
+
 			# Do you want to secure the EmailReporting script so that it cannot be run
 			# via a webserver?
 			'mail_secured_script'			=> ON,
@@ -474,5 +483,10 @@
 				plugin_config_set( 'mail_mantisbt_url_fix', $t_path );
 			}
 		}
+		if ( $t_config_version <= 10 )
+		{
+			plugin_config_set( 'mail_save_note_subject', ON );
+			plugin_config_set( 'config_version', 11 );
+		}
 	}
 }
diff -Naur original/EmailReporting/lang/strings_english.txt new/EmailReporting/lang/strings_english.txt
--- original/EmailReporting/lang/strings_english.txt	2011-09-15 10:04:38.000000000 +0200
+++ new/EmailReporting/lang/strings_english.txt	2011-09-15 10:36:47.000000000 +0200
@@ -51,7 +51,10 @@
 $s_plugin_EmailReporting_mail_remove_replies_after = 'Use this text to identify the start of a reply';
 $s_plugin_EmailReporting_mail_removed_reply_text = 'Use this text if replies have been removed from the email';
 $s_plugin_EmailReporting_mail_reporter_id = 'The default / fallback reporter user for issues created by email';
-$s_plugin_EmailReporting_mail_save_from = 'Write the sender of the email into the issue report';
+$s_plugin_EmailReporting_mail_save_from = 'Write the sender of the email into the issue/bugnote';
+$s_plugin_EmailReporting_mail_save_cc = 'Write the CC of the email into the issue/bugnote';
+$s_plugin_EmailReporting_mail_save_date = 'Write the Date of the email into the issue/bugnote';
+$s_plugin_EmailReporting_mail_save_note_subject = 'Write the email subject into the issue/bugnote';
 $s_plugin_EmailReporting_mail_secured_script = 'Block this script from running via a webserver (recommended = "Yes")';
 $s_plugin_EmailReporting_mail_tmp_directory = 'Directory for saving temporary email content';
 $s_plugin_EmailReporting_mail_use_bug_priority = 'Look for priority header field';
diff -Naur original/EmailReporting/pages/manage_config_edit.php new/EmailReporting/pages/manage_config_edit.php
--- original/EmailReporting/pages/manage_config_edit.php	2011-09-15 10:04:37.000000000 +0200
+++ new/EmailReporting/pages/manage_config_edit.php	2011-09-15 10:36:47.000000000 +0200
@@ -26,6 +26,9 @@
 	'mail_removed_reply_text'		=> gpc_get_string( 'mail_removed_reply_text' ),
 	'mail_reporter_id'				=> gpc_get_int( 'mail_reporter_id' ),
 	'mail_save_from'				=> gpc_get_bool( 'mail_save_from' ),
+	'mail_save_cc'					=> gpc_get_bool( 'mail_save_cc' ),
+	'mail_save_date'				=> gpc_get_bool( 'mail_save_date' ),
+	'mail_save_note_subject'		=> gpc_get_bool( 'mail_save_note_subject'),
 	'mail_secured_script'			=> gpc_get_bool( 'mail_secured_script' ),
 	'mail_tmp_directory'			=> ERP_prepare_directory_string( gpc_get_string( 'mail_tmp_directory' ) ),
 	'mail_use_bug_priority'			=> gpc_get_bool( 'mail_use_bug_priority' ),
diff -Naur original/EmailReporting/pages/manage_config.php new/EmailReporting/pages/manage_config.php
--- original/EmailReporting/pages/manage_config.php	2011-09-15 10:04:37.000000000 +0200
+++ new/EmailReporting/pages/manage_config.php	2011-09-15 10:36:47.000000000 +0200
@@ -65,6 +65,9 @@
 ERP_output_config_option( 'mail_remove_replies', 'boolean', -2 );
 ERP_output_config_option( 'mail_email_receive_own', 'boolean', -2 );
 ERP_output_config_option( 'mail_save_from', 'boolean', -2 );
+ERP_output_config_option( 'mail_save_cc', 'boolean', -2 );
+ERP_output_config_option( 'mail_save_date', 'boolean', -2 );
+ERP_output_config_option( 'mail_save_note_subject', 'boolean', -2 );
 
 ERP_output_config_option( NULL, 'empty' );
 ERP_output_config_option( 'priority_feature_options', 'header' );
note_and_new_issue_add_subject_cc_date_to.patch (12,919 bytes)   
diff -Nuar original/EmailReporting/core/Mail/Parser.php new/EmailReporting/core/Mail/Parser.php
--- original/EmailReporting/core/Mail/Parser.php	2010-10-19 18:48:26.000000000 +0200
+++ new/EmailReporting/core/Mail/Parser.php	2011-09-15 11:43:00.000000000 +0200
@@ -13,7 +13,10 @@
 	private $_content;
 
 	private $_from;
+	private $_to;
 	private $_subject;
+	private $_cc;
+	private $_date;
 	private $_charset = 'auto';
 	private $_priority;
 	private $_transferencoding;
@@ -99,7 +102,10 @@
 		if ( extension_loaded( 'mbstring' ) )
 		{
 			$this->_from = $this->process_encoding( $this->_from );
+			$this->_to = $this->process_encoding( $this->_to );
 			$this->_subject = $this->process_encoding( $this->_subject );
+			$this->_cc = $this->process_encoding( $this->_cc );
+			$this->_date = $this->process_encoding( $this->_date );
 			$this->_body = $this->process_encoding( $this->_body );
 		}
 	}
@@ -114,6 +120,21 @@
 		return( $this->_subject );
 	}
 
+	public function cc()
+	{
+		return( $this->_cc );
+	}
+
+	public function mail_to()
+	{
+		return( $this->_to );
+	}
+
+	public function mail_date()
+	{
+		return( $this->_date );
+	}
+
 	public function priority()
 	{
 		return( $this->_priority );
@@ -133,6 +154,22 @@
 	{
 		$this->setFrom( $structure->headers['from'] );
 		$this->setSubject( $structure->headers['subject'] );
+
+		if( isset( $structure->headers['cc'] ) )
+		{
+			$this->setCC( $structure->headers['cc'] );
+		}
+
+		if( isset( $structure->headers['date'] ) )
+		{
+			$this->setDate( $structure->headers['date'] );
+		}
+
+		if( isset( $structure->headers['to'] ) )
+		{
+			$this->setTo( $structure->headers['to'] );
+		}
+
 		$this->setContentType( $structure->ctype_primary, $structure->ctype_secondary );
 
 		if ( isset( $structure->ctype_parameters[ 'charset' ] ) )
@@ -171,6 +208,21 @@
 		$this->_subject = $subject;
 	}
 
+	private function setCC( $cc )
+	{
+		$this->_cc = $cc;
+	}
+
+	private function setDate( $date )
+	{
+		$this->_date = $date;
+	}
+
+	private function setTo( $to )
+	{
+		$this->_to = $to;
+	}
+
 	private function setCharset( $charset )
 	{
 		if ( extension_loaded( 'mbstring' ) && $this->_charset === 'auto' )
diff -Nuar original/EmailReporting/core/mail_api.php new/EmailReporting/core/mail_api.php
--- original/EmailReporting/core/mail_api.php	2010-11-06 23:23:16.000000000 +0100
+++ new/EmailReporting/core/mail_api.php	2011-09-15 12:00:34.000000000 +0200
@@ -58,6 +58,10 @@
 	private $_mail_removed_reply_text;
 	private $_mail_reporter_id;
 	private $_mail_save_from;
+	private $_mail_save_to;
+	private $_mail_save_note_subject;	
+	private $_mail_save_cc;
+	private $_mail_save_date;
 	private $_mail_tmp_directory;
 	private $_mail_use_bug_priority;
 	private $_mail_use_reporter;
@@ -109,6 +113,10 @@
 		$this->_mail_removed_reply_text			= plugin_config_get( 'mail_removed_reply_text' );
 		$this->_mail_reporter_id				= plugin_config_get( 'mail_reporter_id' );
 		$this->_mail_save_from					= plugin_config_get( 'mail_save_from' );
+		$this->_mail_save_to					= plugin_config_get( 'mail_save_to' );
+		$this->_mail_save_note_subject			= plugin_config_get( 'mail_save_note_subject');
+		$this->_mail_save_cc					= plugin_config_get( 'mail_save_cc' );
+		$this->_mail_save_date					= plugin_config_get( 'mail_save_date' );
 		$this->_mail_tmp_directory				= plugin_config_get( 'mail_tmp_directory' );
 		$this->_mail_use_bug_priority			= plugin_config_get( 'mail_use_bug_priority' );
 		$this->_mail_use_reporter				= plugin_config_get( 'mail_use_reporter' );
@@ -447,15 +455,15 @@
 
 		$t_mp->parse();
 
-		$t_email[ 'From' ] = $t_mp->from();
-		$t_email[ 'From_parsed' ] = $this->parse_address( $t_email[ 'From' ] );
-		$t_email[ 'Reporter_id' ] = $this->get_user( $t_email[ 'From_parsed' ] );
-
-		$t_email[ 'Subject' ] = trim( $t_mp->subject() );
-
-		$t_email[ 'X-Mantis-Body' ] = trim( $t_mp->body() );
-
-		$t_email[ 'X-Mantis-Parts' ] = $t_mp->parts();
+		$t_email[ 'From' ]				= $t_mp->from();
+		$t_email[ 'From_parsed' ]		= $this->parse_address( $t_email[ 'From' ] );
+		$t_email[ 'Reporter_id' ]		= $this->get_user( $t_email[ 'From_parsed' ] );
+		$t_email[ 'Subject' ]			= trim( $t_mp->subject() );
+		$t_email[ 'CC' ]				= trim( $t_mp->cc() );
+		$t_email[ 'Date' ]				= trim( $t_mp->mail_date() );
+		$t_email[ 'To' ]				= trim( $t_mp->mail_to() );
+		$t_email[ 'X-Mantis-Body' ]		= trim( $t_mp->body() );
+		$t_email[ 'X-Mantis-Parts' ]	= $t_mp->parts();
 
 		if ( $this->_mail_use_bug_priority )
 		{
@@ -602,8 +610,16 @@
 			$t_description = $p_email[ 'X-Mantis-Body' ];
 
 			$t_description = $this->identify_replies( $t_description );
-			$t_description = $this->apply_mail_save_from( $p_email[ 'From' ], $t_description );
+			$t_description = $this->apply_mail_subject( $p_email[ 'Subject' ], $t_description );
+			$t_description = $this->apply_mail_save_date( $p_email[ 'Date' ], $t_description );
+			if( array_key_exists( $p_email[ 'CC' ] ) && !empty( $p_email[ 'CC' ] ) )
+			{
+				$t_description = $this->apply_mail_save_cc( $p_email[ 'CC' ], $t_description );
+			}
+			$t_description = $this->apply_mail_save_to( $p_email[ 'To' ], $t_description );
+			$t_description = $this->apply_mail_save_from( $p_email[ 'From' ], $t_description );			
 
+			
 			# Event integration
 			# Core mantis event already exists within bignote_add function
 			$t_bugnote_text = event_signal( 'EVENT_ERP_BUGNOTE_DATA', $t_description, $t_bug_id );
@@ -650,7 +666,19 @@
 			$t_bug_data->status					= $this->_bug_submit_status;
 			$t_bug_data->summary				= $p_email[ 'Subject' ];
 
-			$t_bug_data->description			= $this->apply_mail_save_from( $p_email[ 'From' ], $p_email[ 'X-Mantis-Body' ] );
+			$t_description						= $p_email[ 'X-Mantis-Body' ];
+			$t_description						= $this->apply_mail_subject( $p_email[ 'Subject' ], $t_description );
+			$t_description						= $this->apply_mail_save_date( $p_email[ 'Date' ], $t_description );
+
+			if( array_key_exists( $p_email[ 'CC' ] ) && !empty( $p_email[ 'CC' ] ) )
+			{
+				$t_description					= $this->apply_mail_save_cc( $p_email[ 'CC' ], $t_description );
+			}
+
+			$t_description						= $this->apply_mail_save_to( $p_email[ 'To' ], $t_description );
+			$t_description						= $this->apply_mail_save_from( $p_email[ 'From' ], $t_description );
+
+			$t_bug_data->description			= $t_description;
 
 			$t_bug_data->steps_to_reproduce		= $this->_default_bug_steps_to_reproduce;
 			$t_bug_data->additional_information	= $this->_default_bug_additional_info;
@@ -1034,7 +1062,7 @@
 	# return the bug's id from the subject
 	private function get_bug_id_from_subject( $p_mail_subject )
 	{
-		preg_match( "/\[.*?\s([0-9]{1,7}?)\]/u", $p_mail_subject, $v_matches );
+		preg_match( "/.*\[.*?(0*[0-9]{1,7}?)\s*\]/u", $p_mail_subject, $v_matches );
 
 		if ( isset( $v_matches[ 1 ] ) )
 		{
@@ -1119,13 +1147,62 @@
 	{
 		if ( $this->_mail_save_from )
 		{
-			return( 'Email from: ' . $p_from . "\n\n" . $p_description );
+			return( 'From: ' . $p_from . "\n" . $p_description );
+		}
+
+		return( $p_description );
+	}
+
+	# --------------------
+	# Add the save to text if enabled
+	private function apply_mail_save_to( $p_to, $p_description )
+	{
+		if ( $this->_mail_save_to )
+		{
+			return( 'To: ' . $p_to . "\n" . $p_description );
+		}
+
+		return( $p_description );
+	}
+
+	# --------------------
+	# Add the save subject text if enabled
+	private function apply_mail_subject( $p_subject, $p_description )
+	{
+		if ( $this->_mail_save_note_subject )
+		{
+			return( 'Subject: ' . $p_subject . "\n\n\n" . $p_description );
 		}
 
 		return( $p_description );
 	}
 
 	# --------------------
+	# Add the save cc text if enabled
+	private function apply_mail_save_cc( $p_cc, $p_description )
+	{
+		if ( $this->_mail_save_cc )
+		{
+			return( 'CC: ' . $p_cc . "\n" . $p_description );
+		}
+
+		return( $p_description );
+	}
+
+
+	# --------------------
+	# Add the save date text if enabled
+	private function apply_mail_save_date( $p_date, $p_description )
+	{
+		if ( $this->_mail_save_date )
+		{
+			return( 'Date: ' . $p_date . "\n" . $p_description );
+		}
+
+		return( $p_description );
+	}	
+	
+	# --------------------
 	# Show memory usage in debug mode
 	private function show_memory_usage( $p_location )
 	{
diff -Nuar original/EmailReporting/EmailReporting.php new/EmailReporting/EmailReporting.php
--- original/EmailReporting/EmailReporting.php	2010-11-11 23:31:02.000000000 +0100
+++ new/EmailReporting/EmailReporting.php	2011-09-15 11:43:00.000000000 +0200
@@ -48,6 +48,9 @@
 			# Is this plugin allowed to process and add bugnotes to existing issues
 			'mail_add_bugnotes'				=> ON,
 
+			# Add email subject to a note or new bug report
+			'mail_save_note_subject'		=> OFF,
+
 			# Add complete email into the attachments
 			'mail_add_complete_email'		=> OFF,
 
@@ -133,6 +136,15 @@
 			# Write sender of the message into the bug report
 			'mail_save_from'				=> ON,
 
+			# Write recipient (To) of the message into the bug report
+			'mail_save_to'					=> OFF,
+
+			# Write CC into the bug report
+			'mail_save_cc'					=> OFF,
+
+			# Write Date into the bug report
+			'mail_save_date'				=> OFF,
+
 			# Do you want to secure the EmailReporting script so that it cannot be run
 			# via a webserver?
 			'mail_secured_script'			=> ON,
@@ -474,5 +486,10 @@
 				plugin_config_set( 'mail_mantisbt_url_fix', $t_path );
 			}
 		}
+		if ( $t_config_version <= 10 )
+		{
+			plugin_config_set( 'mail_save_note_subject', ON );
+			plugin_config_set( 'config_version', 11 );
+		}
 	}
 }
diff -Nuar original/EmailReporting/lang/strings_english.txt new/EmailReporting/lang/strings_english.txt
--- original/EmailReporting/lang/strings_english.txt	2010-10-19 18:44:46.000000000 +0200
+++ new/EmailReporting/lang/strings_english.txt	2011-09-15 11:43:00.000000000 +0200
@@ -51,7 +51,11 @@
 $s_plugin_EmailReporting_mail_remove_replies_after = 'Use this text to identify the start of a reply';
 $s_plugin_EmailReporting_mail_removed_reply_text = 'Use this text if replies have been removed from the email';
 $s_plugin_EmailReporting_mail_reporter_id = 'The default / fallback reporter user for issues created by email';
-$s_plugin_EmailReporting_mail_save_from = 'Write the sender of the email into the issue report';
+$s_plugin_EmailReporting_mail_save_from = 'Write the sender of the email into the issue/bugnote';
+$s_plugin_EmailReporting_mail_save_to = 'Write the recipient (To) of the email into the issue/bugnote';
+$s_plugin_EmailReporting_mail_save_cc = 'Write the CC of the email into the issue/bugnote';
+$s_plugin_EmailReporting_mail_save_date = 'Write the Date of the email into the issue/bugnote';
+$s_plugin_EmailReporting_mail_save_note_subject = 'Write the email subject into the issue/bugnote';
 $s_plugin_EmailReporting_mail_secured_script = 'Block this script from running via a webserver (recommended = "Yes")';
 $s_plugin_EmailReporting_mail_tmp_directory = 'Directory for saving temporary email content';
 $s_plugin_EmailReporting_mail_use_bug_priority = 'Look for priority header field';
diff -Nuar original/EmailReporting/pages/manage_config_edit.php new/EmailReporting/pages/manage_config_edit.php
--- original/EmailReporting/pages/manage_config_edit.php	2010-10-07 15:08:38.000000000 +0200
+++ new/EmailReporting/pages/manage_config_edit.php	2011-09-15 11:43:00.000000000 +0200
@@ -26,6 +26,10 @@
 	'mail_removed_reply_text'		=> gpc_get_string( 'mail_removed_reply_text' ),
 	'mail_reporter_id'				=> gpc_get_int( 'mail_reporter_id' ),
 	'mail_save_from'				=> gpc_get_bool( 'mail_save_from' ),
+	'mail_save_to'					=> gpc_get_bool( 'mail_save_to' ),
+	'mail_save_cc'					=> gpc_get_bool( 'mail_save_cc' ),
+	'mail_save_date'				=> gpc_get_bool( 'mail_save_date' ),
+	'mail_save_note_subject'		=> gpc_get_bool( 'mail_save_note_subject'),
 	'mail_secured_script'			=> gpc_get_bool( 'mail_secured_script' ),
 	'mail_tmp_directory'			=> ERP_prepare_directory_string( gpc_get_string( 'mail_tmp_directory' ) ),
 	'mail_use_bug_priority'			=> gpc_get_bool( 'mail_use_bug_priority' ),
diff -Nuar original/EmailReporting/pages/manage_config.php new/EmailReporting/pages/manage_config.php
--- original/EmailReporting/pages/manage_config.php	2010-10-07 15:08:26.000000000 +0200
+++ new/EmailReporting/pages/manage_config.php	2011-09-15 11:43:00.000000000 +0200
@@ -65,6 +65,10 @@
 ERP_output_config_option( 'mail_remove_replies', 'boolean', -2 );
 ERP_output_config_option( 'mail_email_receive_own', 'boolean', -2 );
 ERP_output_config_option( 'mail_save_from', 'boolean', -2 );
+ERP_output_config_option( 'mail_save_to', 'boolean', -2 );
+ERP_output_config_option( 'mail_save_cc', 'boolean', -2 );
+ERP_output_config_option( 'mail_save_date', 'boolean', -2 );
+ERP_output_config_option( 'mail_save_note_subject', 'boolean', -2 );
 
 ERP_output_config_option( NULL, 'empty' );
 ERP_output_config_option( 'priority_feature_options', 'header' );

Relationships

related to 0006658 closedryandesign mantisbt Replying to a mantis ticket should add it as a note to that issue 
has duplicate 0001568 closedgrangeway mantisbt Abillity to send mail to mantis adding bugs and bugnotes 
has duplicate 0003320 closedgrangeway mantisbt Email ability 
has duplicate 0005233 closedthraxisp mantisbt Submission of issues by email 
has duplicate 0005710 closedthraxisp mantisbt E-Mail-Import in mantis 
has duplicate 0008339 closedvboctor mantisbt email reporting 
has duplicate 0009964 closedjreese mantisbt report a bug via email 
has duplicate 0010010 closedthraxisp mantisbt E-mail implementation to mantis as a new bug 
has duplicate 0010550 closedsiebrand mantisbt Report issue via email 
has duplicate 0011831 closedatrol mantisbt Tickets can be created via email? 
has duplicate 0013049 closedatrol mantisbt Report a new Bug via Email 
related to 0006619 closedgrangeway mantisbt Report by email concept 
related to 0008984 closedSL-Gundam Plugin - EmailReporting Adding notes to existing bug via email 
related to 0007086 closedSL-Gundam Plugin - EmailReporting Mantis email via IMAP + folders 
related to 0010146 closeddregad mantisbt Send/Receive mail from issue 

Activities

indy

indy

2004-08-06 10:39

reporter   ~0006704

I've put a test version to the request ;)

Have fun.

jlatour

jlatour

2004-08-06 10:50

reporter   ~0006706

I haven't tried it, but it looks good. I guess we can include this (at least until we have a more flexible e-mail interface). I would appreciate it however if you provide a patch for the project admin interface.

A few other concerns:

  • There is no way for the user to know that his mail has been added to the issue tracker, nor will he get any feedback on it.
  • All issues are reported by one user. Perhaps we could link that to existing users (security issues?), or show the e-mail address instead.
  • I noticed you have added your own copyrights. If we do include this, we'll use the standard copyright header, without specific copyrights for that file.
indy

indy

2004-08-07 04:20

reporter   ~0006742

Last edited: 2004-08-07 04:20

You can use it.

It's an ugly hack this time. ;)
The next step I'd like to do, is to make it possible to use the mail's from header as the reporter (maybe by adding this as a new user account).
This should be configurable.

A feedback to the user was not needed here, but of course, it's possible.
For this the mail's sender should be added as a user account.
I will do this next week, when I find a little time for this.

And...
Use your standard copyright header!

edited on: 08-07-04 04:20

jlatour

jlatour

2004-08-07 04:39

reporter   ~0006743

OK, looking forward to see what you come up with!

indy

indy

2004-08-08 13:50

reporter   ~0006822

I took a look to Bug 0001568 an it seems to be possible for me.

Today I've introduced a new function for finding a user via its mailadress and one to create a new user account out of the box by a mail report.
This time, it seems to work, but I will do some more tests.

jlatour

jlatour

2004-08-08 15:37

reporter   ~0006824

I'm not going to type 'OK, keep it up!' every time you post a status update, but I am reading them :-) Consider it implicit.

indy

indy

2004-08-09 14:59

reporter   ~0006886

The new patch adds the following functions to bug_report_mail:

  • update/remove mail account data to projects with the standard administration interface
  • fetch a users id using a mail address
  • auto-signup a user using a mail address if not found in users table

todo: look into subject of mails for adding bug notes

indy

indy

2004-08-09 16:27

reporter   ~0006891

The mantis-working patch creates user accounts in the right way and is able to recognize mails as replies to an already opened bug.
If it is so, the mail content is added as a bug note.

I think, this should be a ready-to-work solution this time :)

The patch is against Mantis 0.18.3

jlatour

jlatour

2004-08-09 16:39

reporter   ~0006893

Looks and sounds good. However, we're currently working on getting 0.19.0 out first. Could you wait until it's out and send in a patch against that (or even better, use 'cvs diff' with an up to date 0.19.0 CVS tree)?

indy

indy

2004-08-09 17:33

reporter   ~0006898

No problem ;)

I'll wait for it.

fusenigk

fusenigk

2004-08-12 16:25

reporter   ~0006967

Hi, this looks really nice and I´m looking for a solution to report issues vie email.
As noted in some other issues, you can use the /etc/alias file to get new mails immediatly instead of doing a polling.

indy

indy

2004-08-12 16:48

reporter   ~0006968

Last edited: 2004-08-12 16:54

As noted in some other issues, you can use the /etc/alias file to get new mails
immediatly instead of doing a polling.

Yes, I know this.
But there are N+1 different mailservers, and only a few use the /etc/alias database. Qmail, for example not. My first solution was a .qmail Script writing the mail into Mantis database. But it is only useable if the mailserver has the rights to write into the mantis database.

An other possibilily is to put the mail's content into a script doing a http post request. Both are solutions, I tried. But on my mantis host, I have a lot of
clients with own projects who cannot install scripts on their mailserver.
Some do not own a mailserver, some don't like such things, and so on.

But if you're interested in, I can integrate my older solution doing a http post request into this patch.

Edit: I take a look, it's only a little change :)
I think, I'll find a little time for doing this on monday.

bearbeitet am: 08-12-04 16:54

indy

indy

2004-09-15 10:35

reporter   ~0007596

Puh...
I've added a patch for Mantis 0.19.0.
Because of possible security problems, the behaviour has changed a little:
In the default way, only one user is used for reporting.
If this is turned off, the sender's address will be searched in user database.
So it is possible now, to allow always registered users to report via mail without creating accounts for unknown users.
This could be activated with a separate variable.

The next thing, i will integrate is the possibility to have more than one mailaccount for every project. Some people asked me to add support for mail accounts per category.

Have fun...

Indy

Matt_wc

Matt_wc

2004-09-15 10:43

reporter   ~0007597

This is fantastic stuff! Keep it up.

May I put up an idea: if you create a user account from the email (if one was not found), would you then delete the new account when the issue is closed? (as an option)

Again - great work.

indy

indy

2004-09-15 11:14

reporter   ~0007600

if you create a user account from the email (if one was not found), would you
then delete the new account when the issue is closed? (as an option)
Hm... It is possible, of course.
But I think, if the user account is deleted, there are bug reports with no reporter.
If you want it, I will add it as a separate configuration option.

Matt_wc

Matt_wc

2004-09-15 11:28

reporter   ~0007603

This seems to be related to an old issue 3320: Email ability

http://bugs.mantisbt.org/view.php?id=3320

Matt_wc

Matt_wc

2004-09-15 11:35

reporter   ~0007604

On having a bug with no reporter... I agree it is not the best idea - even if it is closed, it would be good to know who reported the issue for future reference.

Will give this more thought.

indy

indy

2004-09-15 12:01

reporter   ~0007605

I'm sorry, the first patch i added today is not really good.
I forgot to remove comments on three lines.

The newer will work. Sorry.

anarcat

anarcat

2004-10-05 23:04

reporter   ~0007930

why isn't this bug marked as related to the bug 3320?

joho

joho

2004-10-15 05:10

reporter   ~0008051

Any chance we can get a version that works on stdin? This would be awesome for people using software like qmail where it makes more sense to pipe input directly from a .qmail file (this also puts a smaller load on the server in that it's only done when mail is actually received).

Using the CLI-interface, PHP files can be invoked/executed from the command-line like any other type of script. So no need to go via the webserver.

indy

indy

2004-10-15 08:22

reporter   ~0008052

Yes, of course it's possible.
I use qmail myself, so I'm working on it.

indy

indy

2004-11-21 11:54

reporter   ~0008385

The newest patch is able to handle MIME-Mails in a correct way.
The attachments are added as new files to a bug.
The Mail_MIME package from PEAR is used for parsing.

It works on my system, please test :)

--

By the way...

I have no idea this time to handle mails via stdin in a correct way.
In this case I have to look for a projects id searching with the mail address,
this is a little bit complicated because there can be also special mailadresses
for each category.
Maybe, if I've a little time in the next weeks, I'll find a solution.

Ouhps: please remove the comment from line 224 in mail_api.php ;)

indy

indy

2004-12-26 08:34

reporter   ~0008813

Update to Mantis 0.19.2.

I've added new configuration options, see README.bug_report_mail for details.
Also, some bugs in the MIME handling are fixed and it is possible now, to run the script via the CLI.
(For this I needed two dirties, maybe, somebody could take a look and beautify this because I don't know how to do ;)

csteeg

csteeg

2005-01-10 05:22

reporter   ~0008905

Could someone please just include a download wich can be copied to/over the 0.19.2 version.
It's a PINTA to get it patched under windows

indy

indy

2005-01-15 10:24

reporter   ~0009029

A complete Mantis 0.19.2 including this patch can be downloaded here:

http://arme-und-beine.de/download/mantis-0.19.2.zip

gernot

gernot

2005-02-12 08:43

reporter   ~0009294

Looks really nice. I'm currently in the process of installing a new Mantis with this patch applied and testing it.

However, I found some small problems when the mails are sent via PINE:

  • MIME handling: Pine always sets the MIME-Version header, even for text/plain msgs. These are tried to decode by the script which fails. I added a check if the Content-Type is really "multipart".
  • MIME handling: Content-Type is set to "TEXT/PLAIN" instead of "text/plain" by Pine. Added strtolower
  • general: I really don't like the idea of auto-sign-ups. Therefore, I use the "Mail" account for reports - but then you can't see who reported a bug at all. Therefore I added a "Report from mail@address.fff:" line to the description.

Please see my patch mantis-0.19.2-additional-fixes.patch and include it to your patch if you like it. The patch has to be applied after mantis-0.19.2.patch.

gernot

gernot

2005-02-12 08:52

reporter   ~0009295

BTW, indy: I think you should change the status of this bug away from "feedback", otherwise it might be overlooked as Mantis developers think you still haven't answered their questions...

gernot

gernot

2005-02-12 09:25

reporter   ~0009296

Another remark (hopefully the last for today, sorry :( ):

I additionally needed to patch Mail_Mime 1.2.1 according to http://pear.php.net/bugs/bug.php?id=1132 so that it will also decode mails with encoding "BASE64" instead of "base64".

indy

indy

2005-02-13 09:39

reporter   ~0009300

gernot: I do not have any privileges to change the state for this report.
In the next version, I will include your changes! :)
Thank you!

gernot

gernot

2005-02-20 07:15

reporter   ~0009351

Additional remark: if you call bug_report_mail.php from the command line via "php", the host and path settings of your server will not be found. This leads to an incorrect message sent upon user registration (www.example.com instead of your server name, wrong path).

So if you want to use this script via "Php" command line, you have to manually set $t_host and $t_path (at least, I didn't try it yet).

jbrouhard

jbrouhard

2005-04-29 11:44

reporter   ~0009964

A complete Mantis 0.19.2 including this patch can be downloaded here:

http://arme-und-beine.de/download/mantis-0.19.2.zip [^]

I get a 404 here?

I would REALLY like to test this out as I use a live bug-tracking system for a database-driven website that controls not only content to a site, but a organization's own reporting and membership system.

Thanks in advance!

indy

indy

2005-04-29 11:58

reporter   ~0009965

I've put the patches and the modified version of Mantis back into the download-area.

jbrouhard

jbrouhard

2005-04-29 12:12

reporter   ~0009966

Thanks!

DTG

DTG

2005-06-22 04:16

reporter   ~0010600

Will this patch also become available for the new 1.x.x version of Mantis?

indy

indy

2005-06-22 04:36

reporter   ~0010601

Of course, but in the moment, I've not enough time to do this.

stevenc

stevenc

2005-06-30 04:51

reporter   ~0010649

I found a bug which prevented the body of an mime email to be added in the description field of a new bug report.

file: core/mail.api.php
function: mail_parse_content ( $p_mail )

if (strtolower($t_parts[0]['Content-Type']) == 'text/plain' ||
strtolower($t_parts[0]['Content-Type']) == 'text/html')
{
//$t_body = array_shift($t_parts); //remove this line
$t_body['Body'] = $t_parts[0]['Body']; //replace it with this one should fix the problem
}
else
{
$t_body['Body'] = "It seems, there is no text... :-o";
}

jbrouhard

jbrouhard

2005-07-08 13:03

reporter   ~0010696

Fatal error: main(): Failed opening required 'Net/POP3.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/virtual/sfmc/public_html/admin/bugs/core/mail_api.php on line 22

I get this error from the cron.. I have this on a virtual host (hosting partner)... It's not permissions as the file is chmod' 655..

rainman

rainman

2005-07-08 15:59

reporter   ~0010697

I've got a problem (maybe my stupidity).
The POP3 connection and login work OK, but $t_pop3->numMsg() returns a false (error) no matter whether there are messages on the POP3 account or not. Has anyone seen this? Any ideas on how to fix it? I'm running the latest 0.19.2 patches.

indy

indy

2005-07-09 05:50

reporter   ~0010699

@jbrouhard: You need the Net_POP3 package from PEAR.
It located here: http://pear.php.net/package/Net_POP3

@rainman: What's your POP3 server?
Maybe you have to patch the Net_POP3 package, sometimes (especially with Courier-POP3) there are courious behaviours.

rainman

rainman

2005-07-11 08:33

reporter   ~0010710

The POP3 server is an Exchange server with POP3 access.

I turned the debugging on in Net_POP3 and I've been diving through the code. I found a missing Auth_SASL package (which appeared to be optional, but I installed it anyway), but so far I still have a problem. I think I'm close. I'll post a followup if I get it working. I expect I'm missing another package.

rainman

rainman

2005-07-11 09:34

reporter   ~0010711

This is the exact server version I am running:
Microsoft Exchange 2000 POP3 server version 6.0.6603.0

It appears that I have an authorization problem. Here is the error I am getting: USER NOT supported authentication method!. This server supports these methods: NTLM, but I support DIGEST-MD5,CRAM-MD5,APOP,PLAIN,LOGIN,USER

jbrouhard

jbrouhard

2005-07-11 09:38

reporter   ~0010712

rainman: you might be able to changhe the settings on the Exchange server to allow for PLAIN login, or even APOP login. NTLM is Exchange's hook to the Active Directory. We run Exchange 5.5 where I work, so I can't really check this out.

rainman

rainman

2005-07-11 09:49

reporter   ~0010713

OK. The problem appears to be between the exchange POP3 server and Pear::Net_POP3 negotiating the authenitication method. If I hard code the auth method to 'USER' it logs in OK. I will attempt to take it up with the Net_POP3 folks.

rainman

rainman

2005-07-11 17:19

reporter   ~0010718

Found a minor problem with the attachment functionality:

My POP3 server (MS Exchange (ARGH!)) was sending the message in multiple parts that ended up causing the mail_add_file function to try to save a file with no name. I think that this is because the user was sending the mail formatted in HTML, so the message was considered an attachment, but there was no name. There's probably a better way to fix this, but here's what I did to fix it:

In file mail_api.php

function mail_add_file( $p_bug_id, $p_part ) {
        $GLOBALS['_mail_file_'] = $p_part['Name'];
        // Add the following if statement to prevent trying to add an 
        // empty file
        if (0 &lt; strlen($p_part['Name']) ) { 
            $t_file_name = '/tmp/'.$p_part['Name'];
            $num_bytes = file_put_contents($t_file_name, $p_part['Body']);
            file_add($p_bug_id, $t_file_name,  $p_part['Name'], $p_part['Content-Type'], 'bug');
            unlink($t_file_name);
        }
    }
jbrouhard

jbrouhard

2005-07-11 23:41

reporter   ~0010723

The Server admin got the Net_POP3 pear package installed, and now i'm getting:

Fatal error: main(): Failed opening required 'Mail/mimeDecode.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/virtual/sfmc/public_html/admin/bugs/core/mail_api.php on line 23

I'm guessing mimeDecode is missing ?

indy

indy

2005-07-12 07:21

reporter   ~0010730

I think this package is missing: http://pear.php.net/package/Mail_Mime

rainman

rainman

2005-07-12 11:03

reporter   ~0010738

I found that the function to add a bugnote was not working because my project name in Mantis had a space in it. The bug id in the brackets looked something like this [Project Name 0000341]. To fix this I added a space into the regex in the mail_is_a_bugnote function and the mail_get_bug_id_from_subject function in mail_api.php.

Old regex example: return pregmatch("/[([A-Za-z0-9-.]\s[0-9]{7})]/", $p_mail_subject);
New regex example: return pregmatch("/[([A-Za-z0-9-. ]
\s[0-9]{7})]/", $p_mail_subject);

I think maybe I goofed when creating a project with a space in the name, but this fixes the problem.

indy

indy

2005-07-20 07:54

reporter   ~0010887

Thanks a lot for the bugfixes and patches.
Sunday (24.07.) I'll create a new release for Mantis 1.0.0a3.

indy

indy

2005-08-07 07:03

reporter   ~0011092

Heyho,

the first patch for Mantis 1.0.0rc1 is submitted.
I'm sorry - the attachments won't work this time - I will fix this within the next days.

Feel free to test!

indy

indy

2005-08-07 08:51

reporter   ~0011094

Now, the file adding seems to work!

A complete version of Mantis 1.0.0rc1 including all required packages is available for download.

http://arme-und-beine.de/download/mantis-1.0.0rc1.zip

dapozzom

dapozzom

2005-08-10 06:42

reporter   ~0011137

I tried to download the solution from "http://arme-und-beine.de/download/mantis-1.0.0rc1.zip&quot; but the file downloaded is corrupted

indy

indy

2005-08-10 07:03

reporter   ~0011138

I've load the file up again.

There's also a bzip2 archive in the directory, try this one, if the ZIP archive fails again. (I hate ZIP gah)

dapozzom

dapozzom

2005-08-10 08:17

reporter   ~0011139

OK!!.
Thanks,
Marco

drtns

drtns

2005-08-11 10:28

reporter   ~0011167

Having an install issue... pulled down the above mentioned mantis-1.0rc1 bzip with the patches rolled in, went to the admin dir, tried to upgrade the DB and got the following error..

Parse error: parse error, expecting `')'' in /var/www/html/newmantis/admin/schema.php on line 349

line 349 is:

&quot;(2, 'mail', 'Mail Reporter', 'nomail@localhost', 'a268462c3c679a9027658c5aa723f97c', '2003-02-16 02:03:48', '2004-07-08 23:59:22', 1, 0, 25, 0, 0, 0, MD5(NOW()))&quot; )
);

?>

I also get the same error with the login page

drtns

drtns

2005-08-24 09:59

reporter   ~0011278

Fixed my issue, not sure if this is somthing that needs to be looked at... the problem was as follows - note I had to change the 'id' as I am upgrading an existing mantis and already had a user with id=2

--- mantis-1.0.0rc1/admin/schema.php 2005-08-24 09:58:20.000000000 -0400
+++ /var/www/html/newmantis/admin/schema.php 2005-08-24 09:56:52.000000000 -0400
@@ -344,8 +344,10 @@
$upgrade[] = Array('CreateIndexSQL',Array('idx_enable',config_get('mantis_user_table'),'enabled'));
$upgrade[] = Array('CreateIndexSQL',Array('idx_access',config_get('mantis_user_table'),'access_level'));

-$upgrade[] = Array('InsertData', Array( config_get('mantis_user_table'),

  • "(1, 'administrator', '', 'root@localhost', '63a9f0ea7bb98050796b649e85481845', '2003-02-16 02:03:48', '2004-07-08 23:59:22', 1, 1, 90, 3, 0, 0, MD5(NOW()))" )
    +$upgrade[] = Array( 'InsertData', Array( config_get('mantis_user_table'),
  • "(1, 'administrator', '', 'root@localhost', '63a9f0ea7bb98050796b649e85481845', '2003-02-16 02:03:48', '2004-07-08 23:59:22', 1, 1, 90, 3, 0, 0, MD5(NOW()))" ));
  • +$upgrade[] = Array( 'InsertData', Array( config_get('mantis_user_table'),
    "(30, 'mail', 'Mail Reporter', 'nomail@localhost', 'a268462c3c679a9027658c5aa723f97c', '2003-02-16 02:03:48', '2004-07-08 23:59:22', 1, 0, 25, 0, 0, 0, MD5(NOW()))" )
    );
    ?>

Basically I needed to add the $upgrade[] ... line to the seccond 'mail' user addition code.

drtns

drtns

2005-08-24 12:04

reporter   ~0011279

When I run the bug_report_mail.php

I get the following error:

APPLICATION WARNING #100: Configuration option 'mail_debug' not found.

APPLICATION WARNING #100: Configuration option 'mail_debug' not found.

However I am still getting the tickets created in my test project under the catagory which they are supose to.

What config file is the mail_debug variable suposed to be set in? and what is the recomended value for this option.

drtns

drtns

2005-08-24 12:41

reporter   ~0011280

RFE:

Is it possible for this to support pop3s as well? out mail server doesn't use pop3 for security reasons. I am working around it right now but my solution is a bit of a kludge.

drtns

drtns

2005-08-24 13:45

reporter   ~0011281

RFE:

The install doesn't take into consideration that you may be upgrading an existing DB.

When it tries to create the mail user it does so with and ID of two... this wont work if you have existing users in your db.

The program sould do a "select max(id) from mantis_user_table;" and then incriment that value by 1, assigning max(id)+1 to the id field for the creation of the mail user.

drtns

drtns

2005-08-24 13:53

reporter   ~0011282

RFE:

E-mail Ticket addition kacks if there is no subject in the e-mail...

If the e-mail sent to the box which mantis checks for e-mail tickets contains no subject it will not insert the ticket to the project with a "No Summary" error:

APPLICATION ERROR #11

A necessary field 'Summary' was empty. Please recheck your inputs.

To make matters worse the e-mail ticket is also del'ed which can lead to a situation where you can get accused of not responding to an issue, because as far as the user is concern their e-mail was delivered even though the bug_report_mail.php/mantis thew the isssue on the floor

The mail_api.php should be changed to look and see if the Subject string is empty and write in a default subject so that when it's handed off to mantis it will properly insert the bug to your project.

drtns

drtns

2005-08-24 15:23

reporter   ~0011283

Right now this works great for submittion via e-mail however it's practical application is limited due to the fact that all future tracking after the inital e-mail is limited to mantis-only conversation.

Is it planned to have this grow to the point where the origional submitter will be e-mailed on each ticket update? as well as an inital tracking ticket which they can reply to, which will automatically update the mantis bug?

Without the ability to carry on a conversation regarding the bug over e-mail the usefullness of the submittion via e-mail is limited.

indy

indy

2005-08-25 03:04

reporter   ~0011287

@drtns: POP3S is possible if it's supported by the Net_POP3 package.
I don't know the current state of this feature, but I'll try enabling this.

The answer for submitters is already possible, if you enable creating of a new account for email reporters.

Your patch will be integrated ASAP, thanks!

dapozzom

dapozzom

2005-08-26 04:41

reporter   ~0011299

In my case I received too the APPLICATION WARNING 100: Configuration option 'mail_debug' not found with no issue created

moppel

moppel

2005-08-30 15:30

reporter   ~0011313

Can anybody provide a list of features needed or bugs to be resolved until this feature can be integrated into a mantis-version?

indy

indy

2005-08-31 05:46

reporter   ~0011325

Of course:

bugs:

  • I have to fix a bug in database layout
  • the default value for mail_debug has to be set

features:

  • check for IMAP and SSL support for POP3/IMAP
ratman

ratman

2005-09-26 11:06

reporter   ~0011431

Last edited: 2005-09-27 05:48

Hi guys,
Can I have a mail sample?
My mail server seems to be empty but the mails are there. I think it a mail format problem.
Is it possible that doesn't work because my mail server is Lotus Notes?

Thanks to all

alsutton

alsutton

2005-09-29 10:42

reporter   ~0011447

Hi all,

If a 1.0.0rc2 patch is made can instructions be included on how to apply it to an already configured system? (I've already deleted the admin directory as directed so the schema.php will fail).

Thanks,

Al.

indy

indy

2005-09-30 05:52

reporter   ~0011454

I'll make a patch for 1.0.0rc2 this weekend and include a mail sample and an installation howto!

fafnir

fafnir

2005-10-27 03:45

reporter   ~0011549

Will there be a patch for RC 1.0.0rc2? Or will the patch for rc1 work as well? Keep up the good work!

indy

indy

2005-10-27 03:54

reporter   ~0011550

I'm sorry - until now I was not able to take enough time for making a new patch set for Mantis 0.19.3 and 1.0.0rc2.

Maybe, the current patches will work, but there are still some bugs.

moppel

moppel

2005-10-27 08:37

reporter   ~0011554

Are there any plans to integrate this feature in Mantis in an official release?

indy

indy

2005-10-31 05:29

reporter   ~0011564

Jo... I'm ready.
It's been taking a long time, but now, the patches for the current stable and development releases are ready.
Feel free to test it.

For Windows users I'll put ZIP-archives including the patch and necessary stuff on http://arme-und-beine.de/download

@moppel:
Including the patch into official release would be nice, but I have not the privileges to decide this.

jlatour

jlatour

2005-11-01 07:48

reporter   ~0011568

The code looks really nice and clean, I think we can integrate this after we put out 1.0 (we want to finally get that out first).

A few notes:

  • I see a debug line at the top of bug_report_mail.php
  • There doesn't seem to be an upgrade script for the database (integrated in the standard upgrade procedure) - could you add your alter queries to the script?
  • You chose a password for the mail user? Maybe we should set the MD5-ed value to an impossible hash, to make sure that no one can log in to any Mantis installation.
  • The README will have to be integrated into the manual

Really impressive work!

indy

indy

2005-11-01 16:41

reporter   ~0011575

  • I see a debug line at the top of bug_report_mail.php
    Yes, I forgot to remove this line... Sorry

  • There doesn't seem to be an upgrade script for the database (integrated in the
    standard upgrade procedure) - could you add your alter queries to the script?

  • You chose a password for the mail user? Maybe we should set the MD5-ed value

  • The README will have to be integrated into the manual
    Yes, of course, it's possible. I'll do this in the patch for the next release.

Really impressive work!
:-)

reality

reality

2005-11-07 07:18

reporter   ~0011598

Hi. I've used Mantis 1.0.0rc2 patch. If I send mail with subject, mail body and attachment I get "It seems, there is no text... :-o" in bug description field. My settings are:
$g_mail_reporter = "Mail";
$g_mail_use_reporter = ON;
$g_mail_auto_signup = OFF;
$g_mail_parse_mime = ON;
$g_mail_save_from = OFF;
Is it a bug or my settings are incorrect?

indy

indy

2005-11-07 08:44

reporter   ~0011599

This could be a bug.

Maybe, please send me you testmail to gerrit.beine@gmx.de. I'll take a look.

cube23

cube23

2005-11-30 16:53

reporter   ~0011675

poll mail cron info.

If someone need a win32 cron running as a service(i try it with XP Pro),
to poll mails or execute da "bug_report_mail.php" from da commandline...

i use a ".cmd" batchfile with "c:...\php c:...\bug_report_mail.php"
for the crontab.

It works great with a freeware from http://www.kalab.com/freeware/cron/cron.htm

greetz & great work indy

jaapandre

jaapandre

2005-12-07 03:50

reporter   ~0011709

nice work, you have done so far. I hope this will improve our work substantially, unfortunately:
patching admin/schema.php failed for rc3, other files were ok.
3 out of 3 hunks FAILED -- saving rejects to file mantis-1.0.0rc3/admin/schema.php.rej

investigating it a little further: in mantis-1.0.3rc3tar.gz schema.php had ^M (control-M) at the end of every line, so patch couldn't find the lines.... removing them, solved the issue.

indy

indy

2005-12-23 09:25

reporter   ~0011842

Hi all,

I've made a quick and dirty patch for Mantis 0.19.4 and 1.0.0rc4.

It's available here: http://arme-und-beine.de/projekte_mantis.html

Until now, I haven't found enough time to test it, but I hope it's working.

So long...

jaapandre

jaapandre

2006-01-11 11:20

reporter   ~0011908

It's all working!!!!!
I use rc3 a few remarks:
1) in mail_api.php line 250 was:
#$t_pop3->deleteMsg($i);
so mail was not deleted and so only the first messages was imported to mantis over and over again, removing # fixed this
2) if you add a note via email to an existing issue with in config_inc.php:
$g_mail_use_reporter = ON;
$g_mail_save_from = ON;
the sender is not added to the note.
3) determing the issueId from subject is done with pregmatch("/[([A-Za-z0-9-. ]*\s([0-9]{7}?))]/",....... but '&' is also allowed as character in a project name, but is not allowed in preg_match. Maybe more characters are missing from that preg_match. Work around: don't use a project name as it is not used, but put a space between first bracket and issueId
4) removed newlines at mail_api.php and bug_report_mail.php, but maybe i added them as well ;-)

dapozzom

dapozzom

2006-01-13 07:42

reporter   ~0011929

I've the following two problems
1) getting the mail the message
APPLICATION ERROR #11
A necessary field 'Riassunto' was empty. Please recheck your inputs.
Also if the bug is correctly created in mantis
2)the getting loads only the first mail into mantis and delete the mail to have all the mail loaded in mantis I need to rerun the the getting so seven mail seven executition of bug_report_mail.php

jaapandre

jaapandre

2006-01-13 08:44

reporter   ~0011931

regarding bugnote id 11929 ad 2) Only load one message:
This is a feature which can be set in config_inc.php:

How many mails should be fetched at the same time

# If big mails with attachments should be received, specify only one
$g_mail_fetch_max   = 1;

See also doc/README.bug_report_mail

dapozzom

dapozzom

2006-01-13 09:00

reporter   ~0011932

In my configuration the parameter is set to 20

indy

indy

2006-01-13 09:09

reporter   ~0011933

Maybe, this could be to large.
Please check the memory limit for PHP.

lig

lig

2006-01-20 03:20

reporter   ~0011982

i've posted conceptual issue 0006619.
i think concept of reporting by email in the public release must look like this.

jaapandre

jaapandre

2006-02-03 12:22

reporter   ~0012075

I have to problems with this patch:
1) mime_mail is not handled correct, the text and html version is put in note-field (is add note, maybe add issue is handled correct).
2) checking for new mail, gives in the logfiles an authentication error:
cyrus/pop3d[8569]: login: example.com[ipadres] account plaintext
cyrus/pop3d[8569]: could not find password
cyrus/pop3d[8569]: badlogin: examplecom[ipadres] APOP (<id>) SASL(-13): user not found: could not find password

rainman

rainman

2006-02-03 13:15

reporter   ~0012077

FYI: I'm using an older release with my own bug fixes (see notes above) but I found a situation where when one of the reporter email addresses was invalid, the reply from the postmaster was added as a note, which caused another email to go out to the reporter, which caused another reply from the postmaster ... Well, you get the picture. I fixed it by checking the from address and ignoring emails from the postmaster, however there's probably a smarter way to fix it.

mc

mc

2006-02-13 15:10

reporter   ~0012140

Can i use 1.0.0rc3 patch for Mantis 1.0.0 relase?

dapozzom

dapozzom

2006-02-14 02:28

reporter   ~0012143

I'm using the patch with 1.0.0 and works fine.

Nekronomekron

Nekronomekron

2006-02-21 05:36

reporter   ~0012202

Hy guys,

I am very interested in this feature of Mantis but I don't have the possiblities to test this patch at the moment.

My question is: How does the E-Mails look like?? Is it difficult to write them, that the system can work with them? Is it a very robust system, or is it possible that a single character can crash the whole system??

C YA - []Nekro

EBY

EBY

2006-02-21 23:28

reporter   ~0012206

I just installed this patch to 1.0.1 and it is great! A few little glitches I have noticed:

-Email are not removed from the mailbox. Easily solved as indicated by jaapandre
on 01-11-06 11:20 below...
-If I send a Plain Text + HTML file, which results in a multi-part message in MIME format... then the email is not extracted properly into the issue description.

indy

indy

2006-02-22 00:51

reporter   ~0012207

Hi there,

I'm working on the next "release".
It supports correct handling of MS Outlook mails (especially multipart mails), decoding of base64 and utf-8 encoded messages and some more bugfixes and patches people sent me.

I'll submit it after the 5th of march (after the chemnitzer linux days)

So long...

Gerrit

EBY

EBY

2006-02-22 09:36

reporter   ~0012210

Would there be an easy way to:

-Keep the emails on the mail server but avoid creating new issues each time they are fetched without deleting the emails? I would like to keep a trace in my mailbox. What I do for now is a rule on the mail server to copy email to a second mailbox from which mantis will fetch emails and deletes them afterward.
-When adding notes through email to an existing issue, parse the content to only add the reply from the sender added... notes become big quickly and notification emails sent out can become hard to read for end users.
-This one is more a mantis issue but could the notification emails for new notes only contain the last note with out of the box configuration? I know that I could do this through customization, just hoping there is a setting that I did not find! This would take care of my previous question.

Nekronomekron

Nekronomekron

2006-02-24 02:32

reporter   ~0012217

Hi,

How can I apply the patch to my mantis system?? Which programm do I need?? I am using a WindowsXP OS...

C YA - Nekro

indy

indy

2006-02-24 03:17

reporter   ~0012218

Take a look to this site:

http://arme-und-beine.de/projekte_mantis.html

I offer some patched archives of Mantis for download.

EBY

EBY

2006-02-24 22:46

reporter   ~0012226

Last edited: 2006-02-25 04:05

I cannot get the email attachment to be added to my issues. I have the Mail_MIME package installed... and I can attach file to other issues for the same project manually just fine. Any idea what else I could check?

EDIT: Ok, I isolated the problem to this line that fails in file_api.php: <i>move_uploaded_file( $p_tmp_file, $t_disk_file_name )</i> I checked both src and dest file names and they are Ok... plus I see the uploaded file created properly in my /tmp/ directory. It does not seem to be linked to privileges and I have safe mode OFF. I am using DISK upload.

EDIT 2: Was this tested under Linux with DISK storage? From what I read, the move_uploaded_file function will only work if the file being moved was actually uploaded. When you save the file you got from the POP3 server to the /tmp/ directory it does not look like it qualifies for that function and it refuses to move it to my project's upload folder. I finally got it to work like this:

<b>file_api.php:</b>
...
<i>#if ( !move_uploaded_file( $p_tmp_file, $t_disk_file_name ) ) {</i>
if ( !<b>rename</b>( $p_tmp_file, $t_disk_file_name ) ) {
<i>#trigger_error( FILE_MOVE_FAILED, ERROR );</i> - error in constant name...
triggererror( <b>ERROR</b>FILE_MOVE_FAILED, ERROR );
}
chmod( $t_disk_file_name, 0400 );
...

<b>mail_api.php:</b>
...
function mail_add_file( $p_bug_id, $p_part ) {
$GLOBALS['_mailfile'] = $p_part['Name'];
if ( 0 < strlen($p_part['Name']) ) {
$t_file_name = '/tmp/'.$p_part['Name'];
file_put_contents($t_file_name, $p_part['Body']);
file_add($p_bug_id, $t_file_name, $p_part['Name'], $p_part['Content-Type'], 'bug');
<i>#unlink($t_file_name);</i>
}
}
...
I really have limited PHP knowledge... but this did the trick for me, I finally get attachments for my Email reports! I am running you Email patch for 1.0.0rc4 on Mantis 1.0.1.

EBY

EBY

2006-03-02 22:51

reporter   ~0012271

Last edited: 2006-03-17 09:36

What about setting the priority in Mantis based on if the email is sent with low / normal / high priority? Using a set of variables to configure to what the email priority should translate into Mantis priority...

EDIT: Made a quick & dirty patch to enable this, seems to work OK:

<b>config_inc.php:</b>
$g_mail_use_bug_priority = ON;
$g_mail_bug_priority_default = NORMAL;
#dirty... yuk!
#X-Priority... depends how set by mail server...
$g_mail_bug_priority = array( '5 (Lowest)' => 10,
'4 (Low)' => 20,
'3 (Normal)' => 30,
'2 (High)' => 40,
'1 (Highest)' => 50,
'5' => 20,
'4' => 20,
'3' => 30,
'2' => 40,
'1' => 50,
'0' => 10,
'Low' => 20,
'Normal' =>30,
'High' => 40,
'' => 30,
'?' => 30 );

<b>mail_api.php - mail_parse_content</b>
...
$v_mail['Subject'] = $t_structure->headers['subject'];
<i><b>$t_mail_use_bug_priority = config_get( 'mail_use_bug_priority' );
if($t_mail_use_bug_priority == true)
{
$v_mail['X-Priority'] = $t_structure->headers['Priority'];
}</b></i>
...

<b>mail_api.php - mail_add_bug </b>
...
$t_mail_save_from = config_get( 'mail_save_from' );
<i><b>$t_mail_use_bug_priority = config_get( 'mail_use_bug_priority' );
$t_mail_bug_priority_default = config_get( 'mail_bug_priority_default' );
$t_mail_bug_priority = config_get( 'mail_bug_priority' );</b></i>

    $t_bug_data = new BugData;
    ...
    ...
    ...
    $t_bug_data->severity           = 50;
    <i><b>if ($t_mail_use_bug_priority == true)
    {
        $t_bug_data->priority       = $t_mail_bug_priority[$p_mail['X-Priority']];
    }
    else
    {
        $t_bug_data->priority       = gpc_get_int( 'priority', $t_mail_bug_priority_default );
    }</b></i>
    $t_bug_data->summary            = $p_mail['Subject'];
    ...
EBY

EBY

2006-04-21 15:10

reporter   ~0012659

Indy, you indicated that you had a new release in the work for better Outlook support... will this be released for 1.0.x or will it be only ready for the 1.1 release that will incorporate the email reporting feature?

I am having numerous problems with Outlook emails which make email submission unreliable in my environment. I am eagerly waiting for any improvements!

indy

indy

2006-04-21 15:15

reporter   ~0012660

Hi,

I'm sorry.
At the moment I'm working on my diploma thesis.
And I have a fulltime job.

On May, 2nd the thesis period will be over, then I'll offer new patches with some new features and fixes, especially for mails sent with Outlook.

So long...

indy

indy

2006-05-10 08:54

reporter   ~0012813

Hi,

I'm back ;-)

Now, a patch for Mantis 1.0.3 is available.
It contains support for HTML content and encoded mails.

I've also added the patches by EBY with some minor changes.

In this version, the processing of mails changed: bug_report_mail no longer fetches all mails into an array.
The mails are fetched one after another from the mail server and are processed directly.

Feel free to test and report bugs, if there are any.

So long...

Indy

ericb

ericb

2006-06-09 00:02

reporter   ~0012949

Can someone clariy for me what this patch will do? I've installed it and can get incoming emails to be added as new issues. But, what I really want to accomplish is allowing users to reply to emails that mantis sends out on existing issues and have their reply added as a note to the issue. Can this patch do that? My testing is just with simple text emails.

bmccool

bmccool

2006-06-19 07:05

reporter   ~0012985

How exactly would i set this up on a Windows server with exchange running in the background? My linux knowledge leaves much to be desired.

My mantis installation is currently running 100% with no issues but it is a business requirement that can accept incoming emails for tickets.

I've been through the entire note list so far and not much has been cleared up.

bmccool

bmccool

2006-06-20 04:02

reporter   ~0012996

^^^ignore that, i got it working \o/ ^^^

Sort of, anyway.

I've added the following to my config_inc.php
$g_mail_auto_signup = ON;
$g_mail_parse_mime = ON;

The MIME parsing is functioning correctly but the auto signup is not. I've snt mails from various accounts but it always reports the user as the mail reporter. I've since deleted the mail reporter user and now the tickets have no reporter whatsoever.

Any help there pls.

Also, i've noticed that the version number have a conflict. I've loaded a test version of mantis 1.0.3 and the latest mail patch but the version number displaying at the bottom of the screen reports Mantis 1.0.0rc4.

Any help would be appreciated!

EBY

EBY

2006-06-20 16:41

reporter   ~0013000

Last edited: 2006-06-20 17:04

Just got around to try to install your latest patch... could there be an error with the patch file, I highlighted in bold what I think should not be there, i.e. replace with 'mantis_project_table'. BTW, I am applying the patch to a clean 1.0.3 install.

$upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_project<b>file</b>table'),"
@@ -222,7 +225,11 @@
view_state I2 NOTNULL DEFAULT '10',
access_min I2 NOTNULL DEFAULT '10',
file_path C(250) NOTNULL DEFAULT \" '' \",

  • description XS NOTNULL
  • description XS NOTNULL,
  • pop3_host C(250) NULL,
  • pop3_user C(250) NULL,
  • pop3_pass C(250) NULL,
  • pop3_categories L NOTNULL DEFAULT '0'
    ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS')));
    $upgrade[] = Array('CreateIndexSQL',Array('idx_project_id',config_get('mantis_project_table'),'id'));
    $upgrade[] = Array('CreateIndexSQL',Array('idx_project_name',config_get('mantis_project_table'),'name',Array('UNIQUE')));

Update: I found other issues in the patch file for the following files, could you have done your diff on a 'non default 1.0.3' build? I patched files manually and all seems fine now.

File to patch: mantis-1.0.3/admin/schema.php
File to patch: mantis-1.0.3/manage_proj_mail_update.php
File to patch: mantis-1.0.3/manage_proj_edit_page.php

bmccool

bmccool

2006-06-21 05:34

reporter   ~0013005

okay then, i was just being stupid...

Got my mails working. It sends and receives emails without attachments briliantly.

Problem now comes in when i send a message with an attachment(doesn't matter if it is the first issue or any of the subsequent responses). The issue will be created and the subject is placed in the summary field but in the description it states "It seems, there is no text... :-o"

The file does not get attached to the issue either.

bmccool

bmccool

2006-06-29 05:11

reporter   ~0013049

how would i go about setting the following?

I need to exclude all email addresses (except internal) from receiving the signup notification.

I also need to exclude certain email addresses from receiving any mails whatsoever. These will be messages that come from other systems relating to downtime, program errors, etc.

Any help would be appreciated!

bmccool

bmccool

2006-07-11 09:25

reporter   ~0013084

Is indy still around?

I need to install the 1.0.3 patch but i need the windows version... I checked his site and there is nothing available. The last patch is mantis-1.0.0rc4.zip...

I have a feeling that this patch will resolve my issues.

indy

indy

2006-07-11 13:07

reporter   ~0013086

Yes, he is ;-)

I'll create a patched version of Mantis 1.0.3 this evening and post the URL here.

bmccool

bmccool

2006-07-12 03:28

reporter   ~0013088

Thanks indy, any news on that URL?

cas

cas

2006-07-12 06:53

reporter   ~0013089

Last edited: 2006-07-12 07:00

using Mantis 1.0.1 I noticed that although mail_fetch_max was set to 1, multiple emails were imported and not all correct.
Not sure why this happens but managed to correct this in mail_api.php, function mail_process_all_mails.

I changed this:
for ($j = 1; $j <= $t_pop3->numMsg(); $j++ )

into this :
if ($t_mail_fetch_max <=$t_pop3->numMsg()){
$limit = $t_mail_fetch_max;
} else{
$limit = $t_pop3->numMsg();
}
for ($j = 1; $j <= $limit; $j++ )

Most likely there is a better way, if so please let us know.

indy

indy

2006-07-16 08:28

reporter   ~0013102

Heyho,

patched versions of Mantis 1.0.3 are available now:
http://www.gerritbeine.de/download/mantis/

So long...

bmccool

bmccool

2006-07-18 05:45

reporter   ~0013109

Thanks for the patched release.

Strange error though. If i install a new version then the db is setup perfectly. If i update an existing installation then the db changes are not applied.

I cannot access the manage projects section as i get the following error:

APPLICATION ERROR 0000401
Database query failed. Error received from database was #1054: Unknown column 'pop3_host' in 'field list' for the query: SELECT pop3_host, pop3_user, pop3_pass, pop3_categories
FROM mantis_project_table
WHERE id='14'

I've checked the db and true enough the mentioned fields do not exist. They do exist on a new installation though.

This is causing a bit of a problem as i cannot upgrade my current live release to the latest version.

Any ideas?

indy

indy

2006-07-18 05:52

reporter   ~0013110

Please take a look to doc/README.bug_report_mail

Quote:

If you are alway running Mantis you have to alter your projects table
with the sql/bug_report_mail.sql script.
If not, you can create the database tables in the way described in
the doc/INSTALL file.

So long...

Indy

bmccool

bmccool

2006-07-19 07:00

reporter   ~0013114

Yeah, sorry about that. The typo had me a bit confused... I think alway should actually be already.

Different problem now though...

I've enabled auto_signup to create a user for each incoming ticket.

It imports the first mail from a user perfectly but if i submit a 2nd email it will not import the data.

I enabled debugging and ran bug_report_mail.php in IE. The following displays:

Array ( [0] => Array ( [0] => 27 [id] => 27 [1] => Mail Requests [name] => Mail Requests [2] => 10 [status] => 10 [3] => 1 [enabled] => 1 [4] => 10 [view_state] => 10 [5] => 10 [access_min] => 10 [6] => [file_path] => [7] => This is for incoming mails (rfs@domain.com) [description] => This is for incoming mails (rfs@domain.com) [8] => mail.domain.com [pop3_host] => mail.domain.com [9] => DOMAIN\RFS [pop3_user] => DOMAIN\RFS [10] => Password [pop3_pass] => Password [11] => 0 [pop3_categories] => 0 ) ) Array ( [Received] => from TESTSVR ([10.1.0.200]) by server.domain.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id PGMJG0QS; Wed, 19 Jul 2006 11:34:03 +0200 [Message-ID] => <291B76E98794D511878C0010B5EC4BEE02A86E07@mail.domain.com> [From] => TEST System [To] => user@domain.com [Subject] => TEST New company registration [Date] => Wed, 19 Jul 2006 11:22:30 +0200 [MIME-Version] => 1.0 [Content-Type] => text/plain; charset="iso-8859-1" [X-Mantis-Body] => New client Registration Company: edwed Contact Person: sds Telephone: 21 21 Ben3 [Priority] => 30 )

Below that i get:

APPLICATION ERROR 0000801
User not found.

Weird indeed. This used to work perfectly before i applied the latest version.

Help please!

cas

cas

2006-07-19 08:31

reporter   ~0013115

We receive from time to time mails without subject and the import script stumbles over this.
this can be easlily adjusted by something like this :
if ($p_mail['Subject'] == ""){
$p_mail['Subject'] = "No Subject found" ;
}
$t_bug_data->summary = $p_mail['Subject'];
if ( $t_mail_save_from ) {
$t_bug_data->description = "Report from: ".$p_mail['From']."\n\n".$p_mail['X-Mantis-Body'];
} else {
if ($p_mail['X-Mantis-Body'] == ""){
$p_mail['X-Mantis-Body'] = "No Description found" ;
}
$t_bug_data->description = $p_mail['X-Mantis-Body'];
}

where the original code was :
$t_bug_data->summary = $p_mail['Subject'];
if ( $t_mail_save_from ) {
$t_bug_data->description = "Report from: ".$p_mail['From']."\n\n".$p_mail['X-Mantis-Body'];
} else {
$t_bug_data->description = $p_mail['X-Mantis-Body'];
}

Before i forget, adjustment has to be made in mail_api.php.

Finally want to confirm the issue and fix reported by EBY (0012226) when using DISK as storage solution.

Cas

indy

indy

2006-07-19 15:18

reporter   ~0013117

I'll integrate this new patch and fix the errors on weekend.
I think I have a little time then.

So long...

bmccool

bmccool

2006-07-24 03:25

reporter   ~0013130

Not too sure if you've done the integration yet but if not would it possible to integrate directly with version 1.0.4. which was released over the weekend?

indy

indy

2006-07-24 04:37

reporter   ~0013131

Hi bmcool,

I'll do this.
But this weekend I had to create an PDF exporting tool for the MediaWiki, so I wasn't able to work on my Mantis patch.

So long...

dcolliervb23

dcolliervb23

2006-07-26 23:58

reporter   ~0013159

i downloaded the copy from indy's link on 7/16/2006, but when I try to click the link for managing my specific project (manage_proj_edit_page.php?project_id=1), I get the following error:

SYSTEM WARNING: main(PEAR.php): failed to open stream: No such file or directory

It looks like all necessary pear packages are in it, except for this file. Do I need to download this file from another package off pear.php.net?

Thanks.

indy

indy

2006-07-27 03:12

reporter   ~0013160

You may use the PEAR.php from http://pear.php.net/package/PEAR

cas

cas

2006-07-31 06:42

reporter   ~0013171

I also can confirm BMCCOOL's comment (0013114) that when wants the user to be added if it does not exist, the latest patch acts strangely. It indeeds generates a "User not found" error.
I could tackle that by commenting the following line "auth_attempt_script_login($t_reporter);".
However strangely enough this only imports the mail the second time the script is run.
Any clue on this issue ?

Cas

cas

cas

2006-07-31 06:42

reporter   ~0013172

Last edited: 2006-07-31 06:44

I also can confirm BMCCOOL's comment (0013114) that when one wants the user to be added if it does not exist, the latest patch acts strangely. It indeeds generates a "User not found" error.
I could tackle that by commenting the following line "auth_attempt_script_login($t_reporter);".
However strangely enough this only imports the mail the second time the script is run.
Any clue on this issue ?

Cas

cas

cas

2006-08-18 05:33

reporter   ~0013293

I have spotted another issue (and created the solution for it).
We had problems if a mail was received with more than one picture embedded in the body of the message.
This caused a dupicate file error since every embedded picture was attached using the same filename causing the error message.
In order to overcome this issue, we need to change two functions :

function mail_add_bug
add the end where the files are attached i included a counter to be passed to the mail_add_file routine.

Add files

if ( null != $p_mail['X-Mantis-Parts'] ) {
$filenr=1 ;
foreach ($p_mail['X-Mantis-Parts'] as $part) {
mail_add_file ( $t_bug_id, $part, $filenr );
$filenr ++ ;
}
}

then the mail_add_file routine should be like this

--------------------

Very dirty: Adds a file to a bug.

function mail_add_file( $p_bug_id, $p_part,$p_filenr ) {
$GLOBALS['_mailfile'] = $p_part['Name'];
if ( 0 < strlen($p_part['Name']) ) {
$t_file_name = '/tmp/'.$p_part['Name'];
file_put_contents($t_file_name, $p_part['Body']);
$mantisname = $p_filenr;
$mantisname .= $p_part['Name'];
file_add($p_bug_id, $t_file_name, $mantisname , $p_part['Content-Type'], 'bug');
#unlink($t_file_name);
}
}

Hopefully this helps others too.

Cas

indy

indy

2006-08-18 07:05

reporter   ~0013294

Thanks to cas, I've added your patch.

indy

indy

2006-08-18 08:17

reporter   ~0013295

Heyho,

I've updated the patch for Mantis 1.0.5.

See: http://gerritbeine.de/download/mantis/

The mail parsing is a complete rewrite, now it should support all combinations of embedded HTML and text and also different encodings.

So long...

bmccool

bmccool

2006-09-12 07:03

reporter   ~0013367

Hi,

I've recently upgraded to 1.0.5 but get the following error when i run bug_report_mail.php

[pear_error: message="Generic login error" code=1 mode=return level=notice prefix="" info=""]

This is just the portion of the error that i think is causing the error. I've never seen it before and google doesn't know much either...

Any ideas?

cas

cas

2006-09-14 10:57

reporter   ~0013385

Indy,

i have found 2 little issues. One of the nice things of this add-on is that when a second mail arrives with the same topic, it adds it as a note to the original.
This however happens regardless of the status of the original issue. Think we need a treshold to decide to add it as a note or to create a new issue.

If you find time to look at this, could you also strip the "RE:" that outlooks adds to the subject when replying such that also those messages can be added as a note ?

vboctor

vboctor

2006-09-14 13:39

manager   ~0013386

A lot of attachments were lost after the crash of mantisbt.org. Indy, can you please attach the latest code. I will patch this Mantis installation to show the broken attachments.

indy

indy

2006-09-17 09:14

reporter   ~0013407

Hi there,

the latest version of the mail import patch is available again.

It is still unchanged, I'll fix the noticed issues when I'm back from Kyrgyzstan in the middle of October.

achumakov

achumakov

2006-09-17 10:50

reporter   ~0013408

Wow, indy! What are you doing there in Kirgyzstan? Are you Russian?

indy

indy

2006-09-17 11:00

reporter   ~0013409

No, I'm German. ;-)
My professor asked me if I would like to hold a workshop in Java programming with him at the university in Bishkek.

achumakov

achumakov

2006-09-17 11:09

reporter   ~0013410

That's cool, anyway

vboctor

vboctor

2006-09-19 04:49

manager   ~0013413

Hey everyone, just wanted to let you know the good news that Indy has joined the Mantis development team and we will work together in getting this feature into Mantis codebase.

The first step will be to write the requirements of the feature in the Wiki. The aim of this excercise will be to indentify any necessary changes that are required before including this in the offical codebase. Once this is done it shouldn't be a lot of work to implement the changes and get this stuff in.

http://wiki.mantisbugtracker.com/doku.php/mantisbt:requirements

I would like to take this chance to thank Indy for his work so far and looking forward to work closely with him once he gets back from his business trip.

thoben

thoben

2006-10-09 12:40

reporter   ~0013595

I'm just testing this nice feature under Windows. I had some difficulties with attachments because of the hard-coded '/tmp' in the mail_add_file-function.
I changed it to use the mail_tmp_directory-parameter:
function mail_add_file( $p_bug_id, $p_part, $number ) {
$t_mail_tmp_directory = config_get( 'mail_tmp_directory' );

$GLOBALS['_mail_file_'] = $p_part['name'];
if ( 0 &lt; strlen($p_part['name']) ) {
    $t_file_name = $t_mail_tmp_directory.$p_part['name'];
    file_put_contents($t_file_name, $p_part['body']);
    file_add($p_bug_id, $t_file_name,  $number.&quot;-&quot;.$p_part['name'], $p_part['ctype'], 'bug');
    unlink($t_file_name);
}

}

cas

cas

2006-10-18 10:36

reporter   ~0013622

Last edited: 2006-10-18 10:55

Indy,

i notice different behavior if i run the bug_report_mail.php script through a commandline. Amongst other things, retrieving the reporter id seems to fail. If i run the script through the browser all works fine.
Is this a known issue and if so, is a fix available and/or known ?

vJack

vJack

2006-11-10 03:19

reporter   ~0013712

This is a fantastic feature I'm really hoping to use, but I've hit an error.

When I go to Manage/Manage Projects/'specific project' (manage_proj_edit_page.php) I get the following error:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /mantis/Mail/Parser.php on line 7

I made a complete new install using the 1.0.5 package from Indy's site: http://gerritbeine.de/download/mantis/mantis-1.0.5.tar.bz2

All the files and db tables apear to be in place, and the rest of Mantis functions fine. Any ideas?

rellg

rellg

2006-11-16 05:29

reporter   ~0013726

Hi!

I need some help!

At here we use utf-8 for mail encoding. This is not too nice in mantis when I report a bug by mail.
It doesn't use the right characters.
Can somebody help me?

DTGI

DTGI

2006-11-19 05:45

reporter   ~0013738

vJack,

I had the same problem. The cause is the Parser.php. The php scripts in this file are wrote to support only PHP version 5.x. So when I tried to make it work on my PHP 4.x hosting, it resulted in similar errors.

Somehow the code should be refactored to support both versions PHP 4.x and 5.x, I guess.

bmccool

bmccool

2006-12-07 01:53

reporter   ~0013779

wrt my post (0013367)

Anybody have any ideas how i can get past the "generic login error" when i run bug_report_mail.php?

jnak

jnak

2006-12-11 19:13

reporter   ~0013803

hi everyone I'm trying to get this nifty feature working in windows. so far I'm not getting any errors but I'm unsure of a couple things. Is the 'mail' user that needs to be set up the address that we would be sending e-mails to to report a bug via e-mail? and also is opening bug_report_mail.php from the web browser the proper way to retrieve the e-mails for entry into reporting the bug?

vboctor

vboctor

2006-12-12 02:20

manager   ~0013805

The Mail\Parser.php uses the new format specifiers which are not supported by PHP 4.x. Hence, this will not work on the PHP servers running on most of the Mantis installations out there and won't be compliant with Mantis current minimum requirements.

I got it passing the syntax check, but haven't tested it, by removing the following:

  • Replace "private " with "var " for variables.
  • Replace "__constructor" with the class name.
  • Replace "public " with nothing.

It would be great if we can use an older version of this module which supports 4.x. In the worst case, we should avoid including these files if the installed version of PHP is 4.x.

indy

indy

2006-12-12 07:07

reporter   ~0013808

The Mail_Parser class is written by me.
I'll make it PHP 4.x compatible before commiting it into CVS.

Sorry, I have no more PHP 4.x installations running... ;-)

jnak

jnak

2006-12-13 15:36

reporter   ~0013822

what syntax must e-mails follow to be parsed properly for reporting issues?

jnak

jnak

2006-12-14 18:19

reporter   ~0013829

Is my understanding of this correct? After installation of the patch you go to manage project accounts and add a user/email address and set up a reporter account? and set it up for the current category of the project? upon running bug_report_mail no errors get generated and nothing changes in the database even when I try to get it to be more verbose. Is there something glaringly obvious that I'm missing? any assistance would be appreciated.

EBY

EBY

2006-12-20 19:22

reporter   ~0013854

Last edited: 2006-12-21 10:00

Small issue with your debug mode... emails are always saved to file to my temporary folder even if debug is off. Looks like you do not check if the debug mode is ON or OFF in the mail_save_message_to_file function, despite the fact that you retrieve the config param value.

I moved the call to the mail_save_message_to_file function in mail_process_all_mails like this:

...

function mail_process_all_mails( &$p_account ) {
<b>$t_mail_debug = config_get( 'mail_debug' );</b>
$t_mail_fetch_max = config_get( 'mail_fetch_max' );

...

if ( $t_mail_debug ) {
print_r($t_mail);
<b> mail_save_message_to_file( $t_msg );</b>
}

<b>#mail_save_message_to_file( $t_msg );</b>
mail_add_bug( $t_mail, $p_account );

...

RyanR

RyanR

2007-01-21 22:01

reporter   ~0013941

Does anyone have a patch for this feature based on 1.1.0a2?

indy

indy

2007-01-22 00:45

reporter   ~0013943

Sorry, there is no newer patch at the moment.
I'm in Uganda until march and it is not possible here to work on it.

I'm sorry. When I'm back in Germany, the development of my patch will continue.

redcom

redcom

2007-01-24 16:08

reporter   ~0013959

Is there a reason this has not been committed to the development tree to officially supported, instead of having to patch every release?

indy

indy

2007-01-25 00:27

reporter   ~0013961

Victor gave me already CVS access, but I was not able to commit the patch into the offical Mantis sourcecode.

I was very busy the last months.

dapozzom

dapozzom

2007-02-05 10:24

reporter   ~0014004

Where I can findout all the modules updated for 1.1.0a1

drtns

drtns

2007-02-23 12:56

reporter   ~0014088

I would just like a quick confirm, that the 1.0.5 patch works for 1.0.6??

Jimmy

Jimmy

2007-02-28 10:09

reporter   ~0014117

Same question:

I would just like a quick confirm, that the 1.0.5 patch works for 1.0.6??

EBY

EBY

2007-03-27 14:33

reporter   ~0014255

A small problem I noticed and for which I am trying to find a solution:

If you forward the same email to Mantis twice (or different emails with same attachments names and order) to add a bug note to an existing bug... then on the second email, the system will add the new bug note but when it tries to add the attachment it will fail and result in a "duplicate file" error.

Although this mod adds a prefix (1-, 2-, 3-, etc.) to each attachment in the same email, it will have problems when subsequent emails for the same bug have the same attachments names and in the same order.

As a result, the email is parsed into the existing bug note, the attachments dont make it and the email is left in the mailbox after the error is triggered. This means that on the next email fetch, the email is still parsed and bug note added again and failure on attachment (duplicate file name in database) will again leave the email in the mailbox... repeating over and over... with email notification going out non stop each time the email is parsed again. You get the picture.

I am trying to find a solution for this: deleting the email prior to this attachment parsing is a quick fix but not intuitive to users as their attachments are just dropped. Ideally, a way to number attachments globally would work... if at the time where the system starts numbering attachments for a new email, it 1st fetched the max attachment prefix number for the current bug. More work.

EBY

EBY

2007-03-27 15:09

reporter   ~0014256

I made a quick and dirty fix for the problem I just reported:

I do not use the attachment numbering code found in mail_api.php, I could take out the numbering completely but decided to just comment out where it added when passed to the file_add code:

#EBY 20070327 - bug with prefix

file_add($p_bug_id, $t_file_name, $number."-".$p_part['name'], $p_part['ctype'], 'bug');

        file_add($p_bug_id, $t_file_name, $p_part['name'], $p_part['ctype'], 'bug');

Instead when it comes time to check for the unicity of the new attachment file name in the database, I replaced the check as follows:

#EBY 20070327 - fix duplicate attachment issue
$number = 1;
while (!file_is_name_unique( $number . '-' . $p_file_name, $p_bug_id ) )
{
$number++;
}
$p_file_name = $number . '-' . $p_file_name;

if ( !file_is_name_unique( $p_file_name, $p_bug_id ) ) {

trigger_error( ERROR_DUPLICATE_FILE, ERROR );

}

This works great and if I forward more copies of the same file in different emails they all get added with a different unique prefix. Not a very elegant solution (dont like that kind of loop) but it does the job for now!

EBY

EBY

2007-03-27 15:44

reporter   ~0014257

Regarding the 1.0.5 patch for Email on release 1.0.6... I got mine to work although I did have some problems that required minor edits. I don't think the problems I encountered were related to the patch being made for 1.0.5 but rather just small bugs that caused minor issues on my specific setup.

jboulay

jboulay

2007-04-19 16:31

reporter   ~0014370

Hi everybody,

it's a very nice stuff !!

I've developped the following evolutions on the mail reporter functionnality:

  • parsing mail body for specific fields
  • batch file for use with a cron tab
  • update to Mantis 1.0.6

you will find a complete 1.0.6 distribution on http://boulayj.free.fr/Open%20Source/mantis1.0.6%20+%20mail%20reporter.zip

dapozzom

dapozzom

2007-05-08 10:53

reporter   ~0014445

The zip file seems to be corrupted

sirshurf

sirshurf

2007-05-10 03:58

reporter   ~0014488

Will there be a version for the 1.1* ????

indy

indy

2007-05-10 07:12

reporter   ~0014490

Yes it will, when I find enough time to work on it again.

sirshurf

sirshurf

2007-05-11 04:23

reporter   ~0014498

Maybe somebody else can do the integration if you dont have the time... (I can look at it if you like...)

jotango

jotango

2007-05-29 10:50

reporter   ~0014650

I would love the email format to be compatible with the bugzilla format: http://www.bugzilla.org/docs/3.0/html/api/email_in.html

Some thought has gone in to the Bugzilla format, I think it would be a good idea to learn from their experience. Plus compatability makes it easier for people to switch to Mantis.

SL-Gundam

SL-Gundam

2007-06-06 11:50

manager   ~0014688

I was in need of this feature for Mantis 1.1.0a3.

This is the result. It's based on mantis-1.0.5.patch.gz

Changelog:
Jun 2007

  • update to Mantis 1.1.0a3
  • Support for PHP 4 ( 0004286:0013805 )
  • Fixed a bug with processing priority's of emails (priority class variable didn't exist in Mail/Parser.php)
  • Updates to the latest PEAR packages
  • print_r changed to var_dump's (Works better if you have xdebug extension installed)
  • New config setting called:

    Default bug category for mail reported bugs (Defaults to "default_bug_category")

    # Because in Mantis 1.1.0a3 a category is required, we need a default category for issues reported by email.
    # Make sure the category exists and it has been configured correctly
    $g_mail_default_bug_category = '%default_bug_category%';
  • Fixed a missing variable in the function: "mail_process_all_mails"
    $t_mail_debug was not set and would cause notice level errors and debug mode in this function wouldn't work ( 0004286:0013854 )
  • Emails are now not allways saved to disk ( 0004286:0013854 )
  • Made sure $t_mail['X-Mantis-Complete'] would allways be populated ( with null value if the config "mail_additional" was disabled )
  • Adding attachments to bug items now also works on Windows systems (Removed hardcoded directory part "/tmp/").
  • The subject of an email is now also trimmed before storing it in $t_bug_data->summary. Like it is in bug_report.php
  • Fixed problem with duplicate attachments ( 0004286:0014255 and 0004286:0014256 )
SL-Gundam

SL-Gundam

2007-06-06 13:45

reporter   ~0014691

I forgot to terminate a line in mail_api.php. ( "Mantis-1.1.0a3-changed_files_only.zip" )

My apologies for that.

I added the package again with the correction in it ( "Mantis-1.1.0a3-changed_files_only-v2.zip" )

Can somebody remove "Mantis-1.1.0a3-changed_files_only.zip". I can't do it myself.

reszel

reszel

2007-06-08 12:59

reporter   ~0014715

How to apply a patch?

Step by step instructions for for reporting via E-Mail patch?

I'm running mantis-1.1.0a3 on a shared host.
I've downloaded "mantis-1.0.5.patch.gz" and "Mantis-1.1.0a3-changed_files_only-v2.zip"

1) I don't know how to apply the patch :=( HELP!

2) After paching, files in ""Mantis-1.1.0a3-changed_files_only-v2.zip" should be copied
over older files installed by the patch.

3) I assume that i have to configure an e-mail forwarder for "reporter@domain.com" like this:
| /usr/local/bin/php -q /home/domain/public_html/mantis/bug_report_mail.php

Correct me if I'm wrong.

reszel

reszel

2007-06-08 13:02

reporter   ~0014716

How to apply a patch???
My step by step instructions for for reporting via E-Mail patch:

I'm running mantis-1.1.0a3 on a shared host.
I've downloaded "mantis-1.0.5.patch.gz" and "Mantis-1.1.0a3-changed_files_only-v2.zip"

1) I don't know how to apply the patch :=( HELP!

2) After paching, files in ""Mantis-1.1.0a3-changed_files_only-v2.zip"
should be copied over older files installed by the patch.

3) I assume that i have to configure an e-mail forwarder for "reporter@domain.com" like this:
| /usr/local/bin/php -q /home/domain/public_html/mantis/bug_report_mail.php

Correct me if I'm wrong.

SL-Gundam

SL-Gundam

2007-06-08 20:09

reporter   ~0014718

I discovered one last small problem that could occur. So thats fixed in Mantis-1.1.0a3-changed_files_only-v3.zip

Because this was the second problem which required patching i tested all the changes. I couldn't find anymore problems.

SL-Gundam

SL-Gundam

2007-06-08 20:17

reporter   ~0014719

@reszel
Copy all files from Mantis-1.1.0a3-changed_files_only-v3.zip to the root of your mantis installation overriding all existing files.

In the /docs/ directory you'll find 2 files called:
bug_report_mail.sql - Contains all the needed database changes.
README.bug_report_mail - Contains general information on a number of the settings you can set.

After the script has been succesfully installed you can log into the admin account. Go to "Manage projects" page. Click on a project. At the bottom of the page you'll find a form to activate email retrieval for that project.

Hope this helps

jhofker

jhofker

2007-06-11 11:16

reporter   ~0014743

Hi Indy,
First, great plugin.

I have a couple of things that I think could improve this even more:
1) The email password box should be an actual password box. Displaying passwords cleartext like that could be a security issue.
2) Default category specification should probably be specified per project. Maybe I just don't use Mantis correctly, though. :-) Is the best way to add the same category to every project (ie, "Email Reported Bugs")?

Keep up the great work!

davide73italy

davide73italy

2007-06-25 08:59

reporter   ~0014809

Why isn't this in CVS branch??

davide73italy

davide73italy

2007-06-25 09:00

reporter   ~0014810

Why isn't this in CVS branch??

bmccool

bmccool

2007-06-25 09:45

reporter   ~0014811

See note 0013961 davide73italy ;)

DaVinci

DaVinci

2007-07-06 16:24

reporter   ~0014892

i still dont get how do i activate the reporting by mail...
when i go to Manage Project and click on a Project and then go the bottom of the page im asked to type in POP3 settings..
which settings are the these?
what do i write there?

axeljung

axeljung

2007-07-15 18:30

reporter   ~0014998

If a email Report via Email with attachments recieved.
this Line throws an Error:

Line 466 in mail_api.php

while( !file_is_name_unique( $number . '-' . $p_file_name, $p_bug_id ) ) {

it have to be:

while( !file_is_name_unique( $number . '-' . $part['name'], $t_bug_id ) ) {

axeljung

axeljung

2007-07-15 18:32

reporter   ~0015000

If a email Report via Email with attachments recieved.
this Line throws an Error:

Line 466 in mail_api.php

while( !file_is_name_unique( $number . '-' . $p_file_name, $p_bug_id ) ) {

it have to be:

while( !file_is_name_unique( $number . '-' . $part['name'], $t_bug_id ) ) {

DaVinci

DaVinci

2007-07-16 04:58

reporter   ~0015036

can someone please help me..i have been waiting for many days now

i still dont get how do i activate the reporting by mail...
when i go to Manage Project and click on a Project and then go the bottom of the page im asked to type in POP3 settings..
which settings are the these?
what do i write there?

jboulay

jboulay

2007-07-16 05:20

reporter   ~0015037

Hi DaVinci,

In the POP3 settings fields, you must type the POP3 connexion parameters.
This will allow you to connect to your mail server and get all the emails processed by the mantis bug reporter extension.

POP3 Host : your mail server
POP3 User : the email account that will receive mail notifications
POP3 Password : the password of this user

Once your pop mail server is configured, you can also configure some parameters in the configuration file

In order to execute the automatic reporter, you have to go on page
http://your_mantis_server/bug_report_mail.php

I hope this will help you ...

DaVinci

DaVinci

2007-07-16 06:44

reporter   ~0015039

thanxx for the reply..
i get the follwoing error message when i try to go to the above link:

error:<db_username> [pear_error: message="-ERR authorization failed" code=-1 mode=return level=notice prefix="" info=""] error:helpdesk@mydomain.com [pear_error: message="Generic login error" code=1 mode=return level=notice prefix="" info=""]

DaVinci

DaVinci

2007-07-16 07:10

reporter   ~0015041

im am the administrator an yet i get the error above

jboulay

jboulay

2007-07-16 08:51

reporter   ~0015043

It seems that your connection parameters are wrong !!

Try to enter the user account only : "helpdesk", without the complete email adress. It should work !

Could you also give me the version of the mail reporter extension you use ?

DaVinci

DaVinci

2007-07-16 10:47

reporter   ~0015044

Last edited: 2007-07-16 10:49

im using:
mantis-1.0.5.patch.gz [^] (109,299 bytes) 2006-09-17 09:09

and i appereciate ur help but i do not understand what do u mean
i get the above error message when i go to:

http://your_mantis_server/bug_report_mail.php

This is what i want to do:

http://www.mantisbt.org/forums/viewtopic.php?t=3429&amp;highlight=

Banek

Banek

2007-07-23 02:35

reporter   ~0015166

Thank you for great patch! :-)

it makes issue and notes for existed issues by email. But it don't create notifications to email reporter via email even with "creating new accounts" option enabled.

I'm using mantis 1.0.5 with mantis-1.0.5.patch.gz

juan777

juan777

2007-07-23 07:58

reporter   ~0015178

Ummm... First of all, thanks to all for that huge and great work.

Second, I have configured this patch ok and I can report issues via web OK including spanish caracters like ñ, á,é,í .. etc...

But using mail reporter plug-in I can report issues via email IF NOT contain these spanish caracters... if contain it i get this error:

How can solve it????????????????Please.

APPLICATION ERROR 0000401
Database query failed. Error received from database was 0001366: Incorrect string value: '\xE1\x0D\x0A\x0D\x0AJ...' for column 'description' at row 1 for the query: INSERT INTO mantis_bug_text_table
( description, steps_to_reproduce, additional_information )
VALUES
( 'Report from: \"Juan\" \n\n poᜲ\n\r\nJuan +34945392080, icom.com\r\n\r\n\r\n\r\n', '',
'' )

Many thanks in advance.

eagle00789

eagle00789

2007-08-25 09:05

reporter   ~0015530

After a lot of work making it work for 1.0.8, i finally have it working. Thanks for such a great patch, but i would love to see this new feature in the upcoming 1.1.0 version!

eagle00789

eagle00789

2007-08-25 11:14

reporter   ~0015531

Please add the following line to the file mimeDecode.php to prevent adding of e-mail certificates (to verify that the mail is from me) as an attachment to a bug. This line needs to be added around line 292 in the function _decode in the above mentioned file.
<b>case 'application/x-pkcs7-signature': //E-Mail Certificate</b>

cas

cas

2007-08-30 05:58

reporter   ~0015554

Found another small issue. If an email is retrieved with an attachment but no body text, the bug/issue is created but the attachment is not added.
It looks like something fails within the parser.
Anyone an idea ?

Banek

Banek

2007-10-09 04:43

reporter   ~0015833

eagle00789,
can you share your knowledge how you make it work for 1.0.8?

Woefdram

Woefdram

2007-10-31 11:22

reporter   ~0016038

I've played with this for a while and would love to see this accepted into the Mantis sourcecode. Very useful patch, this...

tronics

tronics

2007-11-04 12:44

reporter   ~0016077

Please add this one to the project!
This is a great and very needed addition.

tronics

tronics

2007-11-04 12:54

reporter   ~0016079

Please add this one to the project!
This is a great and very needed addition.

indy

indy

2007-11-08 06:05

reporter   ~0016109

I've been abroad for a while, but now I'm back.
The weekend I'll build a new version of the patch for the current stable and development release of Mantis.

So long...

Gerrit

brody

brody

2007-11-08 10:33

reporter   ~0016115

Hi Gerrit,
you wrote : "...new version of the patch for the current stable and development release". Will this be two patches (stable, development) or is this one patch for the current rc2?

I ask, because I'm on the way to integrate this great patch into my prod version 1.0.7 (which also works for 1.0.8)

cz4hkr

cz4hkr

2007-11-09 13:14

reporter   ~0016128

Hi all,
Please how can I reopen closed or resolved bug through email??
I set g_reopen_bug_threshold , but this is only for web interface.

thanks in advance

cas

cas

2007-11-20 02:32

reporter   ~0016246

Last edited: 2007-11-20 02:33

Have a small update on the mail_api.php.
In case one runs 2 instances of Mantis both using this feature, you may end up having the issue that a mail is recognized to be a bugnote. But that the bug cannot be found due to the fact that it is part of another instance.
To avoid this issue the function "mail_is_a_bugnote" needed to be adjusted like :

--------------------

return true if there is a valid mantis bug referernce in subject

function mail_is_a_bugnote ( $p_mail_subject ) {
if (pregmatch("/[([A-Za-z0-9-. ]\s[0-9]{1,7})]/", $p_mail_subject)){
$t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] );
if ( bug_exists( $t_bug_id ) ) {
return true;
} else{
return false;
}
}else{
return false;
}
// return pregmatch("/[([A-Za-z0-9-. ]
\s[0-9]{1,7})]/", $p_mail_subject);
}
#----------------------
#----------------------

Perhaps this can be included in the next version.

Cas

nawak

nawak

2007-11-28 03:19

reporter   ~0016317

hi,
I have a problem when I forward mail, it doesn't seem to accept .eml files and, at this line (551) in file_api :
$t_file_size = filesize( $p_tmp_file );
the value of $t_file_size is 0 even if it's not the case ... so I got the following error : ERROR_FILE_NO_UPLOAD_FAILURE ...
Does someone know where does it come from please ?

Thanks in advance.

Loki

Loki

2007-12-09 13:55

reporter   ~0016417

jboulay in note(0014370) you have a bat file to run the mail call function. I have a test instance of Mantis on Windows XP and I changed the paths in the batch file to match my setup and it works. I've a production version on Windows 2000 server and I can't get the batch file to work. I'm stuck. Do you know what I need to change to have it work on Windows 2000 server?

Thank You

Woefdram

Woefdram

2008-01-02 08:01

reporter   ~0016526

Any news about this patch and its availability for 1.1.0?

libregeek

libregeek

2008-01-04 02:15

reporter   ~0016544

I tried to integrate this patch to mantis-1.1.0 and got the following error:
APPLICATION WARNING #100: Configuration option 'db_schema' not found.

APPLICATION ERROR #18

Page redirection error, ensure that there are no spaces outside the PHP block (<?php ?>) in configinc.php or custom*.php files.

Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.

I have checked the config files and the custom files and it doesn't have any spaces outside php block.

Any solution for the above problem?

libregeek

libregeek

2008-01-04 03:35

reporter   ~0016548

Last edited: 2008-01-04 03:37

I have managed to setup the plugin in mantis-1.1.0. The issues was with config_defaults_inc.php and I used the new config_defaults_inc.php and added the additional config parameters for mail_report.

However I am unable to create bug from email. I am using a secure POP3 server and have hacked core/mail_api.php to modify the POP3 port to 995.

Is there any way out to fix the issue with secure POP3 server?

scubie

scubie

2008-01-25 01:47

reporter   ~0016809

I have downloaded and installed 1.1.1, is this issue built in to this new version or do I still need to download and apply this patch?

brody

brody

2008-01-25 03:24

reporter   ~0016810

scubie,
as you could see above in field "target version" (maybe you have to switch to 'advanced view' of issue), currently this very important feature (my weighting!) will be part of V1.2.0

A longer time ago it was moved from 1.1.0 to 1.2.0, unfortunately.

scubie

scubie

2008-01-26 00:31

reporter   ~0016822

Thanks brody - still learning to use the system, important lesson learned!

strangeways

strangeways

2008-01-28 19:43

reporter   ~0016868

libregeek,

In addition to changing the port to 995, add ssl:// before the mail server. E.g., ssl://pop.gmail.com

Once I did that, I was able to connect to a secure POP3 server and retrieve the mails.

DaVinci,

This may also have been the cause of your "Generic login error" error message.

strangeways

strangeways

2008-01-30 21:36

reporter   ~0016894

Just a couple notes:

  1. The latest package of changed files (Mantis-1.1.0a3-changed_files_only-v3.zip) needs to include the updated core/category_api.php (otherwise Mail Account per Category won't work, because the SELECT statements won't retrieve the mail account fields). Also, as libregeek mentioned above, config_defaults_inc.php needs to be updated to include the new Mantis configuration options.

  2. I noticed that if the email is HTML, the attachment doesn't get added to the bug that is created. If the email is text, however, the attachment gets added. Any ideas on how to fix this?

Thanks for the work you've been putting into this, Indy. It's an important feature!

brody

brody

2008-01-31 04:18

reporter   ~0016895

Strangeways,
regarding question 2: seems to be a bug in the parser.php. I did a fix into my own installation (on windows) with following behaviour:
a) If mail(body) is text/html, either is used as body (and not as an attachment). The latter one has to go through the (optional) htmlparser for the text only.
b) a slighly different call to the html-parser (replaced) for windows installations
c) Other text attachments (real attachment) are added as attachments.

My working copy is on V1.0.7; if you or anyone else is interested, I'd post the fixed file to this thread

strangeways

strangeways

2008-02-03 18:19

reporter   ~0016930

Hi Brody,

Thanks for the information! I would be interested in seeing the changes you have made to parser.php.

My working copy is V1.1.0, but I'm trying to put together a package of changed files for V1.1.1. Perhaps I could incorporate the bug fix into that and then post the new package here.

brody

brody

2008-02-04 05:17

reporter   ~0016932

Strangeways,

I hope that its enough to only attach the mentioned file "parser.php". May changes are commented with (brody). If you have questions, contact me...

strangeways

strangeways

2008-02-04 20:59

reporter   ~0016949

Thanks Brody! This was very helpful. I ended up including both html parser commands and put an operating system check to run the correct version. I also ended up rewriting the setParts function and made sure to check for the disposition attribute on each part.

I've put together an UNOFFICIAL package for V1.1.1 and attached it to this issue. The changes are listed below:

  1. Patched Mantis files now include 1.1.1 changes.

  2. Includes updated category_api.php with the correct SQL queries.

  3. Added changes based on brody's Parser.php patch:
    a. Support for loading an HTML parser on Windows. OS is auto-detected (if not Windows, defaults to original piped command form).
    b. Rewrote setParts() function - function was only loading the first part (and any sub-parts of the first part). Now goes through all parts and sub-parts.

    • Checks for "disposition" attribute on each part. If set, the part is considered an attachment.
    • If the body is split across multiple sub-parts of a "multipart" part, will now concatenate them together before setting the body.
    • If an HTML part should be included as an attachment (like in the original version of the function), there are a few lines that can be uncommented. Warning: This change has not been tested yet, but it should work the same as before.
  4. In file_api.php, included EBY's changes mentioned in note #0012226:
    a. move_uploaded_file() changed to rename()
    b. FILE_MOVE_FAILED corrected to ERROR_FILE_MOVE_FAILED

  5. In mail_api.php:
    a. mail_add_file() now uses the mail_tmp_directory configuration option for writing the temporary file.
    b. mail_add_file() now doesn't try to unlink a temporary file if method is DISK. Since file_add() moves the temporary file to its final location for the DISK method, the original temporary file is not there afterwards. (Why does the file_add() function also try to move files for the FTP method?)

As stated above, this package is unofficial. It also needs testing. Indy, feel free to include any of these changes in an official packaging.

Something else I'd like to do at some point is add a checkbox next to the POP3 Host field to indicate a secure POP3 server. This would automatically add ssl:// to the beginning of the mail server string, and also change the port from 110 to 995.

strangeways

strangeways

2008-02-04 22:11

reporter   ~0016951

Just uploaded a new package: Mantis-1.1.1-changed_files_only-unofficial-v1.tgz

There was a bug in the setParts function that was causing the content to appear to be duplicated when there was no attachment. My apologies. I've fixed it to only concatenate the content when it is in sub-parts. The previous package can be deleted.

brody

brody

2008-02-06 10:53

reporter   ~0016968

Strangeways,
only one remark to last statement at 3.b "Rewrote setParts()...

Although I did not take a look into your changes, but your assumption isn't that correct, I think. I got all parts as attachment including that meant as body.

Using a debug session I first found out that setParts() got called recursivly to get sub parts and uses all parts in its last loop. Second the "disposition" test came to check between text body part(s) and text attachment. All attachments (with disposition set) should be handled as attachments (addParts)

Regarding the htmlparser - my version is a java class around jericho-html.jar, which also could be used under linux. Because the html parser could be configured inside the configuration (I'm right?) it would make more sense to support a "flying file" parameter, which tells, where the file should be included. Thus you'd get in either case as shell_exec ($html_parser) and inside configuration
a) for linux: <u>cat <b>${f}</b> | /usr/bin/w3m -T text/html -dump </u>
and e.g.
b) on windows: <u>htmlparser\parse.bat <b>${f}</b></u>

Woefdram

Woefdram

2008-02-11 05:53

reporter   ~0017004

Great, it works. Thanks!

I think I found something though. If I configure Mantis to pick up 5 messages at a time, it doen't seem to call the "QUIT" command. Without the "QUIT" command, our GroupWise server doesn't delete messages, although I see Mantis send the "DELE" command.

If I make $g_mail_fetch_max 1, everything works just fine and messages are picked up, processed and deleted from the mailserver.

brody

brody

2008-02-11 11:29

reporter   ~0017011

Just wanted to provide another patch here - but that failed without an error message.

This patch circumvents the problem (i have currently), if one can't delete mails on a pop3 account for some reasons. Thus you would set "g_mail_delete" to <b>OFF</b>. Side effect: On every call of the php script you duplicate your issues. I extended the mail_api.php to check, if an e-mail of an account (of a project) is newer than the last checked mail and only add newer mails. Last saving the datestamp of the last added mail, so only then again newer mails are filled in.

brody

brody

2008-02-11 11:31

reporter   ~0017012

Last edited: 2008-02-12 05:10

Second try - it did :-) see last attached file (<b>mail_api.php.patch-v2</b>)

dapozzom

dapozzom

2008-02-12 07:30

reporter   ~0017019

I cannot get the email attachment to be added to my issue and for the description always “No description found”
My config_inc settings are
$g_mail_use_reporter = ON;
$g_mail_reporter = "CAU";
$g_mail_auto_signup = OFF;
$g_mail_debug = OFF;
$g_mail_additional = OFF;
$g_mail_save_from = ON;
$g_mail_parse_mime = OFF;
$g_mail_parse_html = OFF;
$g_mail_bug_priority_defult= NORMAL;
$g_mail_bug_priority= NORMAL;
$g_mail_delete=ON;
$g_mail_html_parser = OFF; # '/usr/bin/w3m -t text/html -dump';
$g_mail_tmp_directory = OFF;
$g_mail_fetch_max = 1;
$g_mail_auth_method = 'USER';
$g_mail_use_bug_priority = ON;
$g_mail_default_bug_category = 'CAU - Centro Assistenza Utenti';
$g_mail_directory = './Mail_CAU';
$g_mail_from = './Mail_CAU';
$g_mail_tmp_directory = './Mail_CAU';

dapozzom

dapozzom

2008-02-13 04:52

reporter   ~0017037

I attached the debug file

brody

brody

2008-02-13 12:29

reporter   ~0017039

Thanks for the debugfile - this file is a Mime-Mail (in my opinion), thus you need to switch at least $g_mail_parse_mime to ON.

Besides that, there is a typo in your configuration I guess:
$g_mail_bug_priority_defult -> $g_mail_bug_priority_default

lleroy

lleroy

2008-02-14 09:18

reporter   ~0017043

hi, i added a few lines of code to set the category and severity from the email message when reporting a new bug.

--- mail_api.php-orig 2008-02-14 15:07:51.863103100 +0100
+++ mail_api.php 2008-02-14 15:01:43.522902800 +0100
@@ -426,13 +426,23 @@
$t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 );
$t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );

+

  • if (preg_match("/^\s@?[Cc]ategory\s[:=]\s(.)/", $p_mail['X-Mantis-Body'], $matches)) {
  • $t_bug_data->category = $matches[1];
  • } else {
    if ( isset( $p_account['category'] ) && $p_account['category']) {
    $t_bug_data->category = gpc_get_string( 'category', $p_account['category'] );
    } else {
    $t_bug_data->category = gpc_get_string( 'category', config_get( 'mail_default_bug_category' ) );
    }
  • }
  •         $t_bug_data->reproducibility            = 10;
  • if (preg_match("/^\s@?[Ss]everity\s[:=]\s(.)/", $p_mail['X-Mantis-Body'], $matches)) {
  • $t_bug_data->severity = $matches[1];
  • } else {
    $t_bug_data->severity = 50;
  • }
    $t_bug_data->priority = $p_mail['Priority'];
    $t_bug_data->summary = trim( $p_mail['Subject'] );
Woefdram

Woefdram

2008-02-14 10:02

reporter   ~0017044

I run it with $g_mail_fetch_max set to 1 and a cronjob that fetches mail every minute. Should work fine as long as there aren't any e-mail bursts.

Woefdram

Woefdram

2008-02-14 11:24

reporter   ~0017046

Hmm, found something else. This one is nasty...

If I report anything via e-mail, the URL Mantis puts in the confirmation e-mail is screwed up. My URL is rewritten to http://www.example.com./view.php?id=xxx (yup, mind the period before the slash).

I know the example.com domain is mentioned in the default config, but in my config it's gone. I searched through the program files, but couldn't find anything suspicious. Ok, I'm not a programmer...

If I do something with an issue in Mantis itself, everything's fine. But as soon as I interact with Mantis through e-mail, the URL gets whacked.

brody

brody

2008-02-15 06:47

reporter   ~0017050

One advice on the added POP3 ability, which works on my system. Therein the database is changed and a new user is added to the user base. The user per default has nomail@localhost as user, but of not acknowlegable default email settings, set additional a preference record with all e-mail traffic for that user is switched off. Furthermore it might be useful, to protect that user against deleting and changing

brody

brody

2008-02-15 08:59

reporter   ~0017053

@Woefdram,0004286:0017046: You right, this seems to be a bug, maybe a not initialized variable, my disturbed URL is more crashed compared to another manually added issue, which says (e.g.):
http://localhost:8899/view.php?id=180

by Mail Reporter, the URL is
http://www.example.com{absolute path of installation or runtime}/view.php?id=179

I guess, that has to do with the fact, that the Mail Reporter is run directly with php.exe, while the other is run through the webserver

Loki

Loki

2008-02-19 14:08

reporter   ~0017111

Using the Mantis-1.1.1-changed_files_only-unofficial-v1.tgz I'm having a problem with the description not being added. I have the mail patch running in mantis 1.0.6 and have the config file with Parse MIME = ON and the description is included. But on the 1.1.1 version with the Parse MIME = ON get the error no description found. I can look at the file from the debug and it has the description. I'm running on Windows 2000 Server.

Loki

Loki

2008-02-19 15:08

reporter   ~0017113

To fix the URL in the email just add the path to your Mantis installation in the config_inc.php file or added it in the Configuration section in Mantis.

Works for me :-)

brody

brody

2008-02-21 10:39

reporter   ~0017145

@Loki: What did you configure there - Would you tell us?

I instead changed config_defaults.inc, made some translations (i.e. de, en) to circumvent this problem with a correct message in the e-mail.

I'll attach adequate patches including those for the above mentioned languages

Loki

Loki

2008-02-21 13:44

reporter   ~0017147

Hi.

In the config_inc.php
$g_path = 'http://your_url/mantis/';

or in the configuration Mantis version 1.1.1
Username = All Users
Project Name = All Projects
Configuration Option = path
Type = string
Value = http://your_url/mantis/

Loki

Loki

2008-02-25 16:17

reporter   ~0017197

Using the Mantis-1.1.1-changed_files_only-unofficial-v1.tgz I'm having a problem with the description not being added.

The Description is included if the email format is Plain text. Parse MIME = ON
But if the email is in Rich text or HTML format I get this in the description field - "no description found"

I've turn on:
Parse HTML = ON but still have no description.

This setting I don't understand for WINDOWS 2000 Server. How would I set this the example is not for Windows

HTML Parser Command

# It should print the formatted text to STDOUT
# For example: &quot;/usr/bin/w3m -T text/html -dump&quot;
$g_mail_html_parser = ON;

Any help would be Great!

brody

brody

2008-02-26 04:33

reporter   ~0017202

@Loki: The by default mentioned HTTP-Parser is a plain linux tool and the execution command is also unix like. I needed to change several lines in the mantis software to integrate such an html-parser on windows. Please take a look at my note 0004286:0016968 and strangeways' notes below. The unofficial patch should prepare to use a html-parser also under windows, as strangeways wrote.

Woefdram

Woefdram

2008-02-27 10:29

reporter   ~0017207

@Loki: Thanks for the tip. I put my Mantis URL in $g_path and now the links Mantis generates are correct.

Loki

Loki

2008-02-27 18:38

reporter   ~0017210

@Woefdram: Welcome.

@brody: I read the notes and from what is said in them the 1.1.1 should only need these 2 config settings:
$g_mail_parse_html = ON;
$g_mail_html_parser = ON;

This is how they are set but I still get 'no description found' in the description in Mantis.

If this setting htmlparser\parse.bat ${f} needs to be added I'm not sure where it goes.

Thanks

brody

brody

2008-02-28 04:06

reporter   ~0017216

Loki,
these settings (as only change) are valid on linux (or other unixes/unices?), because they come with a lot of command line tools, windows does not have and deliver.
Thus, on windows you additionally need to select a tool. I integrated jericho-html (which is java based), and is a sourceforge-project to get same functionallity as on unix. Therfore I wrote a wrapper batch around it and replaced the unix-like commandline with htmlparser\parse.bat , while the parser is linked (as in unix) into my mantis installation

i><b>@strangeway</b: Because I think there are a lot of users, who are running mantis on windows, might it be interesting to generally and as an option to the plain linux variant integrate my solution into the next release bundle? I think, that Java will be available on most OSes including Linux and Windows.</i>

Loki

Loki

2008-02-29 12:00

reporter   ~0017222

@brody: Thanks for the clarification on why the html is not working. I have Mantis 1.0.6 using the mail import and it imports the description when the email is in HTML. So I'm confused as to why that works on the same server that I have the test version 1.1.1 on?

I'm going to hold off upgrading the production code from 1.0.6 to 1.1.x until I've tested a html parser (jericho-html).

brody

brody

2008-03-03 09:57

reporter   ~0017252

Last edited: 2008-03-12 09:32

Loki, that is indeed interesting - I'm using V1.0.7 with pop3-email extension on Windows, but not V1.1.1; maybe strangeways could help around V1.1.1 and its differing behaviour concerning the html parser on Windows. The original pop3-email extension is from V1.0.5, but there was no html-parser inside (except the configuration for unix OSes). What is your e-mail backend? Some of them deliver html emails in both html and text. The parser (of 1.1.1) has been changed by strangeways with parts of my code as written in that note below. I tested it thoroughly on my environment. If you would send me such an email, which works on V1.0.6 and not on V1.1.1, I could take a look on it.

I've again read your 0004286:0017210 and maybe found a hint to your problem. You wrote about two settings and what they are in your configuration, if I'm right. While the first one seems to be correct (its a switch), the second one is no switch, but the commandline to call and this one I've set to "htmlparser\parse.bat". Please take in mind that my setting assume a slightly other kind of calling mechanism as with unix, but strangeway should have adapted it in V1.1.1

brody

brody

2008-03-12 09:36

reporter   ~0017323

b>@Indy</b: Thanks again for providing the pop3 patch. A question: Do you have an idea, why umlauts are destroyed on reading (or saving the mail) as new issue or note?

e.g. "ü" get converted to ü

libregeek

libregeek

2008-03-14 04:05

reporter   ~0017342

I have successfully installed the email_reporting patch for mantis-1.1.1. The mails sent to a POP3 account is successfully registered in the mantis system. But the reporter doesn't get any confirmation mail or the bug_id.

How can I send back the issue_id to the sender, so that the user will get the issue_id and use it as a referencein future. Is there any patch available? If not can I work on this feature?

jojow

jojow

2008-03-14 06:35

reporter   ~0017345

hi all,

we are using at the moment mantis 1.0.8 with the mail report function on a Linux Server and it's running perfect.

In the future we want to use mantis 1.1.1 with the mail report function on a Windows 2003 Server. Now I'm testing it and I've got many Problems with the mail report function. I know that we must change something in the parser.php file and that we need a htmlparser for windows.
I found a htmlpaser on http://htmlparser.sourceforge.net/project-info.html. Has anybody experience with that tool? And it is able to use it for Mantis?

@brody: you wrote in note#16968
...
b) on windows: htmlparser\parse.bat
-> Where can I find this bat file? Can you upload it here?

alex_hoeck

alex_hoeck

2008-03-16 17:55

reporter   ~0017381

I had some problems with my provider (save mode is set, so HTML parser cannot be launched). So I changed the function setBody in Mail/Parser.php:


function setBody( $body ) {
    if ( 0 == strlen( $body ) || 0 != strlen( $this->_body ) ) {
        return;
    }
    if ( 'text' == $this->_ctype['primary'] &&
         'plain' == $this->_ctype['secondary'] ) {
        switch ( $this->_transferencoding ) {
            case 'base64':
            case '8bit':
            case 'quoted-printable':
                $this->_body = quoted_printable_decode( $body );
                break;
            default:
                $this->_body = $body;
                break;
        }
    } elseif ( $this->_parse_html &&
               'text' == $this->_ctype['primary'] &&
               'html' == $this->_ctype['secondary'] ) {
        $file = $this->_htmltmpdir . &quot;/&quot; . md5 ( $body );
        file_put_contents( $file, $body );
        if ( 'WIN' == substr( PHP_OS, 0, 3 ) ) {
            # Windows: parser command with parameter
            $this->_body = strip_tags($body); #shell_exec($this->_htmlparser . &quot; &quot; . $file);
        } else {
            # others: piped command
            $this->_body = shell_exec(&quot;cat &quot; . $file . &quot; | &quot; . $this->_htmlparser);
        }
        unlink($file);
    } elseif ( !$this->_parse_html &&
               'text' == $this->_ctype['primary'] &&
               'html' == $this->_ctype['secondary'] ) {
        $this->_body = strip_tags($body);
    }
}

The change causes an include of the mailbody in the incidents description field when parsing of HTML mails is rturned off ($g_mail_parse_html = OFF;). It uses striptags() to remove HTML tags from the body.

If you like, include it.

brody

brody

2008-03-17 06:58

reporter   ~0017385

@libregeek's 0004286:0017342: I guess that the Mail Reporter adds new issues to your issue list. If the user gets not registered automatically on sending a new issue (as in my case), he must register at the site and switch its settings to be notified on new issues, but that are all issues. If you register new users ($g_mail_user_reporter = OFF), it might be additional implementation effort to get the user notified about his own issue, because mantis' e-mail notification on new issues does by default only notify developers and above, if they want to be notified about it(personal settings). Additionally you can influence this maybe through settings in the configuration. Take a look at $g_notify_flags

brody

brody

2008-03-17 07:00

reporter   ~0017386

@jojow's 0004286:0017345: The parse.bat is only a wrapper around "my" htmlparser, the jericho-html parser, I use. If you need it, I'll could put it here, but I think your parser might be wrapped through another call as mine.

jojow

jojow

2008-03-17 11:39

reporter   ~0017388

I've tested the "strip_tags" - function. With only this function I get an error 401 and the INSERT into the database won't work.
Now I'm testing the php-functions "htmlentities" and "htmlspecialchars". Then the Insert works, but I'll get some signs that I don't want :-(
Like "'ü' instead of 'ü', ß' instead of 'ß' and '&nbsp;' or '&amp;'. Can that be a problem with UTF-8 Unicode (utf8) in MySQL (version 5.1.23)?

function setBody( $body ) {
    if ( 0 == strlen( $body ) || 0 != strlen( $this->_body ) ) {
        return;
    }
    if ( 'text' == $this->_ctype['primary'] &&
         'plain' == $this->_ctype['secondary'] ) {
        switch ( $this->_transferencoding ) {
            case 'base64':
            case '8bit':
            case 'quoted-printable':
            $this->_body = quoted_printable_decode( $body );
            break;
        default:
            $this->_body = $body;
            break;
        }
    } elseif ( $this->_parse_html &&
               'text' == $this->_ctype['primary'] &&
               'html' == $this->_ctype['secondary'] ) {
        $file = $this->_htmltmpdir . &quot;/&quot; . md5 ( $body );
        file_put_contents( $file, $body );
        if ( 'WIN' == substr( PHP_OS, 0, 3 ) ) {
            # Windows: parser command with parameter
# START 17.03.08 --------------------------------------------------------   
            # Infos from Mantisbt.org Bug 4286 Note 0017381
            #$this->_body = shell_exec($this->_htmlparser . &quot; &quot; . $file);
            $this->_body = strip_tags($body);

# @@@ TEST jojow   !!! ONLY T E S T !!!
            $hjw_body = $body;
            $hjw_body = strip_tags( $hjw_body );
            $hjw_body = htmlentities( $hjw_body );
            $hjw_body = htmlspecialchars( $hjw_body );
            $this->_body = $hjw_body;
# END 17.03.08 -------------------------------------------------------- 
        } else {
            # others: piped command
            $this->_body = shell_exec(&quot;cat &quot; . $file . &quot; | &quot; . $this->_htmlparser);
        }
        unlink($file);
    }
}

jojow

jojow

2008-03-17 11:46

reporter   ~0017390

that's funny:
I wrote: Like ' & uuml ' (without Space) instead of 'ü', ' & szlig' (without Space) instead of 'ß' and ' ' or '&'
And I see 'ü' instead of 'ü' etc.
But in my Installation is standing "Mit freundlichen Gr & uuml & szlig" (without Space after & ) instead of "Mit freundlichen Grüßen".
I hope now it is readable.

alex_hoeck

alex_hoeck

2008-03-17 14:02

reporter   ~0017393

Last edited: 2008-03-17 14:05

@jojow: I found a small PHP package which possibly fits the needs: http://php-html.sourceforge.net/html2text.php

But I did not try it.


By the way: I allways get a strange error message when adding comments with the "Add Note" Form on your installation:

Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 199508 bytes) in /home/mantisbt/public_html/bugs/core/database_api.php on line 171

Does not belong here but fyi...

libregeek

libregeek

2008-03-25 07:44

reporter   ~0017450

@brody: Thanks for your clarification.

In my case the implementation is like the following - I don't create a new user when somebody sent a bug(via email) to mantis. Instead, it uses a common account(like mailUser) for all users to report the bug to mantis. I am wondering how difficult it will be to add some email-ids to a issue so that they will be notified about the bug status and notes.

bernhard

bernhard

2008-04-04 06:16

reporter   ~0017550

@jojow:

I managed to get German umlauts working by changing Mail/Parser.php:

in setBody() I added a new line at the end:

<code>
function setBody( $body ) {
if ( 0 == strlen( $body ) || 0 != strlen( $this->_body ) ) {
return;
}
if ( 'text' == $this->_ctype['primary'] &&
'plain' == $this->_ctype['secondary'] ) {
switch ( $this->_transferencoding ) {
case 'base64':
case '8bit':
case 'quoted-printable':
$this->_body = quoted_printable_decode( $body );
break;
default:
$this->_body = $body;
break;
}
} elseif ( $this->_parse_html &&
'text' == $this->_ctype['primary'] &&
'html' == $this->_ctype['secondary'] ) {
$file = $this->_htmltmpdir . "/" . md5 ( $body );
file_put_contents( $file, $body );
if ( 'WIN' == substr( PHP_OS, 0, 3 ) ) {

Windows: parser command with parameter

                            $this->_body = shell_exec($this->_htmlparser . &quot; &quot; . $file);
                    } else {
                            # others: piped command
            $this->_body = shell_exec(&quot;cat &quot; . $file . &quot; | &quot; . $this->_htmlparser);
                    }
        unlink($file);
    }
    $this->_body = htmlentities($this->_body); // 
}

</code>

In setSubject I also added htmlentities():

<code>
function setSubject( $subject ) {
$this->_subject = htmlentities( quoted_printable_decode( $subject ) );
}
</code>

This works for me with plain text and html mails.

remko

remko

2008-05-08 08:28

reporter   ~0017796

Hi,

Here at the City of Amsterdam (www.amsterdam.nl) we've been using this GREAT addition to mantis for about 6 months now. We'd like to update to Mantis 1.2. But as you know this e-mail reporting function does not work in that version of Mantis. Are there any plans to for an update for this function to work with Mantis 1.2? Perhaps as a plugin even? Thanks for your reply!

rjosulli

rjosulli

2008-05-15 05:16

reporter   ~0017839

Last edited: 2008-05-15 05:20

Hi,

I'm working on integrating this into our system. I've hit a problem with net_pop3, which isn't quite decoding mime e-mails properly. Sometimes a mail sent with text and html bodies will contain both: this appears as the body repeated twice, with the first copy containing no newlines (I presume the whole thing is being sent to the html processor) - this is most noticeable from outlook and yahoo! mail though it does not happen every time.

Also, if you send a mail from gmail with an attachment, the body is sent as an inline text part, and is not picked up at all. My experience with this is that it can be reproduced every time, simply send a gmail with an attachment and "No Description found" is inserted.

Anybody else having these problems? I don't want to have to go in and change net_pop3, and since it's been nearly 3 years since the last release I don't hold out much hope for a bug-fix. I'm going to look at piping it out to a different program/script....

brody

brody

2008-05-27 08:05

reporter   ~0017926

@rjosulli: the decoding of mime mails is not done by net_pop3, but by the Mail-package, especially Mail_mimeDecode and Mail_Parser. I remember that I've to fix several issues there (we use MS Exchange/Outlook, too) to get it working.

But in the meantime its working in most of cases.

cas

cas

2008-06-02 05:15

reporter   ~0017986

Last edited: 2008-06-02 08:40

We also use this feature heavily and I am surprised it is not in the latest versio (1.2.0).
Here http://www.mantisbt.org/bugs/view.php?id=4286#c13314 it is stated that the original author had joined the team. Would have hoped Gerrit managed to convince the team to get in this release.
It wil just mean that we have to patch the latest version ourselves to get it working. With so many users of this feature, it will become available.
Without it no upgrade so I may have to this myself.

dapozzom

dapozzom

2008-06-05 06:05

reporter   ~0018014

Last edited: 2008-06-05 06:08

I'm using Mantis 1.1.1 on Linux with following settings and all tims that a new mail is sent a ticket is created with in the body the plain text and html text.
Is the HTML part skippable in the ticket creation
$g_mail_use_reporter = ON;
$g_mail_reporter = "MAIL";
$g_mail_auto_signup = OFF;
$g_mail_debug = OFF;
$g_mail_additional = ON;
$g_mail_save_from = ON;
$g_mail_parse_mime = ON;
$g_mail_parse_html = ON;
$g_mail_bug_priority_default= NORMAL;
$g_mail_bug_priority= NORMAL;
$g_mail_delete=ON;
$g_mail_html_parser = '/usr/bin/w3m -t text/html -dump';
$g_mail_tmp_directory = OFF;
$g_mail_fetch_max = 1;
$g_mail_auth_method = 'USER';
$g_mail_use_bug_priority = OFF;
$g_mail_default_bug_category = 'Assistenza';
$g_mail_directory = './Mail_Sisset';
#$g_mail_from = './Mail_LOMB_CALL';
$g_mail_tmp_directory = './tempmail';

brody

brody

2008-06-05 12:48

reporter   ~0018018

@dapozzom:
These settings influence the html treatment:

$g_mail_parse_html = ON;
$g_mail_html_parser = '/usr/bin/w3m -t text/html -dump';

IF you switch first setting of, html is not handled any more.

dapozzom

dapozzom

2008-06-06 03:07

reporter   ~0018024

My incoming mail is generated with HTML/Plain text setting on the client, so if I will put the $g_mail_parse_html =OFF the description will contain " No description found", setting to ON the description will contain the HTML body and the "translated" one. So the bug description contains twice the same information.

dean2008

dean2008

2008-06-09 19:08

reporter   ~0018041

I am confused with all this history. Can someone give me a basic outline of how to get this thing running on 1.0.8 and Windows 2003? What files should I download, will I need that html parser, etc?

Thanks!

cas

cas

2008-06-10 05:35

reporter   ~0018044

Last edited: 2008-06-10 05:37

I seem to have a problem with very long URLs which get truncated if received by mail.
here is the url:
http://xxxxxx/rnt/Material%20Master/Form/filling%20in%20progress(RnD%20n%20Pur%20n%20QC)/For%20Dataman%27s%20action%20(.Dataman%20via%20Alina)/MINI%20MM%20P18300-AE%20Soo%20040608.xls

And this is how it shows up after importing:
<http://xxxxxx/rnt/Material%20Master/Form/filling%20in%20progress(RnD%20 [^]
n%20Pur%20n%20QC)/For%20Dataman%27s%20action%20(.Dataman%20via%20Alina)/
MINI%20MM%20P18300-AE%20Soo%20040608.xls>

Any suggestions someone?

brody

brody

2008-06-10 08:37

reporter   ~0018046

Last edited: 2008-06-10 08:44

@dapozzom 0004286:0018024, you wrote: My incoming mail is generated with HTML/Plain text setting on the client, so if I will put the $g_mail_parse_html =OFF the description will contain " No description found", setting to ON the description will contain the HTML body and the "translated" one. So the bug description contains twice the same information.

If you have a clean "plain text" part in your mail, you should get it also, if you switch html parsing to OFF. If you get "no description found", did you maybe switch "mime parsing" to OFF. It seems to me that something with your mails is not ok for the parsing process either in mime, which normal correctly differ between text and html parts in general inside mime based mails. I've both "mime parsing" and "html parsing" on, which works

brody

brody

2008-06-10 08:49

reporter   ~0018047

@cas 0004286:0018044: Take a look into the datbase table to decide, if the line breaks (you see) come from the parsing process or from the bugtracker userinterface.

If in the database (bug text table) a URL in the description column is not broken by <cr> or <lf>, the gui breakes an disforms the URLs

cas

cas

2008-06-11 09:39

reporter   ~0018061

Brody,

all long entries direct through the gui are fine, only when parsed at mail receipt wh have this behaviour.
It very much looks like it divides it in chuks of 64 characters.
Have not been able to track this down.

cas

cas

2008-06-17 02:44

reporter   ~0018120

Found another little issue and prepared fix for it.
We have 2 instances of mantis running in our organization. In case a bug-id of one instance is sent to the other it might be recognized as to be treated as a bugnote rather than a new issue. In principle not a real big issue unless the correspong Bug not exists.
In order to overcome this problem look for this line:
if ( mail_is_a_bugnote( $p_mail['Subject'] ) ){
and replace with:
if ( mail_is_a_bugnote( $p_mail['Subject'] ) && bug_exist($t_bug_id) ){

cas

cas

2008-06-17 02:47

reporter   ~0018121

Last edited: 2008-07-15 01:48

Found another little issue and prepared fix for it.
We have 2 instances of mantis running in our organization. In case a bug-id of one instance is sent to the other it might be recognized as to be treated as a bugnote rather than a new issue. In principle not a real big issue unless the corresponding Bug not exists.
In order to overcome this problem look for this line:
if ( mail_is_a_bugnote( $p_mail['Subject'] ) ){
$t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] );
and replace with:
$t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] );
if ( mail_is_a_bugnote( $p_mail['Subject'] ) && bug_exist($t_bug_id) ){

SL-Gundam

SL-Gundam

2008-07-11 08:55

reporter   ~0018362

Uploaded a new package with changes files for version 1.1.2
Mantis-1.1.2-changed_files_only-unofficial.zip

Jun 2008

  • update to mantis 1.1.2
  • Changes applied based on cas's code' NOTE 0016246
  • Using html2text 1.2 created by Jose Solorzano of Starnetsys, LLC. for html email parsing
  • html parsing on by default now
  • All pear packages updated to latest available versions
  • Necessary query adjustments in category_api.php
  • Some small bug fixes and adjustments.

Hope this package is usefull for some of you

SL-Gundam

SL-Gundam

2008-07-14 07:31

reporter   ~0018499

Sorry for this but there was small typo which caused problems with processing attachments.

Here is the fixed package: Mantis-1.1.2-changed_files_only-unofficial_v2.zip

Jul 2008

  • Fixed FILE_MOVE_FAILED to ERROR_FILE_MOVE_FAILED
  • Fixed problem with attachments not being processed properly
SNAFU

SNAFU

2008-07-14 09:04

reporter   ~0018506

Last edited: 2008-07-14 09:23

Hi,
I installed the latest version (1.1.2) and found, that adding mails as notes doesn't work. The cause was the function mail_is_a_bugnote()
a/ $t_bug_id is not initialized in the if-condition
b/ the parameter for mail_get_bug_id_from_subject() was wrong

For me the following version works fine:

    # --------------------
    # return true if there is a valid mantis bug referernce in subject
    function mail_is_a_bugnote ( $p_mail_subject ) {
            if ( preg_match(&quot;/\[([A-Za-z0-9-_\. ]*\s[0-9]{1,7})\]/&quot;, $p_mail_subject) ) {
                    $t_bug_id = mail_get_bug_id_from_subject( $p_mail_subject );
                    if (bug_exists( $t_bug_id )) {
                            return true;
                    }
                    else {
                             return false;
                    }
            }
            else{
                    return false;
            }
    }

... and mails with attachments are not analyzed right: "No description found"
... and the sytem does not recognize, that the mail comes from an existing user ... ?!

grangeway

grangeway

2008-07-27 18:24

reporter   ~0018692

Hello,

Is:
Mantis-1.1.2-changed_files_only-unofficial_v2.zip [^] (130,518 bytes) 2008-07-14 07:29 [Delete]

The latest version of this?

Paul

Devslashnull

Devslashnull

2008-08-25 13:43

reporter   ~0019220

Hi,

Just wanted to make a suggestion for a future release. If possible can the passwords not be stored in plain text.

Thanks,

-Jack
/dev/null

Devslashnull

Devslashnull

2008-09-29 16:01

reporter   ~0019474

Is this still be developed or has this been abandoned? Its been awhile since I've seen any updates are there are a few features not working right. I'm having issues with replies to emails not being added as bug notes and the mail parser seems to fail on characters with accent marks on them.

Thanks,

-Jack
/dev/null

lecouds

lecouds

2008-10-03 10:51

reporter   ~0019490

Hi,

I have the same problem with french accents, is there a way to get around this issue ?

Thanks.

Laurent

mcraig88

mcraig88

2008-10-16 12:54

reporter   ~0019577

Hello, how does this work if you are using Active Directory? Our UserIDs are not email addresses, they are our network logins.

Can this check AD, and create an account using a network login, and fill in the email address as per AD?

Seems like everything I read above is related to an internet facing installation.

Thanks

TomR

TomR

2008-10-23 08:02

reporter   ~0019649

Last edited: 2008-12-03 11:44

Suggestion for future release:

Per project one specific reporter. Now you have to choose between one reporter ( 'Mail' ) or all kind of different reporters. Suppose you have within one organization, which reports by email, one contactperson. You want that to be the reporter. This give them feedback on the issue created ( Issue ID ). I do not want all different reporters in the system. ( Otherwise I would have make accounts for them. Later on you could also update the reporter field in the issue ).

TomR

TomR

2008-10-23 08:05

reporter   ~0019650

Last edited: 2008-10-25 05:46

I am having te same problem with recognizing emails as bugnotes ( already existing issues ). See 0004286:0018506.

However for me that is not the solution. How is this suppose to work. What do you put in the subject of the email, just the issue ID ( with or without the leading zero's ) or something else.
<b>
Found what the problem was.
</b>
Your subject must contain [ProjectName IssueID]. I use the leading zero's with issue ID just as they are in the normal emails.

TomR

TomR

2008-10-25 04:10

reporter   ~0019681

Last edited: 2008-10-25 05:43

I'm having problems with emails containing attachments. It will not attach them to a isuue, and log file shows:

SYSTEM WARNING: file_put_contents(/image001.jpg)
[[1]function.file-put-contents]: failed to open stream: Permission Denied

However normal uploads by Mantis are working correctly.

What could be the problem?
<b>
Found what the problem was.
</b>
In mail_api.php file upload in function mail_add_file
$t_file_name = ini_get( 'upload_tmp_dir' ) . '/' . $p_part['name'];

However in my php.ini upload_tmp_dir was not set so it tried to write into the rootdir '/', which was not allowed.

DaVinci

DaVinci

2008-10-28 10:51

reporter   ~0019715

i can not get it to work on 1.2.0a2
anyone have any suggestions

i couldnt even get it to work on 1.1.3 or 1.1.4

TomR

TomR

2008-10-30 18:37

reporter   ~0019734

Hello DaVinci. Did not test it on 1.2.0a2, but works on 1.1.4.

What is your problem exactly?

DaVinci

DaVinci

2008-11-05 03:23

reporter   ~0019777

TomR,
the problem is that in v.1.2.a2 i dont get the fields where i define the mailserver and mail address which Mantis should use to collect the e-mails from

In 1.1.4 and 1.1.3 the e-mails that Mantis collects are empty: no description, no attachemnts no nothing

DaVinci

DaVinci

2008-11-05 03:23

reporter   ~0019778

TomR,
the problem is that in v.1.2.a2 i dont get the fields where i define the mailserver and mail address which Mantis should use to collect the e-mails from

In 1.1.4 and 1.1.3 the e-mails that Mantis collects are empty: no description, no attachemnts no nothing

DaVinci

DaVinci

2008-11-05 03:31

reporter   ~0019779

i've a suggestion:

  • upload the latest zip file with all the changes and remove all others
  • change the code such that if the subject field is something like <b>Fw:[Diverse cases 2032903]: <case_name></b>, the bug_report_mail.php should jump
  • move the mails that have been collected to another folder so that if something goes worng, like empty desciption, we can retrive the bug again
  • im running bub_report_mail.php as cornjob and sometimes it doesnot delete mails and when this happens during the weekend it ceats over 1000 duplicate cases thats uses mantis numbers. Becasue of this issue our Mantis have used up over 3000 numbers
brody

brody

2008-11-10 11:31

reporter   ~0019831

@DaVinci:

Reg. your last mentioned problem of examining the same mail twice, I added a check, if the mail is to old and has been checked before...

Reg. empty mails, what product is the mailserver you use?! I guess, a M$ Exchange...

DaVinci

DaVinci

2008-11-14 03:12

reporter   ~0019886

@brody
its a webmail provided by www.web10.nu
you wrote that u <B>added a check that if mail is too ols and has been check before..</b>
but the mails on the account never get checked and the cornjob runs every 3 minutes

i've tried to access the mails from LotusNotes but it didnt work :(

brody

brody

2008-11-14 04:49

reporter   ~0019888

@DaVinci
Because this interface (POP3) is very important for my work, I developed several extensions in my own installation to get it working into my process .. one of that was to save the last checked mail datestamp to prevent same mails. Much time needed to get this working against MS Exchange Server, because this is not 100% compliant .. I guess with Lotus Notes you'll have similar problems, but who knows...its a job of debugging, trying out and....

DaVinci

DaVinci

2008-11-14 05:14

reporter   ~0019889

@brody
dude..u have to complete ur sentences :)

jreese

jreese

2008-11-14 13:44

reporter   ~0019897

This would make for a great plugin; I don't think it'll be making it's way into Mantis core anytime for 1.2.x, so removing the target.

DaVinci

DaVinci

2008-11-17 04:44

reporter   ~0019911

@all the people above
is there a possibility somehow to import the reporter's name from e-mail header into <b>Reported by</b> feild in Mantis?

when a reporter sends a mail his e-mail address is imported in header:

<b>Report from: John Doe <john.doe@domain.com></b>

John Doe is always a user in Mantis and i want his name to be imported into <b>Reported by</b> filed instead of <b>Reporter</b> [reporter@somedomain.com] which is the name of the e-mail address everyone sends e-mail to.

I hope you understands the question.

brody

brody

2008-11-17 09:54

reporter   ~0019913

@JReese: When will this come - as plugin? This important feature for a lot of users is displaced many many times...

@DaVinci: Think, that I understand you. The patches for the feature to process e-mails can put that name into the reporter's field. But therefore a reporter entry (a new user) must be generated every time. Therefor two switches exists: $g_mail_use_reporter and $g_mail_reporter. If first is set to "OFF" every issue is saved under its reporter. The "Reported from:" is controlled by $g_mail_save_from switch. Seems to be a misconfiguration in your case.

DaVinci

DaVinci

2008-11-18 08:19

reporter   ~0019931

@brody:
so i should set <b>$g_mail_use_reporter</b> OFF!
what should i do with <b>$g_mail_save_from</b>

brody

brody

2008-11-21 11:39

reporter   ~0019971

@DaVinci: Yes (for the first) - as documented in the settings file ... read:"

--- mail reporting settings -----

# This tells Mantis to report all the Mail with only one account
$g_mail_use_reporter    = ON;

# The account's name for mail reporting
# Also used for fallback if a user is not found in database
$g_mail_reporter    = 'Mail';

and the second part also documented in the config file:

Write sender of the message into the bug report [IF set to ON!]

$g_mail_save_from   = OFF;
brody

brody

2008-11-21 12:23

reporter   ~0019975

b>@indy</b: thanks again for providing the email-pop3 addon. I'm using the (self-extended) mantis-1.0.5.patch.gz addapted to V1.0.7 and have a problem with the original Parser.php, which mangles some mails by second time applying a decoding of "quoted printable". The first apply comes from the origin Mime_Decode class (if configured to decode mime mails directly) and the again decoding of the decoded text comes from the Parser.php class function setBody(), which decodes a plain text again and calls a html parser for html part of mails.

Any idea? Is correct to generally make setBody() to only set the body and do no further decoding?

DaVinci

DaVinci

2008-11-25 08:23

reporter   ~0020027

@brody
this patch is living its own life on my server
sometimes i get the norwegian special chatacters and sometimes i dont
sometimes i get my name in <b>Reporeted by</b> filed and sometims i dont

what am i doing wrong?

TomR

TomR

2008-12-02 06:06

reporter   ~0020180

It seems that attached *.txt files are not attached to the issue.

Can anybody explain me the reason for that?

DaVinci

DaVinci

2008-12-03 07:53

reporter   ~0020211

@brody
okey
so i've done a coiple of tests and managed to create the desired incident
it seems that when i run report_bug_mail.php as a scheduled job on W3K then the special characters and the name of the reporter are missing
when i run it manually in the browser then i get special characters and the reportes name
any suggestions how can i make it work with scheduled job?

DaVinci

DaVinci

2008-12-03 07:57

reporter   ~0020212

@brody
is there a way to get this solution working with LotusNotes?
it is very desirable since now the solution gets mail from a private web-server which could be down at times but our LotusNotes server is up all the time and is stable

i couldnt get it to work with LotusNotes

brody

brody

2008-12-04 08:45

reporter   ~0020228

Last edited: 2008-12-04 08:49

@DaVinci at 07:53: I guess you mean W2K (I don't know W3K) :-)
Well, running a php-page inside a webserver or with the standalone executable might lead to get a different configuration. In the first case, the webserver and the configuration of it is the base of the job. In the later case the executable runs in the context of another process, which might have lesser rights or other settings, than the webserver. Its very difficult to find out. I got some differences by directly debugging the script execution using the executable.

@DaVinci at 07:57: If LotusNotes is capable of being contacted by POP3 and you or your application gets the rights to do so. We use (sorrily) Exchange Server and I found a lot of problems, because Microsoft has its own standards regarding POP3 and IMAP. I've no experience regarding contacting Lotus Notes.

brody

brody

2008-12-04 08:47

reporter   ~0020229

Last edited: 2008-12-04 08:49

@TomR's note 0004286:0020180: It might be forbidden in this installation. Some of the admins should/could tell you, the reason. I'm only reporter here...

TomR

TomR

2008-12-04 11:08

reporter   ~0020234

@brody
It is in my own installation. Normal uploading through web interface goes fine (.txt files). However when using report by email, files with a .txt extension are not attached to issues. Other files are attached correctly.

rajendran

rajendran

2008-12-10 07:35

reporter   ~0020315

Hi

Really very nice, it is great work

Actually it's working fine for bug report email.I got following issues kindly help me very urgent.

1.when user reply via email, the whole content(exist notes also) stored in bug notes but i want only reply messags only stored on bug notes.

2.if user attach the file means the bug notes displayed "No description found" but file is not attached to bug notes.

brody

brody

2008-12-10 08:20

reporter   ~0020317

@TomR 0004286:0020234: I found same problem in context to Exchange Server, which sometimes handled *.txt attachements not as attachement or slightly different to normal attachment. If you use Exchange Server as your e-mail backend that might be the reason for that mishaviour. A general fix is difficult; I fixed Parser.php for that, after digging deep into Exchange's Mail Handling. In general I had to fix/correct a lot of things. BTW: THe mentioned patch seems to be in indys upload of package 1.1.1

@Rajendran 0004286:0020315:

  1. You need a complex function, which handles this. I built and extended one for my installation, which compares headers and given notes about the date added; therefor the add date of a note is patched to the date of the mail from where the note comes from - is very special.

  2. Not in my understanding

TomR

TomR

2008-12-10 08:31

reporter   ~0020318

@Brody, Thnx for your reply, however no Exchange whatsover. Just POP3 on Linux server. I used Mantis-1.1.2-changed files only-unofficial V2.zip and that seemd to work, except voor *.txt uploads.

brody

brody

2008-12-10 09:21

reporter   ~0020319

POP3 is a "client side" protocol. I connect to Exchange by POP3, but that does not matter the format of the messages. Maybe your mail server on linux does also have special behaviour. I do not know, I found some misbehaviour on Exchange and patched my installation adequately. If you need to get this fixed on your installation, you'll have to debug it. For that I use the eclipse PDT Plugin (org.eclipse.php) in combination with the free available zend debugger plugin and for the non mail functions a local installation on my laptop.

Good luck!

rajendran

rajendran

2008-12-10 09:26

reporter   ~0020320

Hi

thanks for your reply brody

2.when user reply via email with file attachment, the file is not displayed in notes section and also notes are displayed "No description found" instead of display original reply messages. if any extra configuration need currently i used following configuration in config_inc.php file

# --- email variables -------------
$g_administrator_email  = 'projects@rhytha.info';
$g_webmaster_email      = 'mk@rhytha.com';

# the &quot;From: &quot; field in emails
$g_from_email           = 'projects@rhytha.info';

# the return address for bounced mail
$g_return_path_email    = 'projects@rhytha.info';
$g_mail_reporter = &quot;Mail&quot;;
$g_mail_use_reporter = ON;

$g_mail_debug = ON;

# --- file upload settings --------
# This is the master setting to disable *all* file uploading functionality
#
# The default value is ON but you must make sure file uploading is enabled
#  in PHP as well.  You may need to add &quot;file_uploads = TRUE&quot; to your php.ini.
$g_allow_file_upload    = ON;

kindly help me very urgent can i change any configuration please advise me

I need how can i set "bug report email" functionality in our external projects.that is i using testing project in this project i need integrate the bug report email functionality kindly give yours valuable suggestion.

libregeek

libregeek

2008-12-11 02:38

reporter   ~0020329

In the mantisbt wiki it's mentioned that an email_reporting feature is being done(http://wiki.mantisbt.org/doku.php/mantisbt:features). Is this the patch that would be included or are the developers working on some other patch ?

brody

brody

2008-12-11 05:18

reporter   ~0020332

Rajendran, from your settings I think, there are some more settings regarding the mail reporting: Please check against my settings, which produces wanted output in general and overwrite the default:

# Write sender of the message into the bug report
$g_mail_save_from   = ON;

# Parse MIME mails (may require a lot of memory)
$g_mail_parse_mime  = ON;

# Parse HTML mails
$g_mail_parse_html  = ON;

Furthermore für the last setting you need a correctly configured HTML-Parser, here is my own:

HTML Parser Command

# It should print the formatted text to STDOUT
# For example: &quot;/usr/bin/w3m -T text/html -dump&quot;
# junction-linked into mantis main dir 
$g_mail_html_parser = 'htmlparser\parse.bat';

This setting should only demonstrate how to set, but you can't take over!

And a correctly set directory:

# directory for saving temporary mail content
$g_mail_tmp_directory   = 'c:/WINDOWS/Temp';

Both are preconfigured for an unix environment.

The file upload settings are IMO only for the web part of the application. Regarding that neither the file is attached, nor the note displays the reply mail, there are several reasons for that - I can't help more. I'd suggest the same, I told TomR with his problem of adding *.txt files

brody

brody

2008-12-11 05:21

reporter   ~0020333

libregreek, seems to be the available patches. I do not know any release version of mantis, who has this feature completely inside and as the history of this item shows, the integration is moved to later versions many times. I think its difficult for them.

Any comments from a mantis developer?

rajendran

rajendran

2008-12-11 05:27

reporter   ~0020334

Hi

I am using "Mantis-1.1.0a3-changed_files_only-v3.zip" files but without the file attachment messages are stored fine, but when upload the file attachment the messages are not displayed correctly(the messages are "No descrption found and also file is not stored in our server").

kindly help me i had sent my configuration settings above the notes

libregeek

libregeek

2008-12-12 02:04

reporter   ~0020349

@brody
I shall take this issue to the mantis developer list.

rajendran

rajendran

2008-12-12 02:36

reporter   ~0020350

Hi

when run "bug_report_mail.php" got the below issues

1.APPLICATION ERROR #11

A necessary field 'Category' was empty. Please recheck your inputs.

2.Notes does not added to bug

kindly help me pls.very urgent

3."X-Mantis-Body"]=> string(14740) "This message was created automatically by mail delivery software. A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed: nomail@montreal.servershost.net Unrouteable address ------

rajendran

rajendran

2008-12-12 04:42

reporter   ~0020356

Hi

when run "bug_report_mail.php" got the below issues

1.APPLICATION ERROR #11

A necessary field 'Category' was empty. Please recheck your inputs.

2.Notes does not added to bug

kindly help me pls.very urgent

3."X-Mantis-Body"]=> string(14740) "This message was created automatically by mail delivery software. A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed: nomail@montreal.servershost.net Unrouteable address ------

rajendran

rajendran

2008-12-12 06:53

reporter   ~0020358

I run this page "Run bug_report_mail.php" got the below error

error:project@rhytha.info [pear_error: message="-ERR Login failed." code=-1 mode=return level=notice prefix="" info=""]

how can i fix this

email reply messages(notes) added successfully but when attach the file with reply notes, attachment file are not stored in our server

kindly help me

DaVinci

DaVinci

2008-12-12 07:05

reporter   ~0020359

@brody
in mantis v.1.1.5 and mail-pluinn version 1.1.2 the mails come in the mail box hours after the case is posted eventhough mantis database is updated as soon as bug_report_mail.php is run

any suggestions?

rajendran

rajendran

2008-12-12 09:14

reporter   ~0020361

Hi

I need track the reply messages from existing mail for our project same for mantis concept.

is it possible? if possible give me any reference site or if u have any script sent me

pls help me

libregeek

libregeek

2008-12-12 09:15

reporter   ~0020362

@brody and other developers:
Please refer:
http://sourceforge.net/mailarchive/forum.php?thread_name=49426B21.2080501%40leetcode.net&amp;forum_name=mantisbt-dev

I think it's worth re-write this patch to suit the new plugin system in mantis-1.2.

Does this makes sense?

rajendran

rajendran

2008-12-16 04:56

reporter   ~0020378

@brody

when running "bug_report_mail.php" i got the following error

SYSTEM WARNING: fopen(Daily task report status.xls) [function.fopen]: failed to open stream: Permission denied

APPLICATION ERROR #15

File upload failed. File is not readable by Mantis. Please check the project settings

Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.

kindly help me

following is my config.inc.php

set these values to match your setup

$g_hostname      = &quot;localhost&quot;;
$g_db_username   = &quot;testun&quot;;
$g_db_password   = &quot;testpwd&quot;;
$g_database_name = &quot;testdb&quot;;
$g_db_type       = &quot;mysql&quot;;

# --- email variables -------------
$g_administrator_email  = 'test@test.com';
$g_webmaster_email      = 'test@test.com';

# the &quot;From: &quot; field in emails
$g_from_email           = 'test@test.com';

# the return address for bounced mail
$g_return_path_email    = 'test@test.com';
$g_mail_reporter = &quot;Mail&quot;;
$g_mail_use_reporter = ON;

$g_mail_debug = ON;
$g_mail_fetch_max = 1;
$g_mail_delete = ON;

# Write sender of the message into the bug report
$g_mail_save_from = ON;

# Parse MIME mails (may require a lot of memory)
$g_mail_parse_mime = ON;

# Parse HTML mails
$g_mail_parse_html = ON;

$g_mail_tmp_directory   = '/tmp';
DaVinci

DaVinci

2008-12-16 06:53

reporter   ~0020379

@rajindran
a couple of things:

  • you have to set up a postmaster account for this purpose..i didnt get it to work with anyother
  • then you have to create an account in Mantis lets say helpdesk and definethe postmaster-address for that account
  • then you have to create a category <b>Reported by mail</b> or something in Mantis
  • then you have to go into the account and set the action and activate it
  • use mail adress and mail server address while configuring [try with username if u dont get to work it with the mail address]

this is how i've set it up

[code]
######################

Mail Reporting

######################

# --- mail reporting settings -----
# This tells Mantis to report all the Mail with only one account
$g_mail_use_reporter    = OFF;

# The account's name for mail reporting
# Also used for fallback if a user is not found in database
    # helpdesk is the name of the account holder all the mails are send     from
$g_mail_reporter    = 'helpdesk'; 

# Signup new users automatically (possible security risk!)
# Default is OFF, ignored if mail_use_reporter is ON
$g_mail_auto_signup = OFF;

# How many mails should be fetched at the same time
# If big mails with attachments should be received, specify only one
$g_mail_fetch_max   = 1;

# Write complete mail into the &quot;Additional Information&quot;
# NOTE - doesn't function because the variable doesn't exist in the function where it is used. So just leave OFF
$g_mail_additional  = OFF;

# Write sender of the message into the bug report
$g_mail_save_from   = ON;

# Parse MIME mails (may require a lot of memory)
$g_mail_parse_mime  = ON;

# Parse HTML mails
$g_mail_parse_html  = ON;

# HTML Parser Command
# It should print the formatted text to STDOUT
# For example: &quot;/usr/bin/w3m -T text/html -dump&quot;
# NO LONGER NEEDED, thx to html2text
#$g_mail_html_parser    = OFF;
$g_mail_html_parser = '/usr/bin/w3m -t text/html -dump';

# directory for saving temporary mail content
$g_mail_tmp_directory   = '/tmp';

# Delete incoming mail from POP3 server
$g_mail_delete      = ON;

# Signup new users automatically (possible security risk!)
# Default is OFF, ignored if mail_use_reporter is ON
$g_mail_debug       = OFF;

# Save mail contents to this directory if debug mode is ON
$g_mail_directory   = '/tmp/mantis';

# The auth method used for POP3

Valid methods are: 'DIGEST-MD5','CRAM-MD5','LOGIN','PLAIN','APOP','USER'

#NOTE: Try to chnage between these methods..the most common is USER
$g_mail_auth_method = 'USER';

# Looks for priority header field
$g_mail_use_bug_priority = ON;

# Default priority for mail reported bugs
$g_mail_bug_priority_default = NORMAL;

# Default bug category for mail reported bugs (Defaults to &quot;default_bug_category&quot;)
# Because in Mantis 1.1.0a3 a category is required, we need a default category for issues reported by email.
# Make sure the category exists and it has been configured correctly
#$g_mail_default_bug_category = '%default_bug_category%';

#NOTE Reported by mail: is the name of the bug category in MANTIS [you have to create one] where all the mails that are reportet by mail come
$g_mail_default_bug_category = 'Reportet by mail';

# Classify bug priorities
$g_mail_bug_priority = array(
    '5 (lowest)'    => 10,
    '4 (low)'   => 20,
    '3 (normal)'    => 30,
    '2 (high)'  => 40,
    '1 (highest)'   => 50,
    '5'     => 20,
    '4'     => 20,
    '3'     => 30,
    '2'     => 40,
    '1'     => 50,
    '0'     => 10,
    'low'       => 20,
    'normal'    => 30,
    'high'      => 40,
    ''      => 30,
    '?'         => 30
    );

[/code]

01

01

2008-12-17 17:59

reporter   ~0020400

just a short question: does the status "assigned" mean that this killer feature will become part of the mantis distribution finally? :->>>

TomR

TomR

2008-12-18 03:12

reporter   ~0020411

Last edited: 2009-01-07 05:34

@rajendran
If you get file upload failed, permission denied. Check your upload_tmp_dir in php.ini.

See 0004286:0019681

jreese

jreese

2009-01-15 15:38

reporter   ~0020632

01: considering that it was assigned three years ago to a developer who no longer contributes to MantisBT, and that no other current developer has stepped up to the task, I'd say "no".

However, as I mentioned in a previous comment, the new plugin system in the 1.2.x versions add the possibility for someone to create this as an external feature for MantisBT that won't require editing core files. However, that still requires someone to volunteer the time and energy needed to get something like that working.

cas

cas

2009-01-20 05:49

reporter   ~0020658

In case nobody is working on this, I am willing to transform this into a plugin.
The reason being that it is a vital part of a lot of installations (including ours) and the believe that it actually should be part of the core.

cas

cas

2009-01-21 08:35

reporter   ~0020666

Have this plugin nearly ready and am looking for testers. The plugin has been created within the plugin system of the 1.2.x version, more specific on the very last release 1.2.0a3

TomR

TomR

2009-01-21 08:59

reporter   ~0020668

Cas,

I am willing to test the plugin, however I first have to setup a 1.2.0a3 version of mantis. I will do that this weekend. Please post when you are ready an upload plugin here.

cas

cas

2009-01-21 14:48

reporter   ~0020674

Have attached the email plugin called Recmail (Receive mail). Based upon Indy's work.
Be aware have tested this with 1.2.0a3 and sofar it works (perhaps it will work on 1.6.x but have not tried).
Have tested with and without attachment (file upload method=DISK).

libregeek

libregeek

2009-02-10 06:48

reporter   ~0020830

I tried to install the plugin in a GNU/Linux (Fedora) server and failed due to incompatibility in directory separator(used \ instead of /) in the require_once statements. These are mainly noticed in the pages/ folder. I have created a patch for the same. Please commit if it doesn't break anything else.

libregeek

libregeek

2009-02-11 04:30

reporter   ~0020833

@cas
I have tried the patch in CentOS server and it seems it has some issues in connecting to the POP3S server. I have a secure POP3 server running at port 995. I have changed the port number in api/mail_api.php , but it didn't helped. This server already have mantis-1.1.2 with the old patch and it works without any issues.

cas

cas

2009-02-17 06:27

reporter   ~0020870

I will incorporate the patch and see if I can do something on the POP3S issue.
Those parts of the code have hardly changed in my recollection but will verify.

midgardtech

midgardtech

2009-02-18 12:01

reporter   ~0020882

Last edited: 2009-02-18 12:07

Hi. I have been testing this plugin for use within my company.

Two things I noticed but could be doing something wrong:

1) Replies to tickets made via email create new tickets and are not added to bugnotes.
2) I sent in an email with a file attachment but the attachment never showed up on the ticket.

Thanks,

Tim

cas

cas

2009-02-18 14:44

reporter   ~0020883

Replies to tickets quite often conatin the full bug-report. This is a pain.
In order to avoid this, open mail_api.php and search for:
$t_mail['X-Mantis-Body'] = trim( $t_mp->body() );
if ( empty( $t_mail['X-Mantis-Body'] ) ) {
$t_mail['X-Mantis-Body'] = "No description found";
}

add after this section:
$lookfor = "-----Original Message-----";
$lookin = $t_mail['X-Mantis-Body'];
$sep = strpos($lookin, $lookfor);
if ($sep){
$t_mail['X-Mantis-Body']=substr($lookin,0,$sep);
}

This has been tested in version 1.1.X

cas

cas

2009-02-18 15:22

reporter   ~0020884

@ Tim,
what is your storage Disk or Database ?
Will check on the replies

midgardtech

midgardtech

2009-02-18 16:59

reporter   ~0020885

Good question. Where do I find that? Whatever the default is, I guess. I never made any changes to it that way.

cas

cas

2009-02-18 17:37

reporter   ~0020886

check this setting: $g_file_upload_method

midgardtech

midgardtech

2009-02-18 19:08

reporter   ~0020887

Okay. Looks like it is set to DATABASE. I guess I should try changing it to FILE and try again.

midgardtech

midgardtech

2009-02-18 21:11

reporter   ~0020888

Alright, I changed it to DISK and tried again with the same results.

midgardtech

midgardtech

2009-02-18 22:04

reporter   ~0020889

Okay, I have been doing a little more research. I have found, that if I send in a file attachment, nothing seems to get parsed. Nothing gets added to the ticket as a description, nor does the attachment get added to the ticket. Is it the parser? Where does the $g_mail_html_parser variable go? I added it to the config_inc.php file as I did not see it in any of the files included with the plugin.

I have tried sending it as both an html mail and a plain text mail and the results are the same. With an attachment, I get no description or attachment. Without the attachment, it works fine.

Let me know if there is any way I can help. Oh, the install is a virgin 1.2.0a3 install with just this plugin.

joshua_chan

joshua_chan

2009-02-18 22:16

reporter   ~0020890

I downloaded Recmail.zip, and applied recmail.patch to get it to work under linux. I had two issues:

  • replying to a Mantis email always created a new ticket, rather than adding a bugnote
  • file attachments did not work

Made a few minor changes to get it to work better for me. I have uploaded them as "recmail_reply_attach.patch". I hope it helps.

brody

brody

2009-02-19 04:34

reporter   ~0020891

@cas - reg. your note 0004286:0020883 - a good idea, but IMO from my experience incomplete, because checking this text is not always possible. In the tense of HTML-mails, this text is sometimes not used (and further more I'm german with same contacts). Resulting that I check following:

-----Original Message-----, -----Original Message-----, From: then the german complements: > -----Ursprüngliche Nachricht-----, -----Ursprüngliche Nachricht-----, Von: . If that does not fit, a language independent form: ____ (underscore of 32 chars)

In newer mails sometimes I saw, that these checks also fails.

cas

cas

2009-02-19 08:01

reporter   ~0020895

I will include Joshua's patch and make fresh version available.
As for note of Brody, in this plugin the search string can be defined.
If you have the bug-report mail to start with a special (set of) characters, you still can eliminate the rest of the mail

remko

remko

2009-02-20 03:29

reporter   ~0020905

@cas - reg. your note 0004286:0020883: What I did was check for the original "$g_from_name" and cut the message there. Not ideal, but better than checking for -----Original Message----- in my experience.

remko

remko

2009-02-20 03:41

reporter   ~0020906

I have a nasty problem with "Mail/mimeDecode.php".
In our system we use long urls with numbers in them. Like this one:
http://www.amsterdam.nl/?xdl=../views/amsterdamnl/xdl/Page&amp;VarIdt=1&amp;SitIdt=18&amp;ItmIdt=150783

If users have a bug on a page like that and mail it to Mantis the mimeDecode.php destroys this url. How? Well, via the function _quotedPrintableDecode, line 609:

$input = preg_replace('/=([a-f0-9]{2})/ie', "chr(hexdec('\1'))", $input);

Somehow it seems IF there's a number behind the "equals" sign (=) in de body of the mail, this gets translated into HEX. But we don't want that! I've tried to out comment this function but ran into the problem that the page does not finish anymore failing to delete the mails on the server. So that did not work. Anyone have a suggestion on how to fix this?

brody

brody

2009-02-20 04:46

reporter   ~0020907

@remko: I noticed this behaviour too - sometimes and on an elder installation of mantis. I tried to find out, where the problem is and I guess this happens on the fact, that the decoding is called twice from the mail processing.

Maybe that hint helps - I've currently no time to provide a fix for that, but someone else could maybe.

remko

remko

2009-02-20 06:50

reporter   ~0020908

@0020906 the following code seems to fix this problem (but only for http urls, so this code could be improved):

if (strpos($input, 'http://') === false){
$input = preg_replace('/=([a-f0-9]{2})/ie', "chr(hexdec('\1'))", $input);
}

cas

cas

2009-02-20 08:13

reporter   ~0020909

Last edited: 2009-02-20 08:41

Attached version 0.95, have taken into account mentioned issues.
Please remove old plugin before installing this one.

Please use recmail095a.zip, initial one contains a bug. Unfortunately I am not allowed to remove.

midgardtech

midgardtech

2009-02-20 21:35

reporter   ~0020914

Hi, the bugnotes issues works now. I still can't send attachments, however. I am using Ubuntu Linux. If there is anything else you need from me, let me know.

cas

cas

2009-02-21 11:39

reporter   ~0020917

Is there an error message?
Did you create the directory for "Directory for saving temporary mail content" as listed within the config?
Have tested this with DISK and DATABASE and all seems to work fine.
Only downside here is that my tesrsite is based on Windows

tanky

tanky

2009-02-26 04:48

reporter   ~0020947

Hello,

Thanks for this helpful plugin. I use MantisBT 1.2.0a3 and have one issue to make it working. I can't add a Mailbox through 'Maintain POP3 Settings' and get an error: "SYSTEM WARNING: mysql_fetch_row(): supplied argument is not a valid MySQL result resource". Do you have any idea about the solution? Thx

cas

cas

2009-02-26 22:13

reporter   ~0020957

has the table (mantis_plugin_recmail_pop3_table) been created ok?

if not, execute this sql on the DB:
CREATE TABLE IF NOT EXISTS mantis_plugin_recmail_pop3_table (
mailbox_id int(10) unsigned NOT NULL auto_increment,
mailbox_name varchar(50) default '',
project_id int(10) unsigned NOT NULL,
category_id int(10) unsigned NOT NULL,
pop3_host varchar(250) default '',
pop3_user varchar(250) default '',
pop3_pass varchar(250) default '',
PRIMARY KEY (mailbox_id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

tanky

tanky

2009-02-27 08:44

reporter   ~0020958

Thanks this table wasn't there. Also I modified my due_date column in Mantis_Bug_Table from datetime to VARCHAR as I had wrong value (-3599) in INSERT query.

cas

cas

2009-02-28 01:35

reporter   ~0020960

Not sure what that fiedl has to do with this plugin. Nevertheless I do not believe that you should change that. My register plugin certainly expects that field to be 'timedate' format. Suggest to open another issue for that problem.

remko

remko

2009-03-03 05:39

reporter   ~0020987

@cas: I will try your plugin on our test system. On our live system we're still using the "old" nonplugin version of this function. We found that we also have a "attachment issue" like midgardtech (@0020914). In Mail/mimeDecode.php we put in:

if (strpos($input, 'http://' [^]) === false){
$input = preg_replace('/=([a-f0-9]{2})/ie', "chr(hexdec('\1'))", $input);
}

that did fix the "broken url" problem, but gave us a new problem: mails with attachments do not get parsed properly any more (and won't be deleted from the server). I quess we have to fix this at the root of the problem. That could be as brody (@0020907) suggests that the parsing is called twice.

Do you know if your plugin fixes this broken-URL problem?

remko

remko

2009-03-04 08:50

reporter   ~0020995

@cas. We are having the same problem as you mentioned @18044 : long URLS get broken. We are only having this problem with incoming HTML-mail. Plain TEXT mails are fine. Did you ever fix this problem?

N.B. Not only the URLS are "cut" at a certain point, but also the rest of the text. So I would suspect a "truncate" of "wrap" variable somewhere, but I can't seem to find it. I quess the problem is somewhere in the /Mail/mimiPart.php. But where?

joshua_chan

joshua_chan

2009-03-08 03:19

reporter   ~0021013

Last edited: 2009-03-09 01:05

This plugin has been working well for us now on Linux using the DATABASE method. I made several more edits since the last time. The only major addition is the option to reject unknown incoming emails. (See "reject-mail.patch", applied to "Recmail095a.zip")

  • Changed the "Auto Signup" option into "How to handle unknown email addresses". It is possible now to reject incoming emails if they don't match a registered user.
  • Fixed double notification emails when a bugnote was added to existing issues.
  • Changed default email of 'Mail' user from "@recmail.com" to "@example.com"
  • Increased "POP3 host" textbox size from 30 to 50 characters.
  • Added "plugin_push_current( 'Recmail' );" to bug_report_mail.php so it can be included directly from another PHP script without passing through plugin.php.

I also renamed "Recmail_api.php" to "recmail_api.php" for Linux, though this change isn't in the patch.

[edit: We use DATABASE, not DISK. Sorry.]

cas

cas

2009-03-10 09:47

reporter   ~0021021

@Joshua
Will implement most of these into the next version, always could to add some more functions.

@remko,
have not been able to do anything about that one. First wouyld like to have this plugin more or less approved.

ecik

ecik

2009-03-18 05:00

reporter   ~0021073

We've got a problem with attachments which names contain a Umlaut. Those mails do not get parsed properly and therefore there won't be deleted from the Server.

Has anybody an idea how to fix that?

cas

cas

2009-03-18 09:24

reporter   ~0021094

Perhaps by adjusting the name of the attachment by using a function like:
function strip-Accents($string){
return strtr($string,'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ',
'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');

Now look at function 'function mail_add_file' inside Recmail_api.php.
Replace this line :
$t_file_name = plugin_config_get( 'mail_tmp_directory' ) . '/' . $p_part['name'];

with :

$t_file_name = strip-Accents(plugin_config_get( 'mail_tmp_directory' ) . '/' . $p_part['name']);

Do not forget to add this function (strip-Accents) to the same script.

ecik

ecik

2009-03-18 10:27

reporter   ~0021098

Thank you for your answer!
Unfortunately this didn't work. I'm getting an Application Error 0000401. I think the Problem is the Character Setting of a mail which contains Umlauts in the name of an attachment.
I tried to debug it and the result is:

["X-Mantis-Body"]=> string(34) "die ist mal wieder ein Umlauttest." ["X-Mantis-Parts"]=> array(1) { [0]=> array(3) { ["ctype"]=> string(10) "text/plain" ["name"]=> string(8) "t?st.txt" ["body"]=> string(31) "Dies ist ein test. bla bla " } } ["Priority"]=> int(30) ["X-Mantis-Complete"]=> NULL }

The mail I sent looked like this:

This is a multi-part message in MIME format.
--------------030803080500020503020303
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit

die ist mal wieder ein Umlauttest.

--------------030803080500020503020303
Content-Type: text/plain;
name="=?ISO-8859-15?Q?t=E4st=2Etxt?="
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename*=ISO-8859-15''%74%E4%73%74%2E%74%78%74

Dies ist ein test.
bla bla
--------------030803080500020503020303--

The Problem is that the filename comes as filename*=ISO-8859-15''%74%E4%73%74%2E%74%78%74
Filenames which doesnt contain Umlauts are normaly coded like this:
filename=myfilename
I think this little difference causes the problem. But I've got no Idea how and where to fix that.

midgardtech

midgardtech

2009-03-18 14:57

reporter   ~0021103

Hi ... Been a while since I posted my problem with attachments, but I am still getting it. Anytime I send an email with an attachment, Not only do I not get the attachment in the bug but I also do not get a description. Without the attachment it works just fine.

I ran the lynx method of forcing the pop3 check which works. But I do not see any errors. I tried running the command line php version and get this message:

Could not open input file: /var/www/plugin.php?page=Recmail/bug_report_mail.php

Is there anywhere I can look for errors? I did check apaches error.log but found nothing.

Thanks.

cas

cas

2009-03-26 05:45

reporter   ~0021198

Last edited: 2009-03-26 05:58

As for the umlauts, will try to do some additional testing, to see if it can be fixed.
As for not getting the attachments, I really have no clue. Sofar it seems to be working fine. I do not have an Ubuntu testbox (but perhaps finds time to build one in the future). The only way is to use a PHP debugging tool to see what happens, or you work you way through the script step by step using echo/die statements etcetera to find out what happens.

cas

cas

2009-03-26 05:54

reporter   ~0021199

Last edited: 2009-03-27 12:57

Question for the community, currently when receiving an email, the system will try to add it as a note to an existing issue. However this will only happen if the status of this issue is below the "bug_readonly_status_threshold".
If it is equal or higher, nothing happens (actually the mail gets lost).
What todo?
Should the condition be removed?
Should the issue be reopened ?
Should in those cases a new issue be created?

For now, the next version of the plugin will raise a new issue.

midgardtech

midgardtech

2009-03-30 18:15

reporter   ~0021302

Unfortunately, I don't know a think about php or programming. You say you are running the software on a windows box? Are you running wamp or xamp or anything like that? I will try to set this up on a windows box to see if things run differently.

Thanks.

cas

cas

2009-04-05 11:56

reporter   ~0021396

I am running Xampp and running IIS

ingvald

ingvald

2009-04-06 16:13

reporter   ~0021405

Last edited: 2009-04-06 16:16

fyi, in case it's not been addressed yet: fix on non-ascii characters.

i'm playing around with an older version (unofficial something, meant for 1.1.1 i think, and i have mantis 1.1.6).

to get nordic characters i had to add utf8_encode in mail_parse_content, to get a couple of lines as follows:
$t_mail['Subject'] = utf8_encode( $t_mp->subject() );
$t_mail['X-Mantis-Body'] = utf8_encode ( $t_mp->body() );

seems to work fine with norwegian characters.

DGtlRift

DGtlRift

2009-04-08 10:10

reporter   ~0021434

Is the http://git.mantisforge.org/w/email.git supposed to contain the code for this plugin? I ask, because the head is empty at all the referenced mirrors, but I can't say anything about the push url.

grangeway

grangeway

2009-04-08 12:32

reporter   ~0021446

It would be nice to get it on there - iirc, when i've looked at these patches before, they dont change the core api's so a plugin would be good. If there is a problem accessing the repository that was created, whoever created it - drop me an email and i'll see if we can get it working.

Paul

Nosos

Nosos

2009-04-09 04:06

reporter   ~0021450

Hello people,

we had the exact same problem as described by ecik.
E-mails with attachments that containted umlauts could not be processed.

I traced down the problem to the function file_is_name_unique in the core/file_api.php.

It is the sql-query:
$query = "SELECT COUNT(*) FROM $t_file_table WHERE filename='$c_name' and bug_id=$c_bug";
It can't cope with Umlauts.

A possible solution is to change the name of the file beforehand:
#Old Version:
#$c_name = db_prepare_string( $p_name );
#New Version:
$c_name = utf8_encode(db_prepare_string( $p_name ));

Our tests have shown, that this helps with german umlauts, but not nessecarily with every kind of special character (which are not found in the german language).

I'm wondering if this function is really needed. As far as I understand it, it's there to see if there is already an existing file with the same name attached to the issue. If yes, it will be renamed, using a additional number in front of the name (i.e. filename.txt => 1_filename.txt).
In our workflow we don't have a scenario where this would apply.

Anyway, hope I could help.

ecik

ecik

2009-04-14 08:29

reporter   ~0021516

Last edited: 2009-04-16 06:09

Hello,
the solution that Nosos posted worked for us.
@nosos: THANK YOU!!!

We are able to test it for other umlauts, too. Not only for german. I will post if any further problems with special characters appear.

Nosos

Nosos

2009-04-16 05:16

reporter   ~0021571

Last edited: 2009-04-16 05:37

Glad I could help.

Here an additional note: If this fix is not working for your special characters, be it norwegian or hindu for example, you could try just replacing those signs using str_replace() or one of the other functions that php offers.

As the very last solution you can disable this check completly. As I said before, we don't really have a scenario, where we would need this verification.
We only use e-mails to insert new issues, not to alter existing ones.

DaVinci

DaVinci

2009-04-29 05:47

reporter   ~0021721

Hi,
I get a question mark <b>( ? )</b> instead of norwegian charaters when i report a case via mail.
I have tried to change line 189 in file ...\mantis\Mail\mimePart.php

<b>isset($contentType['charset']) ? $contentType['charset'] : 'US-ASCII',</b>
to
<b>isset($contentType['charset']) ? $contentType['charset'] : 'UTF-8',</b>

and line 205 from:
<b>isset($contentDisp['charset']) ? $contentDisp['charset'] : 'US-ASII',</b>
to
<b>isset($contentDisp['charset']) ? $contentDisp['charset'] : 'UTF-8',</b>

and line 400-402:

<b>// } elseif ($charset && (strtolower($charset) != 'us-ascii')) {
} elseif ($charset && (strtolower($charset) != 'utf-8')) {
$shouldEncode = 1;
//} elseif ($language && ($language != 'en' && $language != 'en-us')) {
} elseif ($language && ($language != 'en' && $language != 'nb-no')) {
</b>

but i still get questionamrk instead of norwegian chracters.

Can nayone help me here please.

ecik

ecik

2009-04-29 09:09

reporter   ~0021727

Hi,
I think the lines which ingvald postet a few weeks before could help (Note number 0021405 ):

to get nordic characters i had to add utf8_encode in mail_parse_content, to get a couple of lines as follows:
$t_mail['Subject'] = utf8_encode( $t_mp->subject() );
$t_mail['X-Mantis-Body'] = utf8_encode ( $t_mp->body() );

DaVinci

DaVinci

2009-05-04 04:00

reporter   ~0021772

@ecik
that didnt help :(

jojow

jojow

2009-05-06 07:39

reporter   ~0021781

Last edited: 2009-05-06 07:52

@cas
I'm testing recmail095a with mantisbt 1.2.0a3
(Windows Server 2003, Apache Server 2.2, mysql 5.1.23, PHP 5.2.5)

when I start the automation "... php.exe plugin.php?page=Recmail/bug_report_mail.php ..." as found in the readme.txt i get following Error:
"The procedure entry point DrawRectangle could not be located in the dynamic link library CORE_RLmagick.dll."
I have "ImageMagick-6.5.2-1-Q16-windows-dll.exe" new installed, but it didn't help? Where is the mistake?

Devslashnull

Devslashnull

2009-06-08 17:40

reporter   ~0022061

@ecik
That worked for me. Thanks for the post.

@DaVinci
What collation are you using? Ours worked since we were using utf8_general_ci. I would confirm your DB is using a UTF-8 collation if not I would try confirming if that makes a difference or not.

-Jack
/dev/null

DaVinci

DaVinci

2009-06-23 03:12

reporter   ~0022232

hi,
i've created a gmail address: abc@gmail.com i want to use that to retrive all the mail from..but when i go to ../bug_report_mail.php i get the follwoing error:

error:abc [pear_error: message="Generic login error" code=1 mode=return level=notice prefix="" info=""]

the settings are.

POP address: pop.gmail.com
user: abc@gmail.com
password: abc_gmail_com

can anyone please help

Woefdram

Woefdram

2009-06-23 03:33

reporter   ~0022233

@DaVinci: you should fiddle a bit with the authentication method. I had the same problem with Exchange, turned out it worked just fine when I chose "user" there.

cas

cas

2009-06-23 03:35

reporter   ~0022234

please verify the mail authentication method

DaVinci

DaVinci

2009-06-23 16:36

reporter   ~0022250

@Woefdram and @cas

The auth method used for POP3

Valid methods are: 'DIGEST-MD5','CRAM-MD5','LOGIN','PLAIN','APOP','USER'

$g_mail_auth_method = 'USER';

i've fiddled with the authentication but it didnt help

Devslashnull

Devslashnull

2009-06-23 16:46

reporter   ~0022251

@DaVinci
I probably would not test with a Gmail account. Gmail uses port 995 for POP3 access,

http://mail.google.com/support/bin/answer.py?answer=86399

I would suggest changing the port from 110 which is the standard POP3 port to 995 if you really want to try it out with Gmail.

-Jack
/dev/null

DaVinci

DaVinci

2009-06-24 04:32

reporter   ~0022253

@Devslashnull a.k.a. Jack

I didnt understand that
first u say that u wouldnt try it with a gmail account since gmail uses port 995
then you provide a link that takes me to the thunderbird settings for gmail
and then u say that i've to change the port from 110 to 995
:S

Devslashnull

Devslashnull

2009-06-25 14:09

reporter   ~0022263

@DaVinci

Don't use Gmail to test unless you want to make changes to the code. I gave you the link for Thunderbird to show you that Gmail does use port 995 and not 110.

If you still want to use Gmail to test then you need to update the code to use port 995 instead of 110. If you are using other accounts that don't use port 995 then you will have to make a fair amount of changes to the code base in order to support POP3 accounts using port 110 and those using 995.

Hope that clears things up.

-Jack
/dev/null

Devslashnull

Devslashnull

2009-06-25 14:15

reporter   ~0022264

Last edited: 2009-06-25 14:25

@Brody c0020317

You mentioned that you had found a solution for your own implementation for processing text documents for an email and that you made several code changes to Parser.php.

Any chance you can provide us with the changes you made so I can configure it for the setup I am working with? Also it seemed like you indicated a change had been implemented but I am using the code from Mantis-1.1.2-changed_files_only-unofficial_v2.zip but am still encountering the problem.

Any insight would be appreciated.

-Jack
/dev/null

DaVinci

DaVinci

2009-06-26 02:14

reporter   ~0022266

@jack
what about LotusNotes and phpMail?

Devslashnull

Devslashnull

2009-06-26 09:19

reporter   ~0022268

@DaVinci

Not sure what you want to know about LotusNotes and phpMail. I've never user LotusNotes so I can't say anything about it.

-Jack
/dev/null

DaVinci

DaVinci

2009-06-26 09:28

reporter   ~0022269

@jack
do u know about anyother mail servers that i can use with mantis without doing any changes in code
and..
if i want to use gmail..where do i need to do changes?

cas

cas

2009-06-26 11:40

reporter   ~0022270

@davinci,
Will build this option in next version such that you can specify by entry.

desjardm

desjardm

2009-07-07 09:44

reporter   ~0022437

Hello all,

I got this error with this plugins
Fatal error: Call to undefined function bug_create() in /var/www/umantis.wul.qc.ec.gc.ca/mantisbt-1.2.0rc1/plugins/Recmail/Recmail_api.php on line 316

Did I miss something !!!!


Debian Etch
Deb package installed php-pear

Recmail_api.php need to be renamed to recmail_api.php (or only a symbolic link)
r vs R ... maybe just a typo cause rest of script call it with small r.

reject-mail.patch is not a patch ... =)
I made one with this original diff file (someone need it ?)

Here the result
[root@colline:plugins/Recmail]# patch -p1 < reject-mail-mod.patch
patching file Recmail.php
patching file Recmail_api.php
patching file lang/strings_english.txt
patching file pages/bug_report_mail.php
patching file pages/checkuser.php
patching file pages/config.php
patching file pages/config_edit.php
patching file pages/setpop.php

SL-Gundam

SL-Gundam

2009-07-27 14:33

reporter   ~0022569

Last edited: 2009-07-27 19:17

Hi everyone

I saw that cas already created a plugin for MantisBT-1.2.0

But it didn't work that well for me, mainly because he was directly referencing mysql_query functions and i was using mysqli.

But i also made some small modifications to this script which i never uploaded here as can be seen from the changelog.

In the end i created my own version of the plugin and incorporated as much as possible from cas's ideas. I hope he doesn't mind.

I hope it works well for everyone.

Here is my changelog
Jul 2009

  • Modified script to the new plugin architecture of mantis 1.2.0rc1
  • This script no longer needs new fields created in the database. This allows installation on mantis configurations where the database user only has select, insert, update and delete rights
  • custom_file_api.php has been updated to reflect the changes in its original Mantis counterpart
  • Cleaned up functions and files that were no longer usefull and / or necessary
  • Script did not use the default severity and default reproducibility for new bugs, it does now
  • New setting called secured_script to protect it from running on a webserver. Uses the same method as the send_emails.php job
  • File types that are not allowed will now be properly skipped during processing of attachments in emails so that it doesn't cause further errors down the line
  • mail_additional config setting is now called mail_add_complete_email and saves the complete email as an attachment .txt document instead of in the "Additional information" field
  • replaced html2text 1.2 (phphtmlparser) with simplehtmldom 1.11 from http://sourceforge.net/projects/simplehtmldom/
  • Names of attachments will now also be processed by mbstring to convert the character encoding. The content of the attachment does not need to be processed since its stored as binary
  • Parser will try the content-disposition field and the content-type field for a name if the name seems to be missing. As a fallback a alternative name will be provided incase of attachments of type email
  • Added support to use a different port for the pop3 server.
  • A lot of rewrites for the processing in parser.php and mail_api.php. It should now process all attachments properly
  • Reversible encryption will now be applied to the mailbox password
  • Updated the user information inside bug_report_mail.sql. This file is useless now though since the adding of the user is handled by the plugin
  • php.ini var upload-tmp-dir no longer used, the script will use the config mail_tmp_directory for temporarily saving attachments
  • html parsing no longer requires the file to be physically saved. mail_tmp_directory no longer needed here
  • The Mail Reporter user will now be filtered out of the email system as long as he has "nomail" as a email address
  • Identifying bugnotes works again
  • New function which removes automatic mantis emails from bugnotes
    Dec 2008
  • Scipt made compatible with Mantis 1.1.6
    Sep 2008
  • Check whether php.ini var upload-tmp-dir is empty to avoid attachment problems
    Aug 2008
  • Applied a character encoding conversion on incoming emails.
  • New setting in config_defaults_inc.php called $g_mail_encoding (values can contain supported values for this function: http://www.php.net/mb_convert_encoding)
cas

cas

2009-07-28 06:50

reporter   ~0022573

Thanks SL-Gundam, good to see the plugin has reach an even higher level. Will be testing this shortly.

desjardm

desjardm

2009-07-29 08:27

reporter   ~0022599

Just tested with success.
Thank for this upgrade.

Is there a way to control the reply message?
We use french tag here.

Thanks again.

SL-Gundam

SL-Gundam

2009-07-29 14:32

reporter   ~0022601

Last edited: 2009-07-29 14:43

What do you mean control the reply message?

I know there is currently a bug where mantis 1.2.0rc1 sends emails to users in only its Global language (normally english) and not that of the users its sending to.

Maybe thats what you mean?

Btw i'm currently updating this script again with a feature that was requested on this page but i apparently missed. When a new user needs to be registered automatically it will try to use the senders name as the username. If this fails it will use the email address as a username

Look forward to it

SL-Gundam

SL-Gundam

2009-07-30 18:21

reporter   ~0022621

Last edited: 2009-07-30 18:24

As mentioned earlier here is the small update

Aug 2009

  • The script now also recognizes a possible name in the from part of emails. It uses this as the username during the creation of the user
  • Cleaned up some more useless files that were not used
  • User creation during the installation of the plugin is now handled by mantis api's, schema functions no longer needed.

I think this will be the stable release for a while unless i think of something new to change... but i'm out of ideas and can't find anymore in this issues bugnotes.

remko

remko

2009-08-04 07:29

reporter   ~0022655

@SL_Gundam: first of all: thanks 4 this plugin!
I've got a problem with the password setting though. The "Mailbox password" setting is encrypted I think, but on my server it does not get decrypted when checking the mail. Is there another setting I missed to do that?

SL-Gundam

SL-Gundam

2009-08-04 11:12

reporter   ~0022657

Last edited: 2009-08-04 11:18

I checked but it properly decrypts it right before it wil try to connect to the pop3 server

But i did find a bug in MantisBT-1.2.0rc1_plugin_EmailReporting-0.6.rar (0.5 didn't have this problem) where if you edited a mailbox, that it would not decrypt before editing. Upon saving it would encrypt it on top of the already encrypted password

Fixing this now. Should be a new version in about 30 mins

SL-Gundam

SL-Gundam

2009-08-04 12:07

reporter   ~0022659

Here is the changelog for (MantisBT-1.2.0rc1_plugin_EmailReporting-0.6.1.rar)

Aug 2009 v2

  • bug_report_mail.sql has been removed to avoid confusions about needing to use it
  • Decrypting the mailbox password did not occur before editing. Fixed (Note 0004286:0022655)
  • A new variable is added which resets the plugin schema and fixes the Mail Reporter user when it has the email address "nomail" (Automatically done during the first initialization of the plugin)
  • Removed functions which performed the exclusion of emails to Mail Reporter with "nomail" mail address
martinfdan

martinfdan

2009-08-05 03:53

reporter   ~0022661

I created a custom field called "user_email", and I needed that email will be sent to this email and not the user's mail.

how can I do?

thanks!

SL-Gundam

SL-Gundam

2009-08-05 11:49

reporter   ~0022664

i'm not really following you. Could you explain it a little bit more?

martinfdan

martinfdan

2009-08-05 12:16

reporter   ~0022665

do you speak spanish??

I created a custom field called "email user"

diferents users reported incidents in mantis with the same user account. The notifications to get to at email of the prefences of user, but I want to get to custom "email user"

How can I change it?

sorry for my english! :-(

SL-Gundam

SL-Gundam

2009-08-05 13:09

reporter   ~0022668

No, I speak dutch.

Alright i'm gonna try to decribe what you're saying. Correct me if i'm wrong.

You created a custom field in mantis called "email user" and connected that field to the required projects.
Multiple users reported incidents to mantis which ended in one mantis account (the reporting user account). Now automated notifications are sent to the reporting user account when certain things happen to the issue.

You want those automated notifications sent to the email address in the custom field "email user"?

If that is the problem then i have bad news. Mantis api's are set up to email to users and the email address in the user profile for those users. It is not possible to sent emails to specific email addresses outside of the user accounts.

If necessary you could fix this by creating a plugin yourself or find someone to do it for you.

But would it not be easier to correct the reporter for the issues? EmailReporting can do this automatically, see the second, third and fourth option in the EmailReporting configuration page.

martinfdan

martinfdan

2009-08-06 11:10

reporter   ~0022673

what and where is the EmailReporting??

can you help me?

thanks!

SL-Gundam

SL-Gundam

2009-08-06 11:30

reporter   ~0022675

See the attachments to this issue for file "MantisBT-1.2.0rc1_plugin_EmailReporting-0.6.1.rar"

martinfdan

martinfdan

2009-08-06 11:44

reporter   ~0022676

I download it but I dont know install it!

can you help me? thanks

SL-Gundam

SL-Gundam

2009-08-06 13:49

reporter   ~0022677

  1. install MantisBT 1.2.0rc1.
  2. extract "MantisBT-1.2.0rc1_plugin_EmailReporting-0.6.1.rar" inside the /[where you installed mantis]/plugins/ directory
  3. Log in as admin in mantis and go to "Manage plugins".
  4. You should see EmailReporting 0.6.1 somewhere on that page.
  5. Click install on the line where EmailReporting 0.6.1 is
  6. Configure EmailReporting and create the necessary mailboxes.
  7. Schedule a job to run every couple mintes to retrieve mails from the mailboxes.

Read the readme in EmailReporting/doc/ directory inside the package for more information, though based on your reaction i'm not really sure this will fix your problem. Also i think you are better off asking this question in the support section "Forums" of MantisBT (http://www.mantisbt.org/forums)

stephenm

stephenm

2009-08-31 22:46

reporter   ~0022839

mail_api.php: function mail_parse_address

I had issues with emails from LoutsNotes where the passed in p_mailaddress was just the email address. preg did not match and the function returned blank which then raised errors and blocked further processing.

Simple fix of adding an 'else' resolved it for us:
else $v_mailaddress = $p_mailaddress;

NB This is in the version for Mantis 1.1.2, I see the version for Mantis 1.2 now returns an array, presumably the additional line would now be:
else $v_mailaddress = array('email' => $p_mailaddress);

This may be of use to some of you if experiencing similar issues.

SL-Gundam

SL-Gundam

2009-09-01 13:07

reporter   ~0022846

Last edited: 2009-09-01 21:04

@stephenm.

There should be "<>" around the email address even if the name is not present... is this not the case with lotusnotes? weird... i thought that was part of the standard

Anyways i applied the change mentioned by you in version 0.6.2 of the EmailReporting plugin(not yet released).

kasshapa

kasshapa

2009-09-15 20:54

reporter   ~0022935

Hi
Need a help

I try to download MantisBT-1.2.0rc1_plugin_EmailReporting-0.6.1.rar
But it downloads only the php file.
i think web server not allowing to download rar.

Thanks

kasshapa

kasshapa

2009-09-15 20:55

reporter   ~0022936

Hi
Need a help

I try to download MantisBT-1.2.0rc1_plugin_EmailReporting-0.6.1.rar
But it downloads only the php file.
i think web server not allowing to download rar.

Thanks

SL-Gundam

SL-Gundam

2009-09-16 14:25

reporter   ~0022943

Last edited: 2009-09-16 14:27

No the package is complete, its just that mantis currently has a bug it seems with getting the name of the file correctly to the client.

Just save the downloaded php file with the proper name and extension (.rar) and you should be able to open the package properly

SL-Gundam

kasshapa

kasshapa

2009-09-17 01:00

reporter   ~0022947

Hi thanks SL-Gundam

but I extract to ./plugins/ directory i cant see any thing related to EmailReporting in side plugin manager?

can you help me please

-kasshapa

SL-Gundam

SL-Gundam

2009-09-17 11:58

reporter   ~0022961

The files need to be placed in [your mantis folder]\plugins\

You should extract without using the file name as a path but with the directory structure inside the archive. The end result should be: [your mantis folder]\plugins\EmailReporting\

In the folder should be one php file and 5 folders.

If thats all correct you should see a box with "Installed plugins" and "Available plugins" or at least one of them in the "Manage plugins" page. Click install for the plugin "Email reporting 0.6.1"

That should get you on your way

kasshapa

kasshapa

2009-09-17 22:42

reporter   ~0022962

Hi SL-Gundam

it wont work my site on that way :(
can i have .mantis.pkg of EmailReorting?
i try some
.mantis.pkg pakeges and those are installed.

thanks

SL-Gundam

SL-Gundam

2009-09-18 10:39

reporter   ~0022967

Well found your problem (i think).

This plugin manager is for old mantis versions.

You need to install mantis 1.2.0rc1 with its builtin plugin system.

The latest emailreporting package requires mantisbt 1.2.0rc1 or it will not work

SL-Gundam

kasshapa

kasshapa

2009-09-20 21:52

reporter   ~0022992

Hi SL-Gundam

thanks for you reply.
yes i was used the old Version. now i have 1.2.0rc1 and i manage to install Email Reporting.
after done that i try to run the bug_report_mail.php in CMD
but it give error
"Database connection failed. Error received from database was #0: PHP Support for databaseis not enabled."

any idea for this?

-Kasshapa

SL-Gundam

SL-Gundam

2009-09-21 10:53

reporter   ~0022997

Yeah it means that the php module is not working properly from the command line.

This might be because it can not find the folders with extensions or that it can't find the php.ini file.

At least its not a problem with the EmailReporting plugin.

try "php.exe -i" or "php.exe --ini" (both without quotes ofcourse) to debug your problem

kasshapa

kasshapa

2009-09-22 03:24

reporter   ~0023004

Hi SL Gundam

I put OFF to script from running via a webserver and try to run the Script via web browser. then it say it can find the PEAR.php inside the \plugins\EmailReporting\core folder and i copied the PEAR.php from \plugins\EmailReporting\core\Mail after that it was asking about PEAR5.php but i cant fine the PEAR5.php in side this code but i got the PEAR5.php from the php.net and copied to \plugins\EmailReporting\core . then it say

error:Tracker [pear_error: message="-ERR Command is not valid in this state." code=-1 mode=return level=notice prefix="" info=""]

Am i in wrong way?
help me plz

Kassapa

kasshapa

kasshapa

2009-09-22 03:28

reporter   ~0023007

Hi SL Gundam

php.exe --ini

Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File: C:\php\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)

and php.exe -i display full information in CMD

SL-Gundam

SL-Gundam

2009-09-22 11:13

reporter   ~0023016

I've reproduced the problem with the missing pear.php.

Its actually not missing, just in thw wrong folder.

I'm going to fix this and will release a new version when its ready

SL-Gundam

SL-Gundam

SL-Gundam

2009-09-22 12:47

reporter   ~0023017

Well here is the new version: MantisBT-1.2.0rc1_plugin_EmailReporting-0.6.2.rar

It only contains some minor fixes and improvements but it fixes some hickups some of you might have encountered

Changelog:
Sep 2009

  • Incase the email address is not encapsulated with the proper chars EmailReporting will consider the whole string the email address (Note 0004286:0022839)
  • Problems with locating pear.php have been corrected and pear5.php is now also present in the package
  • Added a limit on the maximum allowed file size so that the emails containing those attachments don't block further processing (uses the max_file_size setting of mantis)

Oh and cas i have not heard anything from you about my version of the EmailReporting plugin after you commented that you would try it. I'm wondering if you have any ideas for improving the plugin even more.

SL-Gundam

cas

cas

2009-09-22 13:41

reporter   ~0023018

Last edited: 2009-09-22 14:33

My tests went ok, all I did afterwards was watching progress here. I can only say that you have done a great job. For now I have no more requirements/ideas for improving.

kasshapa

kasshapa

2009-09-25 00:47

reporter   ~0023028

Hi SL Gundam

thanks for the new vertion
after i install the new vertion it say

error:Tracker [pear_error: message="-ERR Command is not valid in this state." code=-1 mode=return level=notice prefix="" info=""] error:Tracker [pear_error: message="-ERR Command is not valid in this state." code=-1 mode=return level=notice prefix="" info=""]

is there are any configration i must do?
this is runing in windows XP ,IIS,MySql

thanks
Kasshapa

SL-Gundam

SL-Gundam

2009-09-25 11:39

reporter   ~0023029

Last edited: 2009-09-25 11:46

Thats an error with the mailbox you added.

See the following link for possible solutions: http://www.google.nl/search?sourceid=navclient&amp;ie=UTF-8&amp;rlz=1T4GGLJ_enNL270NL270&amp;q=%22Command+is+not+valid+in+this+state%22

But you could also try adjusting "The authentication method used for the mailbox". You can find it in the configuration page of the EmailReporting plugin

kasshapa

kasshapa

2009-09-27 21:50

reporter   ~0023038

Thanks SL Gundam

Now it’s working. Thanks for the all help given

Regards
Kasshapa

tanky

tanky

2009-10-14 07:47

reporter   ~0023180

Hi,

Thanks for this new version too. It's very helpful!

However, I still have a problem with Frenc characters with accents (as à,é,è,...) which are removed in the bugnote (i.e.: problème->problme).

I tried several solutions explained previously but I'm still stuck.

Any help would be welcome, regards,

Tanky

SL-Gundam

SL-Gundam

2009-10-14 09:47

reporter   ~0023187

Yes they are removed because of the conversion of the charsets.

EmailReporting converts all charsets to utf8

Some characters will be removed because it can not convert them properly. Its better then the alternative where originally it would cut of any further text when such a character was encountered

If you find a good solution to this problem where it will convert those characters properly aswell, let me know.

For the moment i think selecting the proper charset in EmailReporting config is the best way.

For example: If the tables and fields in the mantis database use a utf8 charset then also select utf8 in the emailreporting config page. If the tables use a latin1 charset you should probably apply the iso-8859-1 charset in the emailreporting config page

Hope this helps

SL-Gundam

tanky

tanky

2009-10-15 10:08

reporter   ~0023205

Hello,

MySQL tables use latin1_swedish_ci charset and I already choose iso-8859-1 charset in the EmailReporting config page without any success.

Thanks for your answer anyway. I just have to wait until someone provide us a solution.

Tanky

SL-Gundam

SL-Gundam

2009-10-15 18:00

reporter   ~0023210

Last edited: 2009-10-15 18:07

I've got some good news and some bad news

The good news is i think i fixed the charset problems.

The bad news is that my experience with charsets is limited. So i might have created new bugs

I tried testing the changes as well as i could and it seems to work without problems but please let me know whether this fixes possible problems you encountered with the charsets

Also 1.2.0rc2 is out but i have not tested this plugin in that version yet (as you can see from its filename). I'll do that in due time but i think the plugin should work properly since i have not seen any changes in the plugin system or in the core functions of mantis used by this plugin which could cause problems. But i might be wrong though

Here is the new version: MantisBT-1.2.0rc1_plugin_EmailReporting-0.6.3.rar

Changelog:
Okt 2009

  • mb_convert_encoding converted strings even if they were using the same charsets. This caused the necessary problems since somehow certain chars seemed to be replaced with empty spaces.
  • EmailReporting will now try to retrieve the charset from the email content type if it is present, as this works better then the auto detect of mbstring functions for conversion. As a fallback it will still try the auto detect if the charset is missing.
SL-Gundam

SL-Gundam

2009-10-16 13:32

reporter   ~0023218

hmmm i seem to have missed a post from cas about the processing of bugnotes (0004286:0021199). I going to apply the fix as cas suggested in the next version

tanky

tanky

2009-10-26 12:59

reporter   ~0023352

Hello SL-Gundam,

I applied the lastest patch but still get the charset problem.
Did I missed something? Could you tell me how you configured the plugin?

Thanks

SL-Gundam

SL-Gundam

2009-10-26 16:52

reporter   ~0023360

Last edited: 2009-11-03 16:03

I'm using utf-8 in the database, in EmailReporting and in Microsoft Outlook 2007

Will try to investigate this a little more

SL-Gundam

Keloran

Keloran

2009-11-02 08:53

reporter   ~0023540

It seems multipart emails dont get parsed properlly, so the bugs are coming in with no content

the header is parsed, but the content of the email is negated

SL-Gundam

SL-Gundam

2009-11-03 16:04

reporter   ~0023558

I will look into that Keloran. But i don't expect a fix in the next couple weeks since all of my pc's except for the server are being reinstalled

SL-Gundam

Keloran

Keloran

2009-11-04 07:21

reporter   ~0023567

Seems to be a config issue, semi fixed now (it did loose some formatting, but not enough to complain over)

tanky

tanky

2009-11-05 07:41

reporter   ~0023592

@SL-Gundam: I changed my Outlook charset from Iso to UTF-8 and it works now!

By the way, do you know how to change my current MySQL database charset from ? So, I don't have to modify configuration of all my Outlook users?

Thanks

SL-Gundam

SL-Gundam

2009-11-05 12:44

reporter   ~0023600

it's possible by creating a sql dump, changing all the charsets references in the dump and reimporting the dump.

This will create problems though since some characters will be replaced by question marks for existing data on reimport.

I'm going to try to reproduce your setup and see what i can do to fix it

SL-Gundam

vboctor

vboctor

2009-11-05 13:30

manager   ~0023601

@SL-Gundam and @cas, it's great to see that we have this work as a plugin for 1.2.0. My understanding is that you support pulling the data from POP email accounts. I wonder if we should structure the plugin into two pieces:

  1. Email Box Provider: This provides the configuration to access the mailbox as well as the implementation to pull the data. Your POP specific code would fit here. You could also utilize 0007086 to create an IMAP provider.

  2. Processing the pulled data - this would work independent of the protocol used to pull the data. This involves content conversion, extracting the necessary data from the email text, adding the attachments, etc.

What are your thoughts?

SL-Gundam

SL-Gundam

2009-11-05 19:28

reporter   ~0023606

Thats actually not a bad idea.

I'll try separating the two parts and integrating imap into the plugin after i find a fix for the charset problems

SL-Gundam

rajil

rajil

2009-11-13 01:14

reporter   ~0023707

Hello everybody.
I'm new fellow to PHP. Working with JAVA actually.
I have implemented MANTISBT for internal use.
Also have implemented this plugin but facing some problem.

When i attach single zip file that contains some text/log files in mail and creating issue through mail. The zip file is attached properly with the newly created issue but couldn't read that file. It is not being opened.

And similar case, when i attach some other files like word, excel with the same zip file in mail then i'm able to read this zip file properly. No issues at all.

Can anybody tell me the solution to this?

Steps to come to error:
A) Not working situation

  1. Send mail by attaching a zip file (contains 3-4 text files).
  2. Read mail using this plugin and report new issue and attach files to issue from email.
  3. Try to read or download this file.
  4. Resulting Not working. Not able to open this file using winzip.

B) Working situation

  1. Send mail by attaching a zip file (contains 3-4 text files) and word file and excel file or pdf file.
  2. Read mail using this plugin and report new issue and attach files to issue from email.
  3. Try to read or download all files.
  4. Resulting all files working including the same zip file.

I have attached same zip file in A and B situation. But one is working another is not.

SL-Gundam

SL-Gundam

2009-11-13 08:43

reporter   ~0023710

You do not have this problem when you add those zip files to already existing issues using the upload functionality on the issue details page (so when adding attachments to issues without use of this plugin)?

SL-Gundam

remko

remko

2009-11-13 09:15

reporter   ~0023711

@SL-Gundam Hi, Hope you can help me.
When using the latest version of this plugin and getting html or plain mail WITH special characters like "é" the mail gets parsed perfectly. But when getting html or plain text mail WITHOUT special characters, the text get's wrapped hardcoded and long urls get broken at (about) 64 chars.

The key to this problem must be somewhere in a 7/8 bit check triggering some kind of hard word wrap I'm thinking.

What are your thoughts?

By the way: I've had this problem with all versions of this plugin but would really like to solve it. I'm using UTF-8 encoding for the plugin and for my database.

SL-Gundam

SL-Gundam

2009-11-13 13:06

reporter   ~0023716

Last edited: 2009-11-28 10:54

@remko Thats probably a problem with the html parser. I'm not sure whether that is fixable but i will look into it.

SL-Gundam

stevedoughton

stevedoughton

2009-11-17 05:04

reporter   ~0023735

Problem with PHP 5.11, wait for 5.12 before you upgrade.
I am using Mantis 1.1.0a1 with an old version of this script, but I assume this this note would apply to the current version too. Have just upgraded to PHP 5.11. There seems to be a bug in this release of PHP which means that feof erroneously returns true when reading from a socket to the POP3 server ( Qpopper version 4.1b18). This results in readLine in socket.php randomly returning an empty string when called from _recvLn() in POP3.PHP , so this breaks all the functions in POP3.PHP

Commenting out feof in readLine fixes this problem:
function readLine()
{
if (!is_resource($this->fp)) {
return $this->raiseError('not connected');
}

    $line = '';
    $timeout = time() + $this->timeout;
    while (/* !feof($this->fp) && */ (!$this->timeout || time() &lt; $timeout)) {
        $line .= @fgets($this->fp, $this->lineLength);
        if (substr($line, -1) == &quot;\n&quot;) {
            return rtrim($line, &quot;\r\n&quot;);
        }
    }
    return $line;
}

As feof( ) seems to randomly return true I suspect a timing issue, probably depends on whether the mail server has written to the socket before feof is called - our mail server resides on another server.

The problem has possibly arisen in PHP bug 49072 (feof never returns true for damaged file in zip). http://bugs.php.net/bug.php?id=49072

It is fixed in the latest version ( 5.12 release candidate 2 ).

remko

remko

2009-11-18 03:47

reporter   ~0023746

@SL-Gundam : found the problem. It's not with this plugin parsing, it's with the display parsing. The text in de database is fine, with soft linebreaks where they should be and no broken text. So I ques I'll have to look into the standard mantis display parsing for the description field to fix this.

SL-Gundam

SL-Gundam

2009-11-18 10:54

reporter   ~0023752

i know that mantis 1.2.0rc1 removes line breaks in the simple view and shows them properly in advanced view.

I'm not sure about 1.2.0rc2 since it does not seem to have those view types

SL-Gundam

SL-Gundam

2009-11-28 10:51

reporter   ~0023818

@tanky I think i've found the reason why charset conversions still did not work properly for you.

I will release a new version of the plugin in a couple days. Please test it again with that new version

SL-Gundam

SL-Gundam

SL-Gundam

2009-11-28 11:12

reporter   ~0023819

Last edited: 2009-11-28 11:13

@rajil I think i've found your problem and its not an issue with this plugin

As far as i can see Mantis 1.2.0rc2 sometimes adds some text before and after the actual file. This might cause your problems with reading the file. The cause for this bug might not be mantis but i did not investigate any further
Example of added texts
Added before: <p style="color:red">SYSTEM WARNING: finfo::finfo() [<a href='http://www.php.net/manual/en/finfo.finfo.php'>finfo.finfo.php&lt;/a>]: Failed to load magic database at ''.</p><p style="color:red">SYSTEM WARNING: finfo::file() [<a href='http://www.php.net/manual/en/finfo.file.php'>finfo.file.php&lt;/a>]: The invalid fileinfo object.</p>
Added after: <br /><b>Fatal error</b>: Allowed memory size of 134217728 bytes exhausted (tried to allocate 524289 bytes) in <b>E:\webserver\htdocs\default\mantisbt-1.2.0rc2\file_download.php</b> on line <b>191</b><br />

Also in 1.2.0rc1 and rc2 there is a problem where the name of the file is not properly assigned which results in a file name like "file_download.php" or "file_download" followed by whatever extension the original filename had.

SL-Gundam

SL-Gundam

SL-Gundam

2009-11-28 11:42

reporter   ~0023820

@remko I think i've actually found your problem. It has to do with plaintext emails.

Email programs often add a html and a plaintext version of the same email to the email its sending. It seems the plaintext versions get wrapped while using the latin charsets, either by the email program (in my case outlook 2007) or the email server(s).

At least it seems its not something i can fix within this plugin

SL-Gundam

SL-Gundam

SL-Gundam

2009-12-01 15:21

reporter   ~0023837

Last edited: 2009-12-02 12:02

Well its finally here: MantisBT-1.2.0rc2_plugin_EmailReporting-0.7.0.rar

IMAP functionality has been added and a small number of improvements and bug fixes are present in this version. it's possible that the changes have created new bugs, especially since new functionality has been added but i've checked the new functionality as good as possible so lets hope we don't see any more bugs ;)

Charset problems should be fixed now. Please let me know if any of you still find any problems with this

IMAP addition based on work from Rolf Kleef 0007086.
IMAP support has been added. Its still a bit experimental but should work fine. Here are some explanation about specific IMAP settings

The IMAP base folder is the folder under which Mantis expects to find subfolders for each project or a single folder for specific project. This could for instance be "INBOX/to_mantis" (meaning the mail folder "to_mantis" under the INBOX folder of the account).

If you enable "Create project subfolder structure" for a mailbox, folders for projects are created under the IMAP base folder if they don't exist yet. Emails in those subfolders will be imported to their corresponding projects. If you disable this setting, only emails in the basefolder will be imported to the project which is defined for the mailbox

Inbox can most likely not be your basefolder, but that might differ between different imap servers. (Applies only to mailboxes where you enable "Create project subfolder structure")

The very free format of project names needed to be mapped to a bit more restricted format for IMAP folder names. We took these steps, and it might lead to name collisions or folder names that are a tiny bit different from their project name counterparts (but we haven't had problems in practice).

  • translate all accented characters to plain ASCII equivalents
  • replace all but alphanum chars and space and colon to dashes
  • replace multiple dots by a single one
  • strip spaces, dots and dashes at the beginning and end

Changelog:
Dec 2009

  • Added a fix for the adding of bugnotes when the issue is readonly (0004286:0021199)
  • Sometimes the charset names in emails were lowercase while mb_list_encodings returned names using a mix of upper and lower case names. This caused problems for detecting valid encodings used in emails
  • Support for IMAP has been added based on Rolf Kleef's work
  • Added Net_IMAP 1.0.3 to this package. 1.1.0 seems to be broken in some situations so EmailReporting will force the use of 1.0.3
  • Added sanity check to the bug priority array config. If this fails the old value will be retained
  • mail_auth_method (now called mailbox_auth_method) has been moved from the configuration menu to the mailbox settings. This way you can modify this per mailbox
  • Script is now declared compatible with 1.2.0rc2
  • Restored lost functionality to mail_fetch_max. This functionality was lost from version mantis-1.0.3.patch.gz and onwards. You might want to increase the mail_fetch_max value since by default it wil only retrieve one email per mailbox everytime bug_report_mail.php is executed
  • Deleting mailboxes works again. Seems to have been broken since the 0.5.0 release

SL-Gundam

tanky

tanky

2009-12-02 10:20

reporter   ~0023839

Hello SL-Gundam,

Thanks for this new version. It fixed my charset problem whatever ISO or UTF-8 selected in Outlook for sending emails.

Tanky

SL-Gundam

SL-Gundam

2009-12-02 12:01

reporter   ~0023840

Thats very good news tanky, we have finally fixed that issue then :D

SL-Gundam

obstbaum80

obstbaum80

2009-12-05 10:01

reporter   ~0023857

@SL-Gundam
made some changes to your latest release
changes

  • added support for imap ssl
  • mailbox_auth_method now saves the value actually selected

Since mantis wont let me upload here is a link:
http://www.yopeso.com/downloads/MantisBT-1.2.0rc2_plugin_EmailReporting-0.7.1.tar.gz

SL-Gundam

SL-Gundam

2009-12-05 14:20

reporter   ~0023859

@obstbaum80, looks good. I've already made changes for a 0.7.1 release so i will change my 0.7.1 to 0.7.2 and add your changes to them

SL-Gundam

SL-Gundam

SL-Gundam

2009-12-05 21:00

reporter   ~0023860

Hi everyone

Here is a new version: MantisBT-1.2.0rc2_plugin_EmailReporting-0.7.2.rar

Based on obstbaum80's work and some small enhancements by myself.

Since one issue regarding the 0 byte attachments could block the proper processing of emails, i'm releasing this update now instead of waiting for more people to find bugs. If necessary a 0.7.3 release will follow for further bug fixing

Changelog:
Dec 2009 v2

  • If a charset has already been found in the email it will stop searching for other charsets
  • If a attachment has a size of 0 bytes it will now be added to the rejected-files.txt else it will block proper processing of emails
  • The max attachment size will now be calculated the same way Mantis does
  • Added SSL support for IMAP and POP3 connections partially based on work from obstbaum80
  • mailbox_auth_method will save the selected value properly now (obstbaum80)
  • The possible values for mailbox_auth_method are now retrieved from the pear packages Net_IMAP and Net_POP3
  • various small code optimizations

SL-Gundam

maximaxi

maximaxi

2009-12-10 03:38

reporter   ~0023892

Does the plugin work with version 1.1.1 of Mantis?
We have too deep modifications to update our Mantis version...

SL-Gundam

SL-Gundam

2009-12-10 10:56

reporter   ~0023893

Last edited: 2009-12-10 10:57

No, i'm afraid not. The plugin system which it requires was a new feature in version 1.2.0.

So you need to have at least MantisBT 1.2.0rc1

SL-Gundam

Arades

Arades

2009-12-12 07:55

reporter   ~0023901

Hi,

i hope somebody can help me. I'm new to mantis and try to run mantis with emailreporting possibility. I have a successfull 1.1.8 Installation and some confusing problems with a paralell try to install 1.2.0rc2.

So, my Question is, can i use any Package with my 1.1.8 Installation?

Would be nice to get some help...

Thanks

cas

cas

2009-12-12 08:56

reporter   ~0023902

Simple answer is NO. Package are geared towards the plugin module of version 1.2

SL-Gundam

SL-Gundam

2009-12-22 10:14

reporter   ~0023957

Last edited: 2009-12-22 10:15

Hi everyone

here is a new version again: MantisBT-1.2.0rc2_plugin_EmailReporting-0.7.3.rar

I've put in some more work and its now possible to run this plugin without setting up a cronjob. Though the recommended method is still that you set up a cronjob.

I added that functionality for people who for some reason are not able to set up a cronjob. This method has the disadvantage that the main trigger is a mantis page visit. So if nobody visits the mantis webpages, no new issues will be imported. There is a timer in the plugin configuration so that not every page visit will trigger this, we wouldn't want to spam the mailservers with connections.

I've also made several enhancements to the code as can be seen from the changelog below

Dec 2009 v3

  • Applied a natural case insensitive sort on the charset dropdown list in the configuration menu
  • Changed the sort method from normal sort to natural case insensitive sort for mailbox_auth_method
  • Mimedecode pear package updated to new version
  • rfc_822bodies (new option in mimedecode) forced to false
  • The messages in IMAPs with the deleted status will not be counted towards the mail_fetch_max counter
  • various small code optimizations
  • Scheduling bug_report_mail as a cron / scheduled job is not required anymore, but is recommended and EmailReporting default configuration assumes you have / will set one up.
  • Adjusted the check whether bug_report_mail can run in a webserver to the same method as in send_emails.php
  • The On and Off texts have been replaced by Yes and No
  • Added helper_mantis_url around 1st bug_report_mail link on the configuration page
  • Removal of mantis replies is no longer experimental
  • Applied a fix for the path in emails that are generated by mantis while bug_report_mail is running outside of a browser
  • During installation allow_blank_email will no longer use config_set. It will use config_set_cache
  • Changed the random number generator for user creations from rand() to mt_rand( 4, 5 )

SL-Gundam

SL-Gundam

SL-Gundam

2009-12-23 21:07

reporter   ~0023978

It's kinda a shame. Today i had a new client for who i also set up MantisBT 1.2.0rc2 + the EmailReporting plugin. During this i found out that there is a possible problem with setting up a cronjob on linux systems.

This problem consisted of not being able to find the core.php file in the mantis root directory.

I applied a fix for this in EmailReporting 0.7.4 just a day after i released 0.7.3.

Anyways it comes down to this. If you have problems setting up the cronjob because its failing with errors that it could not find core.php in bug_report_mail.php on line 5, please let me know. I will prepare 0.7.4 for release if more people have problems with this, otherwise i'm going to wait a bit more until the changelog for that version has grown a bit bigger.

Merry christmas and a happy newyear

SL-Gundam

schneebi

schneebi

2010-01-05 02:08

reporter   ~0024035

I had this problem (unable to find core.php), but I've fixed it, so for me no need for a quick update...

roofdog

roofdog

2010-01-05 17:18

reporter   ~0024053

Help Needed!

I'm not sure this is the right forum to ask for help regarding a setup issue with this plugin.. so if it isn't please point me to the right place. Also, I am not a programmer so my knowledge of PHP is limited.

Configuration:
Windows 2003 Server running IIS v6
Mantis: 1.2.0rc2
Plugin: 0.7.3
PHP: 5.2.11

I installed the plugin, activated it, and setup a POP3 account in the mail account settings. When I do "test mailbox" the response just goes back to the
maintainmailbox page so I am not sure the test is actually working?? I did go in and edit the mailbox settings and did some things like fumble the password or change the authen settings and did "test mailbox" and got the Operation Failed screen so I am assuming that the return to the maintainmailbox page means it is working.

Since I am on windows I run the c:\program files\php\php.exe c:\inetpub\wwwroot\mantis\plugins\EmailReporting\scripts\bug_report_mail.php from the command prompt (and tried via a batch file) and it just returns nothing so I don't know whats going on.

It doesn't write anything to the mail temp folder that I have setup in plugin configuration nor does it create a bug. Also, I have turned on Debug and it doesn't write anything to that folder either.

The only thing I can see that may be an issue is in the plugin config, at the bottom it says:

"PHP mbstring functionality unavailable" Maybe this is the problem? What does it mean?

Anybody know what's going on?

cas

cas

2010-01-06 03:47

reporter   ~0024055

open up php.ini
search for:
extension=php_mbstring.dll
Most likely this line has a semicolon(;) in front of it.
Remove the semicolon, save php.ini, restart webservices and try again.

SL-Gundam

SL-Gundam

2010-01-06 10:12

reporter   ~0024061

That message would be fixed by Cas response but it should not be necessary for the plugin to work properly, it's only needed for charset conversions between emails and database. Though i have noticed that at the moment in 0.7.3 its missing those conditions so it actually does require mbstring in 0.7.3. I'll fix that for 0.7.4

During the testing you only get "Operation succeeded" when you enable "show_queries_count", otherwise when a test is succesfull you'll just get the maintain mailox page again. So your mailbox is working properly

It only needs those temporary folders when there are emails in the mailboxes its checking.

Let me know if you are having problems fixing "PHP mbstring functionality unavailable", then i will make 0.7.4 available here

SL-Gundam

cor3huis

cor3huis

2010-01-06 16:49

reporter   ~0024065

I realize this is not a forum, but wanted to say THANKS for the development, it is not that I use it, but the enthusiastic persistent development is great!

obstbaum80

obstbaum80

2010-01-07 10:23

reporter   ~0024082

i would like to submit some additional changes i made. any chance we can get access to a git repository on mantisforge to continue the development in this plugin?

SL-Gundam

SL-Gundam

2010-01-09 14:15

reporter   ~0024113

Last edited: 2010-03-03 12:17

@obstbaum80 I've also got some changes lined up. I don't know about the if and when of the git repository but in the mean time we can at least combine our changes and make a new release of this plugin in this issue.

SL-Gundam

Terko

Terko

2010-01-15 11:45

reporter   ~0024163

Hi there,

i've a little question about the text parsing process.
Does this plugin parse the body from email to report things like Reproducibility,
Severity, Priority, Assign to etc. directly to MantisBT?

If yes, where can i find the config file to set up what to parse where to? Do i need goodPHP experience to modify it? Never really worked with php yet.
I looked @ the parse.php in the EmailReporting\core\Mail directory but with my knowledge of php it didnt helped really

Just want to have a email beeing added directly to the Tracker fields and not everything in description and modify the plugin that for example a body like this :

"Category:1&&Reproducibility:Always&&Severity:Minor&&Description:'MyTextHere...' and so on"

will be submited directly to the Bugtracker System

I'm using MantisBT 1.2.0rc2 and Email reporting 0.7.2.

Chris

SL-Gundam

SL-Gundam

2010-01-15 14:47

reporter   ~0024165

Currently the plugin will not parse the body for anything

It will use the default values as defined in the mantis configuration parts (config_defaults_inc.php, config_inc.php and the mantis configuration page)

One thing this plugin does do is parse the priority of the email

SL-Gundam

SL-Gundam

SL-Gundam

2010-01-18 14:42

reporter   ~0024192

Well here it is again: MantisBT-1.2.0rc2_plugin_EmailReporting-0.7.4.rar

This version just fixes a small number of bugs that were found.

The most significant changes are probably:

  • the Disabling of quoted_printable_decode in the parser.php
  • the way bugnotes by email are handled. Before any issue with a higher status then 'bug_reopen_status' (by default 'feedback') would be 'reopened', which would cause it to get the resolution 'reopened' and the status 'feedback'. Now that is only done when the actual 'reopen' button would have also been available in the issue at the time.

Jan 2010

  • Small fix for possible problems finding core.php in scripts/bug_report_mail.php
  • mbstring extension is no longer a requirement for running this plugin
  • Disabled quoted_printable_decode in parser since mimedecode is already doing that
  • rfc_822bodies forced to true (also needed transfer_encoding)
  • Kerio Mailserver had a compatibility issue with net_imap 1.0.3 (was fixed in net_imap 1.1.0). The fix has been backported to 1.0.3 in this plugin
  • Some connection error handling improvements
  • Adding notes by email generated 2 exactly the same notifications
  • Status change and resolution change for adding bugnotes by email now only occures when the status of the bug has gone past 'bug_resolved_status_threshold' instead of 'bug_reopen_status'
  • mail_mantisbt_url is now called mail_mantisbt_url_fix because variables with url in the end are not allowed to be stored in the database anymore

SL-Gundam

bolshi

bolshi

2010-01-19 04:17

reporter   ~0024198

Last edited: 2010-01-19 04:37

Hello,
everthing works fine, except EmailReporting. I downloaded the latest release from here: http://www.mantisbt.org/bugs/view.php?id=4286 and unzipped it. There's the following structure:

localhost/mantis/plugins/emailReporting/core
localhost/mantis/plugins/emailReporting/doc
localhost/mantis/plugins/emailReporting/EmailReporting.php
localhost/mantis/plugins/emailReporting/lang
localhost/mantis/plugins/emailReporting/pages
localhost/mantis/plugins/emailReporting/scripts

For checking I installed the pluginmanager plugin. It works well against emailReporting. PEAR also works. At the moment I use that version: http://downloads.sourceforge.net/mantisbt/mantis-1.2.0rc2.zip
Do I need an other release? Do I have to call a special file in web browser?

Greetings from Berlin, Germany

SL-Gundam

SL-Gundam

2010-01-19 12:08

reporter   ~0024199

Basically the procedure is as follows

  1. unzip the package in the plugins directory (you've apparently done this)
  2. go to the mantis "manage plugins" page
  3. "EmailReporting ?.?.?" should be in the list of available plugins
  4. Install the EmailReporting plugin
  5. Configure the plugin as necessary
  6. Add the necessary mailboxes
  7. Set up a cronjob for "/plugins/EmailReporting/scripts/bug_report_mail.php"

That should be it

bolshi

bolshi

2010-02-03 07:33

reporter   ~0024296

Last edited: 2010-02-03 08:13

Hello,
I followed your steps. Cronjob works fine. Unfortunetely I get this message:"PHP Fatal error: Call to undefined function mail_get_mailboxes() in /htdocs/mantis/plugins/EmailReporting/pages/bug_report_mail.php on line 31"

I edited the bug_report_mail.php and found on line 31:

"$t_mailboxes = mail_get_mailboxes();"

Then I asked google for 'mail_get_mailboxes()'. I got no answer. Do you have an idea what's wrong here?

bolshi

SL-Gundam

SL-Gundam

2010-02-03 08:04

reporter   ~0024299

mail_get_mailboxes is a function in core/mail_api.php. Weird that you get that error because 2 lines before that mail_api.php is included by a require_once. Which means that if that failed, it should have already got a fatal error. But since you did not get that error a version of mail_api.php was included... though i doubt

I fear you might have mixed various versions of EmailReporting with each other, particulary a version older than 0.7.0 and 0.7.0 or newer (maybe even a MantisBT 1.1.x version of this plugin).

Do the following (make sure you create proper backups if necessary):

  1. Extract a clean copy of mantisbt 1.2.0rc2 in an empty folder
  2. copy the config_inc.php from the old mantis folder to the new one
  3. extract MantisBT-1.2.0rc2_plugin_EmailReporting-0.7.4.rar into the plugins directory of the newly created mantis folder
  4. go to the mantis "manage plugins" page of the newly created mantis folder
  5. "EmailReporting ?.?.?" should be in the list of available plugins or maybe even already in the installed plugins
  6. Install the EmailReporting plugin if necessary
  7. Configure the plugin as necessary
  8. Add the necessary mailboxes
  9. Set up a cronjob for "/plugins/EmailReporting/scripts/bug_report_mail.php" (adjust the existing cronjob to the newly created mantis folder)

This should fix any conflicting EmailReporting versions.

bolshi

bolshi

2010-02-03 10:39

reporter   ~0024300

Last edited: 2010-02-03 11:58

I reinstalled as described. Seems to be fixed. Thank you. At the moment I don't get a message from crontab. But I don't get no mail as well. Neither via POP nor via IMAP. If I test the account via POP there's no error message. Via IMAP I got the following:

Operation NOT successful

Mailbox description: mantis request via IMAP
Mail server type: IMAP
Mail server hostname(:port): mail.server.de:143
Mailbox connection encryption: None
Mailbox username: ticket@server.de
Mailbox password: **
Authentication method: PLAIN
Mailbox basefolder (IMAP): to_mantis

[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]

Do I have different ways for testing?

appended:
In a posting above I read something about configuration like that:

this is how i've set it up

[code]
######################

Mail Reporting

######################

# --- mail reporting settings -----
# This tells Mantis to report all the Mail with only one account
$g_mail_use_reporter    = OFF;

# The account's name for mail reporting
# Also used for fallback if a user is not found in database
    # helpdesk is the name of the account holder all the mails are send from
$g_mail_reporter    = 'helpdesk'; 

# Signup new users automatically (possible security risk!)
# Default is OFF, ignored if mail_use_reporter is ON
$g_mail_auto_signup = OFF;

# How many mails should be fetched at the same time
# If big mails with attachments should be received, specify only one
$g_mail_fetch_max   = 1;

# Write complete mail into the &quot;Additional Information&quot;
# NOTE - doesn't function because the variable doesn't exist in the function where it is used. So just leave OFF
$g_mail_additional  = OFF;

# Write sender of the message into the bug report
$g_mail_save_from   = ON;

# Parse MIME mails (may require a lot of memory)
$g_mail_parse_mime  = ON;

# Parse HTML mails
$g_mail_parse_html  = ON;

# HTML Parser Command
# It should print the formatted text to STDOUT
# For example: &quot;/usr/bin/w3m -T text/html -dump&quot;
# NO LONGER NEEDED, thx to html2text
#$g_mail_html_parser    = OFF;
$g_mail_html_parser = '/usr/bin/w3m -t text/html -dump';

# directory for saving temporary mail content
$g_mail_tmp_directory   = '/tmp';

# Delete incoming mail from POP3 server
$g_mail_delete   = ON;

# Signup new users automatically (possible security risk!)
# Default is OFF, ignored if mail_use_reporter is ON
$g_mail_debug    = OFF;

# Save mail contents to this directory if debug mode is ON
$g_mail_directory   = '/tmp/mantis';

# The auth method used for POP3

Valid methods are: 'DIGEST-MD5','CRAM-MD5','LOGIN','PLAIN','APOP','USER'

#NOTE: Try to chnage between these methods..the most common is USER
$g_mail_auth_method = 'USER';

# Looks for priority header field
$g_mail_use_bug_priority = ON;

# Default priority for mail reported bugs
$g_mail_bug_priority_default = NORMAL;

# Default bug category for mail reported bugs (Defaults to &quot;default_bug_category&quot;)
# Because in Mantis 1.1.0a3 a category is required, we need a default category for issues reported by email.
# Make sure the category exists and it has been configured correctly
#$g_mail_default_bug_category = '%default_bug_category%';

#NOTE Reported by mail: is the name of the bug category in MANTIS [you have to create one] where all the mails that are reportet by mail come
$g_mail_default_bug_category = 'Reportet by mail';

# Classify bug priorities
$g_mail_bug_priority = array(
    '5 (lowest)'    => 10,
    '4 (low)'   => 20,
    '3 (normal)'    => 30,
    '2 (high)'  => 40,
    '1 (highest)'   => 50,
    '5'  => 20,
    '4'  => 20,
    '3'  => 30,
    '2'  => 40,
    '1'  => 50,
    '0'  => 10,
    'low'    => 20,
    'normal' => 30,
    'high' => 40,
    '' => 30,
    '?' => 30
    );

[/code]
<<

Which file do I have to edit to fill the appropriate values into it?

SL-Gundam

SL-Gundam

2010-02-03 16:40

reporter   ~0024303

your mailboxes are setup correctly when you do not get a error when you test them.

But when no emails are imported at all, then the cronjob is not working as it should. I suggest you check that a bit more.

About the code above, thats useless since it was applicable to a older version. All of that has been moved to the EmailReporting configuration.

bolshi

bolshi

2010-02-04 04:22

reporter   ~0024309

Last edited: 2010-02-04 04:29

Concerning description the cronjob contains the following:
"/2 * php /srv/www/htdocs/mantisbt1/plugins/EmailReporting/scripts/bug_report_mail.php
MAILTO=ticket.de"

That's just for mistakes. But I couldn't find any other information to define the cronjob. In mantis forums they said: "Sorry, we don't support that plugin."
Is there a more detailed configuration description for the cronjob?

SL-Gundam

SL-Gundam

2010-02-04 11:22

reporter   ~0024316

Last edited: 2010-02-04 20:36

afraid not. It expects you know pretty much on your own how to create a cronjob and if needed how to find out whether its working properly. If you lack that knowledge then i think the easiest way would be to go to the EmailReporting plugin configuration page and set the second option to "No" and remove the cronjob you added.

Thats pretty new functionality though so there might still be some bugs in it.

Also make sure you do not get errors when you test the mailboxes you've set up. I'm afraid i can not help you since the error you are currently getting is empty. Which should not be possible...

Why do you have the hostname mail.server.de? As far as i can find that hostname does not exist, neither does server.de for that matter

jurgenhaas

jurgenhaas

2010-02-05 07:15

reporter   ~0024331

This is a great module, thanks for the development. I've just noticed a big issue while configuring mailboxes when working with subprojects.

The value of the dropdown on a subproject is e.g. "6;8" which is not numeric and hence the saving of the mailbox setting fails. The mailbox_project should be "8", not "6;8".

Any chance of fixing this?

SL-Gundam

SL-Gundam

2010-02-05 07:32

reporter   ~0024332

Last edited: 2010-02-05 07:48

I've fixed the issue. It will be in the next version. Though i'm not sure when that will be.

You can fix it yourself by doing the following:

  1. Open pages/maintainmailbox.php
  2. On line 146 look for "print_project_option_list( $t_config[ 'value' ], false, null, true )"
  3. Change the last parameter from true to false like this: "print_project_option_list( $t_config[ 'value' ], false, null, false )"

SL-Gundam

jurgenhaas

jurgenhaas

2010-02-05 09:57

reporter   ~0024333

Excellent, thanks for your quick and precise response. It works as described.

Andreas Besier

Andreas Besier

2010-02-10 05:05

reporter   ~0024361

Thanks for this excellent tool. but one more question. how can i automatically set the "assigned to" person. i have assign some projects to a admin and when an bug is reported by mail the admin of this project need to be informed. for one this is no problem. but when i have different projekt with different admins how can i do this?

Thanks for your help

SL-Gundam

SL-Gundam

2010-02-10 06:35

reporter   ~0024364

That can be fixed easily with the default mantis functionality.

Just go to Manage -> Manage Configuration -> E-mail Notifications

Now for "Status changes to 'new'" enable the proper box for the access levels that you want to receive notifications.

pearljam145

pearljam145

2010-02-10 15:07

reporter   ~0024369

Newbie here, I am trying to get this plugin to work with my Google Apps account. I tried various combinations, but unfortunately nothing seems to work. Can you please help with the settings?

SL-Gundam

SL-Gundam

2010-02-10 19:58

reporter   ~0024370

I perform regular tests on gmail with EmailReporting (don't know if google apps differs greatly). I do advise that you check whether you are running the latest version of EmailReporting

Both IMAP and POP work for me.

See the following pages for information on the configuration for gmail accounts
http://mail.google.com/support/bin/answer.py?answer=78799 - IMAP
http://mail.google.com/support/bin/answer.py?answer=13287 - POP

pearljam145

pearljam145

2010-02-10 22:53

reporter   ~0024371

Hi SL_Gundam

I am running the latest version of EmailReporting. Can you please share your settings for POP3

This is what I have
Description: Ticket Generator
Mail server type: POP3
Mail server hostname: pop.gmail.com:995
Mailbox encryption: SSL
Mailbox username: xyz@gmail.com
Password: mypassword
Authntication method: USER
Mailbox basefolder: <Empty>
Create project subfolder structure: No

Can you please tell me what I am doing wrong?
Would appreciate any help.

Thanks

Andreas Besier

Andreas Besier

2010-02-11 01:43

reporter   ~0024372

Last edited: 2010-02-11 02:01

Thanks for your help.

Now I try to inform the reporter when an note is added to his reported task. but i doesn't work.

The next thing is, that the answer is always coming with the default "mail" reporter mail address. but i want to use the mail address of the used mailbox and this is different from the mail account user.

Is it possible to change this?

SL-Gundam

SL-Gundam

2010-02-11 15:02

reporter   ~0024376

@pearljam145, could you test the mailbox using the EmailReporting "Test mailbox" functionality. I've just tested this with my own gmail account and it worked without problems. I used the same set up as you. Also please check whether you have enabled POP for your gmail account (see the settings page within your gmail account for "Forwarding and POP/IMAP")

@Andreas Besier, various things could cause that the user does not get notifications

  • his personal / global email notification settings have this disabled
  • He has no relation to the bug in question (no monitoring, note posted, or the creator of the issue)
  • There is also the option where users don't get email notifications about there own actions.
    etc.

Also the email address of the mailbox the email was sent to is not used for anything during the creation of the issue. EmailReporting uses the following two settings from the configuration page to decide who sent the note or the issue to EmailReporting

  • "Use one account for issues created by email" - Use only one account or try to find an existing account that uses the email address where this email came from. If the account is not found the "Mail Reporter" is used
  • "The account name for issues created by email" - Select the "Mail Reporter" account
  • "Signup new users automatically (possible security risk!, see documentation)" - This modifies the behaviour where it would normally would fallback to the "Mail Reporter" account. If enabled it will try to create a new user using the email address the email came from

Also Andreas, please keep your questions on the topic of EmailReporting. Any questions about standard functionality of MantisBT should be directed to the forums: http://www.mantisbt.org/support.php

SL-Gundam

pearljam145

pearljam145

2010-02-11 15:29

reporter   ~0024378

Ok I found the issue. My ISP is blocking connections on port 995. I just tried telnet pop.gmail.com 995, and got a connection refused message. Sorry about the trouble and thank you for the feedback.

SL-Gundam

SL-Gundam

2010-02-11 20:39

reporter   ~0024379

i just tried what you did but i used putty, but it also fails.

So it might not be your ISP. My advise still stands, try the "Test mailbox" functionality and see what error it returns.

SL-Gundam

maximaxi

maximaxi

2010-02-12 08:42

reporter   ~0024384

Would this plugin also work with MSSQL? Or is it independent 'cos Mantis itself manages the db stuff?

SL-Gundam

SL-Gundam

2010-02-12 19:01

reporter   ~0024386

the earlier plugin for 1.2.0 called recmail was specific for mysql but EmailReporting only uses the mantis api's and therefore should work with all the supported database types for mantis

Andreas Besier

Andreas Besier

2010-02-18 08:05

reporter   ~0024410

Hi again,

sorry for my question again maybe i use the wrong thread.

But i use 3 Mailboxes with the server type POP3. Each Mailbox use an different projekt.

For example:

Mailbox: A Pop3-Account A Project A
Mailbox: B Pop3-Account B Project B
Mailbox: C Pop3-Account C Project C

I only got one configuration with the option "Use one account for issues created by email " set to no.

Everything works absolutly fine but when i receive an mail, for example somebody add an note to an task, the reply address is always "Mantis Bug Tracker (no-reply@xxxxxxx)"

The no-reply@xxxxxx comes from the mail account user. But i want to change this mail address from no-reply@xxxx to an mailbox specific address

for example:

Mailbox A POP3 Reply-Address: projectA@xxxxx
Mailbox B POP3 Reply-Address: projectB@xxxxx
Mailbox C POP3 Reply-Address: projectC@xxxxx

I also tried to change the plugin_EmailReporting_mail_reporter configuration from each project to specified project with different Users. But it doesn't work.

Please can you help me or do i have to use this in an other thread?

Thanks for your help

Andreas Besier

Andreas Besier

2010-02-18 08:11

reporter   ~0024412

Last edited: 2010-02-18 08:47

Hi again,

sorry for my question again maybe i use the wrong thread.

But i use 3 Mailboxes with the server type POP3. Each Mailbox use an different projekt.

For example:

Mailbox: A Pop3-Account A Project A
Mailbox: B Pop3-Account B Project B
Mailbox: C Pop3-Account C Project C

I only got one configuration with the option "Use one account for issues created by email " set to no.

Everything works absolutly fine but when i receive an mail, for example somebody add an note to an task, the reply address is always "Mantis Bug Tracker (no-reply@xxxxxxx)"

The no-reply@xxxxxx comes from $g_from_email config settings. But i want to change this mail address from no-reply@xxxx to an mailbox specific address

for example:

Mailbox A POP3 Reply-Address: projectA@xxxxx
Mailbox B POP3 Reply-Address: projectB@xxxxx
Mailbox C POP3 Reply-Address: projectC@xxxxx

I also tried to change the plugin_EmailReporting_mail_reporter configuration from each project to specified project with different Users. But it doesn't work.

Please can you help me or do i have to use this in an other thread?

Thanks for your help

SL-Gundam

SL-Gundam

2010-02-18 11:28

reporter   ~0024429

@Andreas. The email address mantisbt uses as the from address when its sending mails is core mantis functionality. This plugin does not change or add anything on to that.

See the following settings in config_defaults_inc.php and possibly config_inc.php

/**

  • the sender email, part of 'From: ' header in emails
  • @global string $g_from_email
    */
    $g_from_email = 'noreply@example.com';

/**

  • the sender name, part of 'From: ' header in emails
  • @global string $g_from_name
    */
    $g_from_name = 'Mantis Bug Tracker';

But why would you want to change the reply address? replies work from any address. If sombody replies to a mantis notification email, it does not matter to which mailbox the email is sent, as long as EmailReporting correctly checks the mailbox for emails it will allways be added to the correct issue.

SL-Gundam

libregeek

libregeek

2010-02-23 00:38

reporter   ~0024462

Tried to install the latest version of plugin in mantisbt-1.2.0 (stable) and got the following errors in the manage_plugin_page

APPLICATION WARNING #300: String "plugin_EmailReporting_title" not found.
APPLICATION WARNING #300: String "plugin_EmailReporting_description" not found.
APPLICATION WARNING #300: String "plugin_EmailReporting_author" not found.
APPLICATION WARNING #300: String "plugin_EmailReporting_mailbox_settings" not found

In adidtion the following errors occured in the plugin page(mantis/plugin.php?page=EmailReporting/config)

APPLICATION ERROR #2502
Plugin page not found.

It may be nice if this package is added to the git repository(http://git.mantisforge.org/)

libregeek

libregeek

2010-02-23 04:33

reporter   ~0024464

Please ignore #c0024462

I have added a minor feature to prevent spam emails getting reported as issue in mantis.

(Use case: Our company is providing support only to three companies which has their own domain names. We don't expect other users to mail to this exclusive support email address)

This feature is completely optional and you have to specify a configuration change in EmailReporting.php. This requires a configuration variable named 'mail_patterns', which is essentially an array of regular expressions to match the incoming email.

The regular expressions should be compatible with preg_* methods in PHP. As of now, this configuration change cannot be done through the admin interface. You have to edit the source code to make the changes.

I have also incremented the minor version of the plugin(0.7.5)

libregeek

libregeek

2010-02-24 02:02

reporter   ~0024477

I have made one more change in mail_get_user() method. This is to check whether the incoming email address is already registered in mantis database, even if mail_use_reporter is set to TRUE.

Here is the use case:
In our company we use the same mantis instance to track our internal issues as well as client requests. (The internal employees has mantis access, but most often they use blackberry or iphone to report issues). The employees should be able to report the issues with their own user_id while all the external issues are reported with a common user_id(Mail5 or MailReporter).

I have tested and confirmed that this change will not break any existing functionality.

The updated package is tagged with version 0.7.6 and uploaded to the files section.

It is very hard to track the versions in this bug. It may be really nice if this plugin is moved to http://git.mantisforge.org

SL-Gundam

SL-Gundam

2010-02-24 11:14

reporter   ~0024486

Thats useless libregeek.

That was already present in EmailReporting if you do the following:
"Use one account for issues created by email" -> "No"
"Signup new users automatically (possible security risk!, see documentation)" -> "No"

In this case it would check for existing users with the email address. If that fails it will use the Mail Reporter account as a fallback

As long as you give your external clients no account in mantis this should work as expected

SL-Gundam

libregeek

libregeek

2010-02-25 00:10

reporter   ~0024503

Hello SL-Gundam,
Thanks for pointing the issue. Somehow I missed the fallback code and hacked it without further testing. It was my mistake. I shall revert the changes and will upload the new package today itself.

libregeek

libregeek

2010-02-25 00:52

reporter   ~0024504

I have reverted the changes as per the comment in c0024486 and the package is added with version 0.7.7

I have also separated the README and CHANGELOG and changed the format for CHANGELOG file. The entries are now based on version number which would be easy to track the changes.

How about adding this plugin in git.mantisforge.org with the name "EmailReporting" ?

scaranol

scaranol

2010-02-27 10:03

reporter   ~0024560

I had a problem getting the plugin (0.7.7) to be available in the plugin section. When I copied 0.7.5 in there it worked great. Anyone else see this?

SL-Gundam

SL-Gundam

2010-02-27 10:52

reporter   ~0024561

Yeah libregeek changed the plugin directory name which could cause problem for people updating there existing installation.

In a couple hours i will release a new version and it should be fixed.

SL-Gundam

SL-Gundam

SL-Gundam

2010-02-27 11:53

reporter   ~0024562

Last edited: 2010-02-27 17:52

Well here it is. A little bit earlier then expected since i put some extra time in testing the changes this weekend.

MantisBT-1.2.0_plugin_EmailReporting-0.7.8.rar

I implemented libregeek's idea using a different method. His idea was good, but its implementation was not user friendly. Also mantisbt already contained a variant of his idea in its core code. Its better to use that.

The validation is done by the email_is_valid function which checks for several things based on certain core mantis configuration options, namely
validate_email
use_ldap_email
allow_blank_email
limit_email_domain
check_mx_record

One drawback of this method i implemented is that it only allows one domain, which might not be enough for libregeek. But i believe thats something that should be taken up with the mantis developers to improve the functionality so that it allows multiple domains

It uses the limit_email_domain setting which can be found in config_defaults_inc.php in the mantis root directory

Changelog:
Mar 2010 - EmailReporting-0.7.8

  • EmailReporting is now officially compatible with 1.2.0
  • Some code improvements for the mail_add_bug function
  • When EmailReporting removes a mantis reply, it will now add a text to notify that it has been removed
  • Subprojects were not properly selectable for setup with a mailbox
  • Empty bugnote emails will no longer be added to the issues. The attachment in those emails (if present) will still be added
  • limit_email_domain will now be adhered to. Any from email addresses not accepted by this setting will be ignored and deleted
  • Some small note corrections in emailreporting.php
  • Further updated the separated README and CHANGELOG
  • Removed libregeek's regular expressions for incoming email address functionality as limit_email_domain should be used
  • Reverted libregeek's undocumented changes to scripts/bug_report_mail.php as they could cause problems for cronjobs in specific situations
    Feb 2010 v3 - EmailReporting-0.7.7
  • Reverted the change of version 0.7.6 (libregeek)
  • Separated README and CHANGELOG (libregeek)
    Feb 2010 v2 - EmailReporting-0.7.6
  • If the incoming email address is present in database then update the corresponding user_id in mail_get_user(). This is true even if 'mail_use_reporter' is set (libregeek).
    Feb 2010 - EmailReporting-0.7.5
  • Configuration parameter to specify regular expressions for incoming email address (libregeek).

SL-Gundam

scaranol

scaranol

2010-02-27 15:48

reporter   ~0024564

I am getting the following when I test my mailbox:

Operation NOT successful

Mailbox description: GMail
Mail server type: IMAP
Mail server hostname(:port): smtp.gmail.com:993
Mailbox connection encryption: SSL
Mailbox username: myemail@gmail.com
Mailbox password: **
Authentication method: USER
Mailbox basefolder (IMAP): Teamtrack

[pear_error: message="not connected! (CMD:LOGIN)" code=0 mode=return level=notice prefix="" info=""]

I tried recreating the mailbox from scratch and got the same.

SL-Gundam

SL-Gundam

2010-02-27 17:32

reporter   ~0024565

I just tested this on my gmail account (using EmailReporting 0.7.8) and it works without issues. I also see nothing wrong with the way you set up the mailbox. The hostname should officially be imap.gmail.com but from tests it seems smtp.gmail.com works as well

The error suggests a problem with making a connection to the imap server

Is it possible the server where your mantis installation is running, is not allowed to make outgoing connections to port 993?

SL-Gundam

scaranol

scaranol

2010-02-28 10:33

reporter   ~0024569

I have a server setup primary for database hosting, but also for cron jobs. It seems to work fine on there, so I'm happy. I could have sworn it was working on my Win2003 servers before, but then I went back to 0.7.5 and got the same error so maybe I just didn't document where I was running it from very well. Anyway, thanks for all the support. Great work on this plugin.

SL-Gundam

SL-Gundam

2010-02-28 15:21

reporter   ~0024570

Last edited: 2010-02-28 15:25

Another new version as there were some bugs that needed fixing: MantisBT-1.2.0_plugin_EmailReporting-0.7.9.rar

If you enabled the new functionality for email address checking, all emails would have been rejected most likely. This is because instead of checking the email address, an array was passed to the email_is_valid function. This is now fixed.

NOTE: i forgot to update the version number from 0.7.9-DEV to 0.7.9. This will not cause any problems. So the next time a version is released by someone it will be either 0.8.0 or 0.7.10.

Mar 2010 - EmailReporting-0.7.9

  • All from email addresses will now be checked by the email_is_valid function before a email will be processed
  • Updated readme based on new functionality
  • EmailReporting will now show an error when a email address is rejected.
  • Fixed a bug with the email address that was given to email_is_valid for checking
  • removed the email_is_valid check from the mail_get_user function as it does need to be checked twice

SL-Gundam

libregeek

libregeek

2010-03-01 01:36

reporter   ~0024573

Thanks to SL-Gundam for reviewing the code and suggesting better implementation for limiting email domains.

My idea was not entirely based on email domains. Some of our partner companies uses email address in the format firstname.companyname@gmail.com. I know that we can use our own domains in gmail, but those companies don't need to bother about the email management and their policy is not to provide official email address to their temporary employees. It seems weird, but it's the way it works. My concern was to address such issues also because we are providing mantis support to such small companies. In this case 'limit_email_domain' doesn't work and a regular expression is the ideal solution, even though it needs some developer intervention.

The folder renaming was a mistake from my part and I'm sorry for this.

It would be nice to use an Open Standard compression utility(such as gzip or bzip) to package the module. RAR is a proprietary format whichn is not an ideal format for a FOSS project (http://en.wikipedia.org/wiki/RAR). In addition, it is causing too much problems in GNU/Linux based systems. Each time I download this package, I have to manually copy them to it's corresponding folders. Please see the attached screenshot

libregeek

libregeek

2010-03-01 05:14

reporter   ~0024577

I have created a repository in git.mantisforge.org for EmailReporting plugin. Please visit http://git.mantisforge.org/w/EmailReporting.git

Please note that I'm still learning Git from http://www.kernel.org/pub/software/scm/git/docs/user-manual.html , So please guide me if I'm doing something wrong.

I request all the contributors here to create an account in git.mantisforge.org(if you don't have an account) and post your username here. I can then add your name to provide you commit access.

Since the plugin works well with the latest mantis(1.2.0), I request the developers to close this ticket and do all the future customisations in Git.

SL-Gundam

SL-Gundam

2010-03-01 11:19

reporter   ~0024581

@libregeek 0004286:0024573
In my opinion, limit_email_domain is still the right solution. If it does not suffice, then mantisbt developers need to enhance the functionality behind it. I don't think we should build the functionality directly in EmailReporting like you did. But thats just my opinion.

@libregeek 0004286:0024577
Nice libregeek. Are there any graphical solutions (that work on windows 7) to manage the git repository?

libregeek

libregeek

2010-03-02 00:22

reporter   ~0024583

@SL-Gundam:
I agree with you regarding limit_email_domain. I was just explaining an use case in our client scenario.

You can find several GUI here:
http://git-scm.com/tools
http://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools#Graphical_Interfaces

But I haven't used any of them, since commandline is the best tool for me :)

obones

obones

2010-03-03 07:38

reporter   ~0024608

Hello,

I just installed this plugin and I must say I'm very thrilled. It works great and was very easy to setup.
One thing though that I did not find is a way to tell the plugin to email back an aknowledgment email when it has processed a received email.
For instance, when a new issue is reported, an email is sent to the reporter with the issue number and a link to it.
Same goes when replying via email.
I know I can configure mantis to mail on self actions, but I would like to avoid this. I only want self notification when acting via this email plugin.

Is this possible? If yes, how?

Thanks for your help
Olivier

ch750536

ch750536

2010-03-03 09:06

reporter   ~0024609

Last edited: 2010-03-03 09:09

Quote from above...
...During this i found out that there is a possible problem with setting up a cronjob on linux systems.
This problem consisted of not being able to find the core.php file in the mantis root directory.
I applied a fix for this in EmailReporting 0.7.4 just a day after i released 0.7.3.
Anyways it comes down to this. If you have problems setting up the cronjob because its failing with errors that it could not find core.php in bug_report_mail.php on line 5, please let me know. I will prepare 0.7.4 for release if more people have problems with this, otherwise i'm going to wait a bit more until the changelog for that version has grown a bit bigger.
SL-Gundam
END QUOTE++++++++++++++++++++++++++++

Just downloaded Changelog:
Mar 2010 - EmailReporting-0.7.9
I have this issue.
Hosts sent me a response of :
A: Hi,
The problem is with the code, here's the message being generated:
[03-Mar-2010 13:29:43] PHP Fatal error: require_once(): Failed opening required 'core.php' (include_path='.:/hsphere/shared/apache/libexec/php5ext/php/') in /hsphere/local/home/ch750536bug/<myURL>/mantis/plugins/EmailReporting/scripts/bug_report_mail.php on line 17

My job is:
/usr/share/wget -v --delete-after http://&lt;myURL>/mantis/plugins/EmailReporting/scripts/bug_report_mail.php

Line 17 is
require_once( ( ( isset( $GLOBALS[ 't_dir_emailreporting_adjust' ] ) ) ? $GLOBALS[ 't_dir_emailreporting_adjust' ] : '' ) . 'core.php' );

obones

obones

2010-03-03 11:02

reporter   ~0024612

Well, answering myself here, I did it this way :

Add the following at lines 701 and 758
config_set('email_receive_own', ON);

and the following at lines 712 and 760
config_set('email_receive_own', $g_email_receive_own);

(line numbers adjusted after each add)
This works quite well for my usage.
Ideally the first line where it sets it to "ON" should have a test that reads the plugin configuration

SL-Gundam

SL-Gundam

2010-03-03 12:21

reporter   ~0024615

@obones, currently not (yet) possible with this plugin. It listens completely to mantis config settings. Unless you hack it like you did now

@ch750536, libregeek placed the wrong file in /scripts/bug_report_mail.php. Please download MantisBT-1.2.0_plugin_EmailReporting-0.7.9.rar found in this issue

ch750536

ch750536

2010-03-03 16:11

reporter   ~0024616

Worked a treat, thanks.

obones

obones

2010-03-04 03:26

reporter   ~0024622

Thanks, that confirmed what I thought. I'll keep watching for new versions.
A few other remarks though:

  • It would be nice if the "reply marker" would be configurable. Right now it uses the value of email_separator1 in the configuration. But the email clients we are using here almost always add a few lines before that marker.
    My idea would be a configurable value that is replaced by email_separator1 if not filled in.

  • I left the default configuration in place where it fetches one mail at a time and deletes it immediately from the POP mailbox. This works well most of the time, but in 24 hours it already happened twice that the email is not deleted. When this happens, the fetch script loops indefinitely on the same email, adding a note again and again to the same bug. Is this something known? If yes, how to solve this?

Regarding the second remark, I would have thought that email IDs would be saved in a table (or a file) to indicate which have already been processed. Otherwise, how could the plugin know if an email has been processed when not deleting them from the mailbox?

Once again, thanks for the great work.

obones

obones

2010-03-04 08:42

reporter   ~0024637

Well, ok, my bad, point two is my fault as I forgot to add "global $g_email_receive_own;" just before the config_set calls. This lead to invalid update queries made to the database.
Point 1 is still valid though.

SL-Gundam

SL-Gundam

2010-03-04 12:40

reporter   ~0024639

libregeek has fixed the problem with /scripts/bug_report_mail.php in the git repository. So from now on people can use the git repository to download the plugin, if they wish.

SL-Gundam

SL-Gundam

SL-Gundam

2010-03-04 12:52

reporter   ~0024640

Last edited: 2010-03-04 20:07

@obones. The reply removal functionality has been specifically set up to remove original mantis notification emails from reply's, not to remove all reply's in the email. I'm still trying to figure how best to set up complete removal of all reply's. But i have not found a satisfying solution (not yet anyway)

About the email ids. It's functionality i never really looked at as i did not use it. But i'll test it and see what happens and possibly make corrections if required.

SL-Gundam

SL-Gundam

SL-Gundam

2010-03-04 20:28

reporter   ~0024644

About the email ids.

In my pop3 tests with delete mail setting disabled. The email was only processed one time. It seems to only process unread emails. After an email is processed it is automatically marked as read. IMAP does not offer this functionality though

So if you sent an email to a email address and mark the email as read using imap or webmail, it should not be processed by the EmailReporting plugin if you are using pop3. IMAP on the other hand will keep on importing the same email over and over.

I'll see what i can do to improve it for IMAP, but don't expect a fix very soon though

obones

obones

2010-03-18 07:12

reporter   ~0024795

Thanks, I'm using pop3 so it's fine with me.
Another idea that came to mind:

Assign the category according to keywords in the subject line

Basically, the idea would be to have a regular expression that if matched indicates which category to use for the newly created issue.
And then a list of such regular expressions so that multiple keywords can be parsed to set different categories.
I'm currently setting up a system where I'll need this, I'll try to code it and send it here but if you beat me to it, I'm sure it will be done more in the spirit of the plugin

Andi3938

Andi3938

2010-03-18 21:53

reporter   ~0024802

Is there a way to use the email report only for adding notes? Creating a bug should processed through the mantis forms. If an email with an unknown issue # is received the email will be discarded.

Furthermore here is an idea for keeping out spam mails:

  • There should be a possibility to only process an email from an registered User. Compare email address with the database users ones (mantis core user_api: user_get_id_by_email($p_email).
  • This spotted user id could also be used for assigning an proper user to a note.
alitvak

alitvak

2010-03-19 00:52

reporter   ~0024805

@obones,

Which file did you use to add your auto reply hack?

obones

obones

2010-03-19 04:07

reporter   ~0024809

@ativak: That was in core/mail_api.php

SL-Gundam

SL-Gundam

2010-03-19 16:35

reporter   ~0024823

Last edited: 2010-03-19 16:43

@obones. Personally i think its more logical to just create multiple email addresses where users can email to. You can create multiple mailboxes in emailreporting that are connected to the same project but if you select a different category for every added mailbox you will have the same effect. This is in my opinion more user friendly for people using it.

@Andi3938. Currently only adding notes is not possible. But you could create a trash project were emails without a valid issue id would be imported. If you make the project invisible you only need to empty it every now and then. I'll see if i can add a good methode for this in the next version. Also the second requested feature is already present in EmailReporting. Just adjust the the configuration options on the "EmailReporting configuration" page (reachable from within the "mailbox settings" page and from within the "manage plugins" page)

@obones and alitvak. That fix will move the configuration for email_receive_own to the database. Keep that in mind. It might also be smarter to use config_set_cache to only set it in the current page request

obones

obones

2010-03-19 17:50

reporter   ~0024824

We actually already have multiple addresses, one per "department" that can post issues.
If we were to create addresses per keyword inside those departments, that would actually make it harder on the users because they would have to remember which email address they have to write to.
We want to keep it simple so that someone from accounting writes an email to support-accounting@ourcompany.com and then the subject helps deciding which category it falls into.
The category (and tags) is only of use to us, at support, but the reporters don't need, nor do they want, to know our internal classification system.

SL-Gundam

SL-Gundam

2010-03-19 21:25

reporter   ~0024826

I can see why that would be usefull in your situation. I'll be looking forward to your implementation of the idea.

cas

cas

2010-03-22 10:46

reporter   ~0024842

Last edited: 2010-03-22 10:55

SL_Gundam,
can you add a facility to have the duedate filled based upon a number of configurable days?
Following code should be catering for this:
if ( ON==plugin_config_get( 'preset_duedate')) {
$f_due_date = time()+ (plugin_config_get('preset_duedate_days') 24 60 * 60);
} else{
$f_due_date = date_get_null();
}

SL-Gundam

SL-Gundam

2010-03-22 19:01

reporter   ~0024853

I'll add it to my todo list (unless somebody else adds the functionality before me of course)

But i think we could expand that idea to some ideas that were already mentioned where you can set up different rules on which certain actions are applied on received emails. For example (rough rule set idea):
IF [email_description] CONTAINS "abcd" ASSIGN_TO [certain_user]
IF [all_emails] SET "due_date" = "dd-mm-yyyy"
etc.

This way people can set their own parameters which they can use in emails. Which should satisfy other requests mentioned in earlier notes aswell

But this functionality would require considerable work if we want to maintain a user friendly interface. Also this is just my idea on a possible implementation so if anybody else has other ideas on how to do this please post them here so we can discuss them

obones

obones

2010-03-24 04:37

reporter   ~0024892

Well, I feared it would be complicated to store the configuration but it was definitely easier than I thought.
Please find the modified files in the attached archive. The modifications were made to the files as they were in the latest plugin zip posted here.
Hope this helps

libregeek

libregeek

2010-03-24 04:49

reporter   ~0024893

@obones:
Please use the git repository. You can create your own private branch and once it is tested we can merge it with the trunk.

http://git.mantisforge.org/w/EmailReporting.git

obones

obones

2010-03-24 05:19

reporter   ~0024894

Ok, done, hope this is ok

obones

obones

2010-03-29 05:00

reporter   ~0024918

Just done another commit that allows sending bug notes to projects that have accented characters in their name.
Without it, it creates a new issue instead of adding a bug note.

libregeek

libregeek

2010-03-29 06:15

reporter   ~0024919

@obones
If the changes are tested and works fine, then please push your changes to git.mantisforge.org.

obones

obones

2010-03-29 09:49

reporter   ~0024924

Well, they work fine on my server, but I have no idea if they work on a non UTF-8 environment.
As to the other changes, related to automatic category by subject, well, I'd rather have someone review them before they are pushed to the trunk.

phoenixcreation

phoenixcreation

2010-03-31 08:22

reporter   ~0024980

Good morning all!

I'm working on getting some Mantis upgrades rolled out here internally at my company and have a few questions about this one before I start on it. I've gone over most of the messages above all the way back to beginning, but some of the code is above my head. OK, most of it is, hehe. :)

Functionality wise, does this do the following at present:

  • Allow for pulling responses to bugs from a group e-mail box on an Exchange server
  • Does the response that is posted to the bug just include the new info, or does it include everything in the e-mail (all the old stuff)

Primarily we need to use this so that some of us can respond to bugs from our blackberries rather than having to log into mantis each time. Would not need to create new issues so much (use Mantis forms as mentioned above).

As a note: I'd be interested in having this added to core functionality if desired, and can have company work with the consulting group to get online. Just a thought there. I have a message into the MantisBT group on a few other items as well.

SL-Gundam

SL-Gundam

2010-03-31 13:36

reporter   ~0024989

currently EmailReporting allways imports the emails without modifications except for the possible removal of original mantis notification emails.

So if two people are emailing eachother back and forth and CC the mailbox from which EmailReporting retrieves emails during the whole session, then that will create new issues over and over unless all of those emails contained a issue id. Then all of those emails will imported in that issue.

But if people just reply to mantis notification emails then there should not be any problems.

phoenixcreation

phoenixcreation

2010-04-03 14:40

reporter   ~0025010

Sounds good Gundam. Another question:

But if people just reply to mantis notification emails then there should not be any problems.

So if I respond to a notification e-mail, hitting the reply, and my response includes all the notification text (bug information, bug notes, bug history, bug relationships), will all that text be added into the new note, or is that stripped?

Thanks very much!

obones

obones

2010-04-03 14:51

reporter   ~0025011

There is an option to strip it. Install the plugin in a test environment, you'll be able to get a better grasp of what it does and what it does not.

obones

obones

2010-04-06 08:48

reporter   ~0025040

I've worked a bit more on this plugin and noticed that the call email_notify_new_account never returns and that the email is not deleted and added as a bug until the next time interval as elapsed for the cron task.
So for now, I have disabled it, especially because I don't need it, but someone should try to find out why it does not work.
I also have added two new options to the plugin so that it can now use the email as the username (optionally stripping the domain name) and use the previous username as the realname.
Imagine an email comes through with this value for the "From" field:

John Doe <j.doe@company.com>

Currently, it will create a user whose user name is "John Doe" and whose email is "j.doe@company.com" without a real name.
In my case, I'm authenticating users using LDAP so all users actually have an account of the form j.doe
This means that they will have two accounts, one created via email, one created the first time they connect to Mantis. To me, this is not desirable, so I added the two options. With those them set to YES, the same email comes through but the following account is created:

user name = j.doe
email = j.doe@company.com
real name = John Doe

This makes it much more friendly to my users who now have a single account, no matter where they post their bugs from.
I'm not sure I did things properly for the GIT public repository to see my changes, so I'm posting the patch file attached here, generated from the command line suggested on this page:

http://www.mantisforge.org/dev/manual/en/developers/dev.contrib.submit.html

Hope this is good.

filmerkl

filmerkl

2010-04-08 11:17

reporter   ~0025072

Hi all,

I have recently installed Mantis plus the mentioned plugin, the whole configuration is:

  • system Windows 2003 Server
  • MySQL db version 5.1
  • Mantis 1.2.0
  • plugin Email reporting 0.7.9-DEV

The thing that is important to me is for all the users to be able to create issues in Mantis by sending email. I have installed and configured everything according to documenation and it works - well, most of the time: I have one problem I haven't been able to solve. The problem I need help with concerns automatization: everything works if I manually get emails from POP3 account to mantis using webserver, but it sometimes crashes when I try the other method - to schedule a job with php.exe running the script.

Details:

  • documentation says that you can either via webserver or via commandline with php.exe
  • via webserver you can do it manually just clicking "/plugins/EmailReporting/scripts/bug_report_mail.php" link or you can set up mantis to do it everytime someone visits the page
  • you can also create a batch with php.exe running the very same php script and schedule it as a reapating tasks
  • with simple mails all the methods above works
  • with some mails, html ones with mime content and footnote, the only method that works is to manually click link on the page; if you do so, the mail is parsed and the image from the footnote is treated as attachment and becomes properly a part of mantis issue; however if you don't do it manully but instead you choose the option that makes mantis webserver to do it triggered by the site visit you can see "SYSTEM WARNING: fsockopen() [function.fsockopen]: unable to connect to 10.0.253.34:0 (Failed to parse address "10.0.253.34")" on the screen; if leave the job to commandline job, you get:
    C:>c:\php\php.exe c:\Inetpub\wwwroot\mantis\plugins\EmailReporting\scripts\bug_
    report_mail.php
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.or [^]
    g/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="C:/Inetpub/wwwroot/mantis/c
    ss/default.css" />
    <script type="text/javascript" language="JavaScript"><!--
    if(document.layers) {document.write("<style>td{padding:0px;}<\/s
    tyle>")}
    // --></script>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Pragma-directive" content="no-cache" />
    <meta http-equiv="Cache-Directive" content="no-cache" />
    <meta http-equiv="Expires" content="Thu, 08 Apr 2010 12:40:06 GMT" />
    <link rel="shortcut icon" href="C:/Inetpub/wwwroot/mantis/images/favicon
    .ico" type="image/x-icon" />
    <link rel="search" type="application/opensearchdescription+xml" title="M
    antisBT: Text Search" href="http://helpdesk.orbistravel.pl/browser_search_plugin [^]
    .php?type=text" /> <link rel="search" type="application/opensearchdescripti
    on+xml" title="MantisBT: Issue Id" href="http://helpdesk.orbistravel.pl/browser_ [^]
    search_plugin.php?type=id" /> <title>MantisBT</title>
    <script type="text/javascript" src="C:/Inetpub/wwwroot/mantis/javascript/min/com
    mon.js"></script>
    <script language="javascript">var loading_lang = "Ładuję...";</script><script
    type="text/javascript" src="C:/Inetpub/wwwroot/mantis/javascript/min/ajax.js"></
    script>
    </head>
    <body>
    <div align="left"><a href="my_view_page.php"><img border="0" alt="Mantis Bug Tra
    cker" src="C:/Inetpub/wwwroot/mantis/images/mantis_logo.gif" /></a></div>
    <
    div align="center"><table class="width50" cellspacing="1"><tr><td class="form-ti
    tle">APPLICATION ERROR 0000401</td></tr><tr><td><p class="center" style="color:red"

    B┼é─ůd wykonania zapytania w bazie danych 1366 ÔÇô Incorrect string value: '\xB
    3obuck...' for column 'description' at row 1 dla zapytania INSERT INTO mantis_bu
    g_text_table

                                        ( description, steps_to_reproduce, a

    dditional_information )

                                      VALUES
    
                                        ( ?,?,?).&lt;/td>&lt;/tr>&lt;tr>&lt;td>&lt;p cl

    ass="center">Prosz─Ö u┼╝y─ç przycisku ÔÇ×WsteczÔÇŁ w przegl─ůdarce by powr├│ci─ç
    do poprzedniej strony. Tam mo┼╝na poprawi─ç to co spowodowa┼éo b┼é─ůd lub wybra
    ─ç inn─ů operacj─Ö. Mo┼╝na r├│wnie┼╝ klikn─ů─ç opcj─Ö w g├│rnym menu, aby przej┼
    Ť─ç bezpo┼Ťrednio do innej sekcji.</td></tr></table></div></body>
    </html>

plz hlp anybody because there is no info on the web...

SL-Gundam

SL-Gundam

2010-04-08 13:11

reporter   ~0025073

Last edited: 2010-04-08 13:30

Ah i see the problem.

It will be fixed in 0.8.0. But that version is currently under development and it will take me some time to finish it.

For the moment i advise you to setup a scheduled job like was mentioned in readme and not use the alternative method which you have currently enabled.

Basically this means that the windows task scheduler must run the following command (adjust directories for your installation):
"c:\php\php.exe c:\path\to\mantis\plugins\EmailReporting\scripts\bug_report_mail.php"

Now to disable that setting i mentioned, set the following setting to "Yes" in the configurations options: "Have you (or will you) set up a cron / scheduled job for retrieving emails (recommended = Yes)"

For the second problem with the commandline script, you need to adjust the mail_encoding setting in the configuration options. It needs to be the same as your database charset.

I think that should fix your problems... if not let us know

SL-Gundam

filmerkl

filmerkl

2010-04-09 03:38

reporter   ~0025080

Last edited: 2010-04-09 07:32

hello,

thank you for your answer

the problem is connected to charset/collation - because the problem mails are those who contains polish language specific chars
still I don't understand it:

  • I've checked all settings and it seems ok, Mantis plugin is set to UTF8, so is MySQL server and the database
  • why does it work properly when I run script from the website using link?

plz hlp

regards,
Filip

SL-Gundam

SL-Gundam

2010-04-09 07:38

reporter   ~0025087

alright the it might be something thats in the email which causes the error

Do the following

Enable debug mode in EmailReporting and make sure that the complete email is written to the debug directory.

The file that created should be formatted more or less like this: [unix timestamp]_[md5 hash].

That file contains the complete email before it is parsed.

If you succeed at creating that file, we just need to get that file to me so that i can debug the problem and hopefully fix it.

SL-Gundam

filmerkl

filmerkl

2010-04-09 08:15

reporter   ~0025088

Last edited: 2010-04-09 08:19

ok I did that - how can I provide you with that file?
if it helps to speed up the process plz contact me at both:

  • filip.merklejn AT orbistravel.pl
  • filip.merklejn AT gmail.com
    the first account is my corporate account, the 2nd is a private one so that I get it even if i'm out of office
    thanks
SL-Gundam

SL-Gundam

2010-04-15 15:18

reporter   ~0025134

Last edited: 2010-04-16 11:00

Well filmerkl's problem has been fixed, though it required him to reinstall his software on a different machine. I don't suspect it to be a problem in EmailReporting, but rather in mysql configuration files... but since it was fixed by him we did not investigate any further

@obones 0004286:0025040. I could not reproduce your problem with the email_notify_new_account function. Please try to find the reason it stops working for you. An error would help to investigate it further.

Also everyone.

http://git.mantisforge.org/w/EmailReporting.git - Now shows historical releases but also contains in progress work. If you grab a release from there make sure you get the right one as in progress work is more susceptible to bugs.

Stable releases will still be posted in this issue

SL-Gundam

obones

obones

2010-04-16 03:02

reporter   ~0025135

@SL-Gundam 0004286:0025134 : I'm not quite sure why it fails, maybe it's because I don't have anyone that wants to get notified, and that I'm using LDAP to authenticate users. I'll see what I can do, but it's not at the top of my priority list.

SL-Gundam

SL-Gundam

2010-04-19 17:29

reporter   ~0025158

Last edited: 2010-04-20 11:13

Notification of removal of functionality

Hi everyone

I'm still very busy with version 0.8.0

One of the changes will be the removal of functionality introduced by me in EmailReporting 0.7.3

To be specific, this change (from changelog): Scheduling bug_report_mail as a cron / scheduled job is not required anymore, but is recommended and EmailReporting default configuration assumes you have / will set one up.

The alternative method i created had one bug which i fixed in 0.8.0-DEV but i also found out that the functionality has serious problems compared to the normal method.

Its limitations (some also apply to other scheduled solutions that would call bug_report_mail through the webserver) have forced me to remove the functionality as its just not practical. The limitations are among other things

  • Maximum execution times of scripts
  • Timeouts of webserver when above max execution times are overwritten with infinite values
  • Maximum memory usage allowed for the script
  • Tying up a single random request for as long as bug_report_mail needs to run

The execution time is the important one because the script looses most of its time retrieving data from the mailboxes. A single 12mb to 17mb email could easily take up 45 seconds of running time and 128mb of memory.

I advise everyone that uses this functionality to try to find a solution so that you can run bug_report_mail as a properly scheduled job.

Personally i don't think anyone actually used it as the bug that has been in it would have only made it work if you used a non-standard http / https port for your webserver

SL-Gundam

SL-Gundam

SL-Gundam

2010-04-20 17:00

reporter   ~0025167

Last edited: 2010-04-20 17:11

@obones. During some testing of another problem i actually ran into your problem with email_notify_new_account. It's actually a bug in the email_api.php of mantis itself but its correctible by just filling a certain variable with a value (0011818).

It all depends on how you handle notice errors. If notice level errors halt your mantis installation from further processing the script then your problem will show itself.

Since most production environments do not halt on notice level errors there are no problems for most users, most development environments on the other hand show and halt on any errors including notice level errors.

I will fix this for 0.8.0

SL-Gundam

alitvak

alitvak

2010-04-22 12:12

reporter   ~0025201

Just a suggestion. Can we move this issue discussion to a forum that allows truncating older notes or perhaps we could delete at least half of the notes here. I don't think anything older then 2009 is relevant for the current discussion.

SL-Gundam

SL-Gundam

2010-04-22 14:59

reporter   ~0025208

The rules system idea has been scrapped... at least for the moment.

The reason for this is that while i was busy with 0.8.0, i also added code which would allow other plugins to hook themselves into the emailreporting plugin. See the calls below. These calls are the same ones also used for the creation of normal bug reports

Allow plugins to pre-process bug data

$t_bug_data = event_signal( 'EVENT_REPORT_BUG_DATA', $t_bug_data );

Possibly for use with extra notifications creation

helper_call_custom_function( 'issue_create_notify', array( $t_bug_id ) );

Allow plugins to post-process bug data with the new bug ID

event_signal( 'EVENT_REPORT_BUG', array( $t_bug_data, $t_bug_id ) );

This should allow other people to create their own adjustments to the created bug reports using there own plugins or plugins created by other people.

Since this would allow the more experienced people endless amounts of adjustability, i thought it would be better then a rule system which could very well be too limited and clutter up the interface.

If ever i still get the silly idea to create the rule system. It will be created as a new plugin which requires the EmailReporting plugin

@cas. This might be something you can connect to your Reminder plugin and also get your due_date the way you want it. I'm actually planning on having a look at that plugin and possibly use it within the IT department where i work.

@obones. Please also try to implement your categorybysubject idea using this method. The LDAP problem you had with user account creations will be fixed in 0.8.0

SL-Gundam

obones

obones

2010-04-23 05:57

reporter   ~0025229

@alitvak: I agree with you, it would be nice to be able to post bug requests in the "EmailReporting" category.

@SL-Gundam: Nice idea to have plugins in here as well. I'll wait for 0.8.0 to come out and will experiment with this. There would be a need for an event that allows to add elements in the configuration page though.

One other thing that should be considered: Do not store the attached files directly but rather call a webpage to do the storage for us. This would solve those two problems:

  1. One has to duplicate the function from Mantis because it assumes files are uploaded via a POST form
  2. The user which created the files is the one the script has been run under cron, which might not be the same as the one the web server runs as. The latter one might not be able to have a cron table.

That special webpage could be one from the plugin package itself, thus allowing to call it without being authenticated but restrict its usage from localhost for instance.

The "Source" collection of plugins by John Reese has such a script with similar restrictions for importing the latest changesets from a source repository

SL-Gundam

SL-Gundam

2010-04-23 12:18

reporter   ~0025235

@obones. Added configurations will require a configuration page within your own plugin. If that causes problems please let me know and we'll discuss whats needed to fix it

EmailReporting uses the exact same method for file uploads as mantis bt does and therefore supports all different methods (disk, database, ftp). But for disk a small fix was required before it would work. Thats the reason for custom_file_api.php

Concerning the Cron user i'm exactly sure on how to fix problems like that. Largely because i use a windows server

SL-Gundam

SL-Gundam

SL-Gundam

2010-04-23 12:27

reporter   ~0025236

Last edited: 2010-04-23 12:31

Well here it is: MantisBT-1.2.0_plugin_EmailReporting-0.8.0.rar

My todo list is empty again.

You can get the new version from: http://git.mantisforge.org/w/EmailReporting.git
But you can also find it in the attachments to this issue

Biggest changes:

  • Revised interface
  • "Copy mailbox" action added
  • mail_delete works for IMAP
  • mail_fetch_max works properly for IMAP
  • At least 20% less memory required
  • IMAP Basefolder is now optional incase you want to use the inbox folder of your IMAP mailbox
  • Extra option to remove all replies from emails
  • Functionality has been added which optionally temporarily enables email_receive_own during the current session
  • 2 new options with which you can enable or disable the adding of bugnotes and bugs
  • New configuration option which allows you to select a preferred username for new user creations

Changelog:
Apr 2010 - EmailReporting-0.8.0

  • Improved the mailbox settings page
  • Improved the plugin configuration page
  • Improved the changelog a tiny bit
  • Updated the readme with upgrade instructions
  • "Mailbox settings" page is now called "Manage Mailboxes". This includes the filenames, maintainmailbox is now called manage_mailbox
  • "Configuration" page is now called "Manage Configuration Options". This includes the filenames, config is now called manage_config
  • PEAR files are now located in the core_pear directory. This way they can be easily removed if you don't need them.
  • New user creation emails from EmailReporting now also contain a proper urls
  • "Copy mailbox" action is now available for mailboxes
  • Various textual corrections and improvements
  • mail_delete option now works for IMAP. Emails will be marked as deleted but not expunged when this option is disabled
  • Removed redundant config_get for limit_email_domain
  • Fixed a possible error with content-transfer-encoding index missing in parser.php
  • Fixed neglecting of properly closing connection to the IMAP server during the testing of mailboxes
  • Fixed a bug in the mail_parse_address function concerning the usage of a wrong index name when no name was found in the from part of the email
  • New EmailReporting menu above every EmailReporting page
  • Attachments will only be added if allow_file_upload is turned ON
  • Debugging of the alternative method for running bug_report_mail at scheduled intervals has been improved
  • Updated the plugin description on the manage plugins page. It now includes the git.mantisforge.org link
  • Added changelog page to the EmailReporting menu in mantis
  • Added readme page to the EmailReporting menu in mantis
  • All of the function names are now prepended by "ERP" (Email Reporting Plugin), sometimes replacing the already present "mail"
  • The ERP_update_check function will now check whether or not it needs to perform some updates to the configuration options
  • Some configuration options that were no longer used but could still be lingering in the database will be removed by ERP_update_check
  • The mail_reporter setting will now be saved using the user_id instead of the username
  • The setting mail_reporter is now called mail_reporter_id
  • The setting mail_directory is now called mail_debug_directory
  • Removed the require_once for core.php from pages/bug_report_mail.php
  • A set of settings for a mailbox will only contain those required for the selected mailbox_type
  • Improved IMAP and POP connection and error handling
  • Mail_fetch_max now works properly for IMAP when mailbox_createfolderstructure is enabled
  • Removed default values for configuration options in pages/manage_config_edit.php
  • Removed default values for mailboxes in pages/manage_mailbox_edit.php
  • Adjusted the amount of times email_separator1 needs to be found from 3 to 5
  • Added IPv6 support
  • Testing a mailbox now shows default ports used if you did not fill any in
  • Fixed an error which occurs if you try to perform an action on a mailbox that no longer exists
  • Changed the random number generator for user creations from mt_rand( 4, 5 ) to mt_rand( 1000, 99999 )
  • mail_get_mailboxes function removed as it outlived its function
  • Mailbox encryption features now only available if PHP OpenSSL extension is available
  • Fixed a problem with a missing port number when using the alternative method to running bug_report_mail (0004286:0025072)
  • Updated readme with "Partial support" notice for Outlook RTF formatted emails
  • Improved functionality when using IMAP in combination with the inbox folder as the basefolder
  • mail_api.php has been restructured to form a class
  • Improved email_is_valid check with caching (only for the current session).
  • Email_is_valid will only be performed when the Mail Reporter is used or on a new user creation
  • Optimized the Mail_Parser a little bit
  • Configuration option mail_bug_priority_default has been removed. The default_bug_priority from the core mantis configuration options will be used instead
  • bug_report_mail is now allowed to run for as long as it needs
  • Default configuration option for mail_tmp_directory is php.ini option upload_tmp_dir if available else it will revert to the old value /tmp
  • The regular expression for the bugnote check now accepts all characters for the project names
  • Removed useless CVS $id$ tags in three files as git can not use them
  • Updated the add_bug function to be more like its counterpart in bug_report.php including plugin hooks
  • Improved the mail_is_a_bugnote function. Now only one regex is needed
  • A new functionality has been added which optionally removes all replies from emails
  • A new functionality has been added which optionally temporarily enables email_receive_own during the current session
  • 2 new options with which you can enable or disable the adding of bugnotes and bugs
  • Added a new option to disable the fallback to the mail reporter account
  • The PHP memory limit is disabled when bug_report_mail is running.
  • When debug mode is enabled the memory usage of the mail_api will be shown at specific moments of processing
  • Mailboxes can be disabled
  • Memory usage optimized (~20% less memory required)
  • Debug mode will no longer show the parsed email contents. They will be saved to the debug directory in a file just like the raw email contents
  • Removed the alternative method to running bug_report_mail as a scheduled job.
  • Applied a fix for bug 0011818 (0004286:0025040)
  • Besides the reporter id and email, bug_report_mail now also shows the bug_id where the actions were performed
  • Found existing users must have an enabled account
  • mailbox_project is now called mailbox_project_id
  • mailbox_global_category is now called mailbox_global_category_id
  • mail_identify_reply is now called mail_remove_mantis_email
  • Parse MIME setting removed. It was useless as simply parsing the raw message already costs much more memory then processing subparts in the message
  • bugnotes to readonly issues will now generate a new bug report with a bug relation to the readonly issue
  • New configuration option which allows you to select a preferred username for new user creations
  • User creations with long usernames longer then 32 characters have been fixed

SL-Gundam

obones

obones

2010-04-26 09:24

reporter   ~0025269

I just tested the 0.8.0 version and I must say that I'm very please with the quality of this release. Most of my customizations are now obsolete, this is very great.
There are, however, a few issues:

  • The added events are pretty much useless because they are the generic ones. As such, they do not allow to do any processing based on the subject, for instance. For this to work, there must be some events declared by EmailReporting itself that other plugins can use.

  • Adding parameters that are specific to a mailbox is not possible because one cannot plug into the load/save/display steps used by the plugin. Once again, there is a need for custom events that others can plug into.

I have thus modified the EmailReporting plugin to have its own events, and I used them to create my own plugin that does the category by keyword processing.
The attached file is a patch to apply to 0.8.0 that does all this.

Regards
Olivier

SL-Gundam

SL-Gundam

2010-04-26 10:32

reporter   ~0025272

Events based on subject are possible by using the generic events and the $t_bug_data->summary which is always the subject

I will have a look at the second part (and your patch)

SL-Gundam

obones

obones

2010-04-26 11:28

reporter   ~0025273

Yes, but summary was just an example. Having access to the whole data means that one can do whatever he can think about and not be limited to what is inside the BugData structure.

obones

obones

2010-04-27 02:53

reporter   ~0025281

Just uploaded my plugin that uses those new events.
One more thing about the specific events: The generic ones are triggered for any bug that is about to be added. I wanted an event that gets triggered only when a bug from an email is about to be added.

obones

obones

2010-04-27 07:12

reporter   ~0025288

@SL-Gundam:
You said you are a Windows guy which explains why the current 0.8.0 version does not allow to edit the configuration properly when used under Linux. It trims '/' from directories, even at the front, thus making it impossible to use "/tmp" for instance.
I just uploaded a diff that shows a possible fix for this.

obones

obones

2010-04-27 07:35

reporter   ~0025289

@SL-Gundam:
Ok, moving on to the file upload problem, which can also happen under Windows by the way.

Here is the situation:
The Apache process runs under the "www-data" user and Mantis is configured so that uploaded files are created on disk with only the owner being able to read them.
This means that when a file is added to a bug via the Mantis interface, the file is owned by "www-data" and readable by no one else.
Because all other accesses are done via Apache, the files are always readable and accessible to Mantis users.

For various reasons, that "www-data" user cannot have a shell and cannot have a cron table. So for the EmailReporting plugin to work, the cron entry has to be associated to another user. Let's call that user "mantisuser".
As "mantisuser" is the one running the bug_report_mail.php script, it's the system user that is used when creating the stored files.
The file rights being those configured for Mantis, the files are only readable by their owner, which is "mantisuser".

But later on, when someone accesses a bug page and tries to get the attached files, it's the Apache server that tries to read the file. And because it runs under the "www-data" user, it cannot read the files owned by "mantisuser".

To avoid this, there is the brute force method that consists in changing the owners of the files right after the bug_report_mail.php script has run. But this is not always possible because some administrators may not want to give access to the chown command. That would most likely be the case on shared hosting for instance.

The sensible way to solve this is to not create files owned by someone else in the first place. And for this to happen, there is a need to call an upload script via the web server. This page from the EmailReporting plugin would then call the "file_add" function from "file_api.php" which in turn would add the file as if it had been uploaded via the regular Mantis page.

Using that second method, you can now get rid of custom_file_api.php and thus avoid the maintenance headaches whenever the Mantis team does a change to the official file_add function.
This method thus solves a problem and avoids a future one.

I have made the required changes to my own installation of EmailReporting and it works just fine. It requires CURL support in the Apache server, but this is available on most systems by default.

The attached patch applies the required changes so that you can see for yourself.

SL-Gundam

SL-Gundam

2010-04-27 09:41

reporter   ~0025297

yep you're right about the directory trims.

That will be fixed in 0.8.1

For the rest i will have a look at them

obones

obones

2010-04-27 11:29

reporter   ~0025300

One other thing:
The _file_number private member looked useless to me and as such I removed it.
I also changed the way file names are computed with this number so that it is appended before the extension only if there is a need to do so.
This avoids having all files prepended with "1-" which puzzles my users
I have attached the patch for this

SL-Gundam

SL-Gundam

2010-04-27 12:46

reporter   ~0025306

Last edited: 2010-04-27 12:56

The file_upload method provided will not be implemented.

The reason for this is that it causes other problems, namely if the webserver is behind a router / firewall, its possible that the url used externally is not available internally.

Also i feel that it is a completely different method of processing the emails. If we add attachments using that method we might as well do the same with the bug report and bugnotes.

One requirement i have for EmailReporting is that it works with as little requirements as possible.

EmailReporting can use mbstring and openssl. But it does not require it to do its work. Same with the PEAR packages as they are present in EmailReporting. But with your solution CURL is required if you want attachments to work... unless we add two different solutions for processing attachments. But i'm not planning on doing that.

Maybe a variant of this could be an idea for the next major release

SL-Gundam

SL-Gundam

2010-04-27 14:00

reporter   ~0025308

Last edited: 2010-04-27 14:41

After looking at the plugin you created and the changes it requires in EmailReporting, i got to the following conclusions.

Its possible for your plugin to use the generic events. Just do the following:

  • The globally accessible variable: $t_mailbox_api->_mailbox or $GLOBALS[ 't_mailbox_api' ]->_mailbox contains the mailbox currently being processed.
  • You can use isset( $t_mailbox_api ) or isset( $GLOBALS[ 't_mailbox_api' ] ) to check whether you are running within the EmailReporting job right now
  • Your regular expressions are now configured per mailbox. Those can be stored within your own plugin and could also use there own manage page for connecting them to the mailboxes. But it would probably be more efficient to connect your regular expressions to projects instead of the mailboxes. Since categories are defined on global and project level, it would require less expressions to reach the same result

Now the only variable not available for your plugin is $p_mail and you don't really need that since all of its information is in the t_bug_data.

My goal is to make EmailReporting as transparent as possible. Users should not notice any differences whether they use emails or the mantis website. Specific EmailReporting events would stand in the way of that.

[EDIT] removed part about plugin_config_get usage as i was wrong about that

SL-Gundam

SL-Gundam

SL-Gundam

2010-04-27 14:36

reporter   ~0025309

Well nobody's perfect, especially not me so this was not unexpected

MantisBT-1.2.1_plugin_EmailReporting-0.8.1.rar

You can get the new version from: http://git.mantisforge.org/w/EmailReporting.git
But you can also find it in the attachments to this issue

This bugfix release fixes a problem on linux systems from note 0004286:0025288

Apr 2010 v2 - EmailReporting-0.8.1

  • Officially compatible with MantisBT 1.2.1
  • Fixed a bug on linux with directory strings in the configurations (obones)
  • File number before attachments only added when required (obones)
  • Added a notice to the readme stating that for proper operation of EmailReporting, the scheduled job needs to operate under the same user account as the webserver

SL-Gundam

obones

obones

2010-04-27 15:14

reporter   ~0025310

For the file upload, I can understand. I'll have to keep it because it's the only way for me to have things work properly. External branches are here for this kind of scenario, so it's fine by me.

For the plugin subevents, I'm sorry, but I don't understand your logic here. If I follow it to its end, there shouldn't be a way in Mantis to add anything to its configuration page, nor to its menu, everything should be in the plugin configuration page.
And yet, it is possible to add menu items, to add new sections inside the bug view and new elements in the configuration sections.
To me it feels much more natural to have all the settings about a mailbox on the same page, no matter where they originate from. That's what the Source plugin does with its subplugins, and it works just fine.

Making EmailReporting transparent is a good idea, but not allowing to plug cleanly into it, I have trouble understanding.
For instance, for the category according to subject, this is clearly something that should not be done for all added bugs. When users add bugs via the "report" page, they must choose a category. How would you feel if it was changed behind your back?
Yes, I know I can use kludges to detect the new bug is added by the EmailReporting plugin. But they'll always be kludges while a specific event is much cleaner. It's not relying on undocumented internals and its signature won't change unless it is clearly mentioned in the update docs.

In the end, you're the one deciding here, but I just wanted to help make that plugin customizable by as many people as possible. And neither you nor I can know what they could come up with.

SL-Gundam

SL-Gundam

2010-04-27 17:54

reporter   ~0025311

My comments were just about the availability of information. Your changes to event calls were not a requirement for those, they just might have made it a little but easier.

Also i don't want to compromise the configuration options of the EmailReporting plugin. If in the future there is a need to adjust those configuration options, i don't want to run the risk of possibly erasing, breaking or conflicting with those options added by other plugins. Every plugin should manage his own configuration options.

About the decision. If i'm the one implementing it i need to be convinced that it is the right solution. With your plugin, as stated in the comments, there were other ways, in my opinion better ways, to do it. Thats why i personally decided against doing it myself. But that does not stop other people from pushing it into the repository though. Just as long as it is not me.

I've got your email address from your plugin. I think its best we continue this discussion there. A lengthy discussion here would not do this mantis page any good.

obones

obones

2010-04-28 09:25

reporter   ~0025327

I have received your email, I will continue that conversation over via this media.

I also uploaded two new patches:

  1. multi_string_reply_marker.patch
    This one is to add a multi line edit zone for the reply marker. I needed it for a safer way to detect the reply marker because of the way Outlook/Exchange Server handle those

  2. reply_identification.patch
    When both "Remove automatic Mantis replies" and "Remove all replies" are on, only the first one applies and thus leaves more text than required in the bug note. That patch fixes this

jurgenhaas

jurgenhaas

2010-05-20 08:31

reporter   ~0025563

When a report gets created or updated by the cron run, the notification email contains links, that are actually wrong. They're called http://www.domain.com/plugins/EmailReporting/scripts/view.php?id=### where it should actually be http://www.domain.com/view.php?id=###

I guess that's a bug and as a quick fix, I've added a file /plugins/EmailReporting/scripts/view.php with the following content:

<?php
header('Location: '. '/view.php?id='. $_REQUEST['id'], TRUE, 301);
exit();
?>

alitvak

alitvak

2010-05-30 12:51

reporter   ~0025627

I am testing 0.8.1 and I wonder if anything changed. I have a new user added to mantis but he is not added to any projects (as a result of auto adding feature of this plugin). Most of my projects including the default for the mail reporting are private. If I am not manually adding user to a "Email Reporting Default" project, then reporter can see all assignment changes or status changes but doesn't see notes. Even if I tell Mantiss to add this user to monitor the ticket, he still is not receiving newly added notes. Only when I add this user to this project as a reporter or with higher privileges, this user will receive new added notes. Am I forced to add reporter to the project all the time? If so shouldn't plugin auto-add feature add user to the specified default project? Why doesn't just allowing user to monitor ticket work?

midimarcus

midimarcus

2010-06-22 12:35

reporter   ~0025948

I've just installed and configured (I hope properly :) Emailreporting version 0.8.1 but whan I try to fetch email via IMAP on terminal I have one or more lines reporting the following error:
2739,/var/www/mantisbt/plugins/EmailReporting/core/Net/IMAPProtocol_1.0.3.php,PROTOCOL ERROR!:must be a ' ' but is a ')' !!!!

Anyone else have experienced it?
I'm on Ubuntu Server 10.04 LTS.

susovan

susovan

2010-07-15 03:24

reporter   ~0026085

Hi,

I have installed mantis 1.2 as well as e-mail reporting plugin 0.8 on aapche server, Its working good. I have setup the database and all.

Every thing is working fine. But have some issues with the email reporting.

Users are able to report bugs via e-mail, its picking the user name according to the email address, User can add bug note as well.

What I am really interseted about is, what is the format to assiging the bug to a particular user (based upon username or e-mail address)and how to change the status of the bug (new,resolved,fixed) via e-mail.

There is also a problem I am facing is the format of the mail, mantis is sending to the user. From where I can change or customise the format of the mail send by mantis?

I would appreciate if anyone can help, I need the solution very much.

Thanks.

susovan

susovan

2010-07-15 03:32

reporter   ~0026086

Hi,

I have installed mantis 1.2 as well as e-mail reporting plugin 0.8 on aapche server, Its working good. I have setup the database and all.

Every thing is working fine. But have some issues with the email reporting.

Users are able to report bugs via e-mail, its picking the user name according to the email address, User can add bug note as well.

What I am really interseted about is, what is the format to assiging the bug to a particular user (based upon username or e-mail address)and how to change the status of the bug (new,resolved,fixed) via e-mail.

There is also a problem I am facing is the format of the mail, mantis is sending to the user. From where I can change or customise the format of the mail send by mantis?

I would appreciate if anyone can help, I need the solution very much.

Thanks.

Neha.Goyal

Neha.Goyal

2010-07-16 06:59

reporter   ~0026095

Hello,

Anyone knows how can we assign an bug to a user via mail?
Any help would be greatly appreciated.

Thanks

SL-Gundam

SL-Gundam

2010-08-05 13:37

reporter   ~0026228

Last edited: 2010-08-25 08:12

@alitvak, the auto added reporter user is only added to fallback support and default functionality. If you want your reporters to get emails and be able to do stuff directly in mantis its advised to disable "Use only default reporter user for issues created by email". That way EmailReporting will try to identify users based on the from email address

@jurgenhaas, Which version are you using. I've never encountered it using MantisBT 1.2.1 and EmailReporting 0.8.1

@midimarcus, What kind of IMAP server software are you using?

@susovan, There is no functionality like that present in EmailReporting at the moment (maybe in the future). EmailReporting only handles incoming emails. Outgoing emails are handled by Mantis

@Neha.Goyal, There is no functionality like that present in EmailReporting at the moment (maybe in the future). Mantis core functionality does have something in categories maybe that is usable

SL-Gundam

eejape

eejape

2010-08-18 09:44

reporter   ~0026350

How about support for öäå? If the email sender has ä in his name the plugin won't work as it does without ä's.
The message body is not added to bug notes.

SL-Gundam

SL-Gundam

2010-08-25 08:27

reporter   ~0026468

@eejape, Which version of EmailReporting are you using? I cannot reproduce this in version 0.8.0 or later

eejape

eejape

2010-08-27 05:32

reporter   ~0026484

Last edited: 2010-08-27 06:43

Forget it. I tested it on my Debian and it runs ok. For an unknown reason it does not work on my test system which is fedora 12...

The fedora case:
I am running latest stable Mantisbt 1.2.2 & MantisBT-1.2.1_plugin_EmailReporting-0.8.1.rar [^] (64,853 bytes) 2010-04-27 14:33 patched with:
patch file icon multi_string_reply_marker.patch
patch file icon reply_identification.patch

If the sender name has öäå the description is cut from there. i.e. For testing I had a sender named Köyhä the ticket description ended up as:
Summary 0000014: asdf
Description Email from: K
Tags No tags attached.

The attached email is ok...

jurgenhaas

jurgenhaas

2010-08-30 03:29

reporter   ~0026514

@SL-Gundam, up until now I'm using EmailReporter 0.7.9 and Mantis 1.2.2, just figured that there is a new version 0.8.1 available. For some reason I get no notofication emails when this ticket gets new notes, although I'm getting notified for other tickets.

The issue I reported doesn't occure everytime and I haven't figured a pattern yet, when it happens and when it doesn't.

I'll go and upgrade EmailReporting now and see what happens. Keep fingers crossed.

reivax

reivax

2010-09-13 11:16

reporter   ~0026702

I have some troubles to unpack the latest rar files, could you put also the tar.gz files online?

many thanks

Xavier

dornata

dornata

2010-09-18 03:17

reporter   ~0026770

Arg, doesn't work with imap TLS and novalidate_certificat. I'm actually using eventum, but I would like to use mantis.
Can somebody tell me where i can add this option?

I am running latest stable Mantisbt 1.2.2 & MantisBT-1.2.1_plugin_EmailReporting-0.8.1.rar

Thx a lot

datacompboy

datacompboy

2010-09-20 15:38

reporter   ~0026817

I have added to config.api new option

                                    case 'dropdown_categories':

?>
<td class="center" width="40%" colspan="2">
<select name="<?php echo $p_name ?>">
<?php
echo '<optgroup label="Global">';
print_category_option_list( $t_value, ALL_PROJECTS );
echo '</optgroup>';

            $t_project_ids = current_user_get_accessible_projects();
            project_cache_array_rows( $t_project_ids );
            foreach ($t_project_ids as $t_id) {
                    echo '&lt;optgroup label=&quot;'.string_attribute( project_get_field( $t_id, 'name' ) ).'&quot;>';
                    print_category_option_list( $t_value, $t_id );
                    echo '&lt;/optgroup>';
            }

?>
</select>
</td>
<?php
break;

and replaced dropdown_global_categories with dropdown_categories for global_category_id

Now i can select exact category for project required :)

obstbaum80

obstbaum80

2010-09-23 15:36

reporter   ~0026851

@SL-Gundam

I discovered an issue in 0.8.2DEV, file core/Mail/Parser.php
http://git.mantisforge.org/w/EmailReporting.git?a=blob;f=core/Mail/Parser.php;h=1116fb3ae008d1581b882de9514ae63121b43146;hb=92791ed7f2ef8f08338a513bdec8a68243f3d740

In lines 306 and 310 the call is
custom_substr( ... )
but should be
$this->custom_substr( ... )

SL-Gundam

SL-Gundam

2010-10-19 13:17

reporter   ~0027088

Last edited: 2010-10-19 14:57

@eejape, is it possible the charset setting in the EmailReporting configuration page is set incorrectly in your test environment?

@jurgenhaas, let us know if the problem persists

@reivax, i will only publish rar files within this issue. For tar.gz please visit the EmailReporting.git --> http://git.mantisforge.org/w/EmailReporting.git
Click on the text "snapshot" behind one of the changelogs to download the version from that changelog. If you want a stable version, under tags click on "commit" behind the stable version you want to have, in the next page click again on "snapshot" to download that tagged version

@dornata, EmailReporting has support for encrypted connections. Tested with both imap.google.com but also with a personal imap server with a self generated certificate. If it does not work for you for some reason please supply me with information so that i can try to reproduce the issue on my side (for example your imap server software etc.). Small note, you need to have the openssl extension loaded in php and it needs to support the proper stream transports for encrypted connections to be available --> http://www.php.net/manual/en/function.stream-get-transports.php

@datacompboy, going to implement a slightly modified version of your code in 0.8.3.

@obstbaum80, yep your right. Will be fixed 0.8.3

SL-Gundam

UVI

UVI

2010-10-22 03:02

reporter   ~0027116

In our production environment from about 2 weeks we got various bug reported via email with "No description found" on description field.

Some bugs is normal, some other have "no description found"
Analyzing all mail temp mail folder I see all emails have text, and the problem is located on email parser.

I've temporary workarounded the problem printing all email stream in this cases editing [b]core/mail.api.php[/b] file from:
[code]
$t_mail['X-Mantis-Body'] = $t_mp->body();
if ( 0 == strlen( $t_mail['X-Mantis-Body'] ) ) {
$t_mail['X-Mantis-Body'] = "No description found";
}

[/code]

to this:
[code]
$t_mail['X-Mantis-Body'] = $t_mp->body();
if ( 0 == strlen( $t_mail['X-Mantis-Body'] ) ) {
#$t_mail['X-Mantis-Body'] = "No description found";
$t_mail['X-Mantis-Body'] = $p_mail;
}

[/code]

Anyone can help me?

I attach a mail complete streams here:
[code]
Received: from mx02.XXXXXXXXXXXXXXXX ([IP])
by XXXXXXXXXXXXXXXX (Lotus Domino Release 8.5.2 HF64)
with ESMTP id 2010101116520869-10011 ;
Mon, 11 Oct 2010 16:52:08 +0200
X-AuditID: 3e65545e-b7c7dae000004d19-38-4cb323a3915a
Received: from mail-bw0-f52.google.com (mail-bw0-f52.google.com
[209.85.214.52])
by mx02.DOMAIN.COM (Symantec Brightmail Gateway) with
SMTP id F4.EC.19737.3A323BC4; Mon, 11 Oct 2010 16:48:03 +0200 (CEST)
Received: by bwz13 with SMTP id 13so3044498bwz.11
for <mantis_amministrativi@mydomain.com>; Mon, 11 Oct 2010 07:48:03
-0700 (PDT)
Received: by IP with SMTP id v23mr3612183bkk.105.1286808483448;
Mon, 11 Oct 2010 07:48:03 -0700 (PDT)
Return-Path: <xxxxxxxx@email.com>
Received: from Name ([IP])
by mx.google.com with ESMTPS id
o12sm4377715bkb.9.2010.10.11.07.47.58
(version=SSLv3 cipher=RC4-MD5);
Mon, 11 Oct 2010 07:47:59 -0700 (PDT)
Message-ID: <0FC2D88A9D4344B0A68620A35D6BC21C@email.com>
From: "Name Surname" <name.surname@email.com>
To: "mantis" <mantis_amministrativi@mydomain.com>
Subject: Fw: targa AAAAAAAAA
Date: Mon, 11 Oct 2010 16:47:56 +0200
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2900.5931
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994
X-Brightmail-Tracker: AAAAAhZCyC4WQ2m9
X-MIMETrack: Itemize by SMTP Server on
ABRO/SERVER/IT(Release 8.5.2 HF64|September
28, 2010) at 11/10/2010 16.52.08,
Serialize by Router on SERVPRO/SERVER/IT(Release
8.5.1FP1|January
05, 2010) at 11/10/2010 16:46:04,
Serialize complete at 11/10/2010 16:46:04,
Serialize by POP3 Server on SSERVPRO/SERVER/IT(Release
8.5.1FP1|January 05, 2010) at 11/10/2010 16:46:12,
Serialize complete at 11/10/2010 16:46:12
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_017A_01CB6964.0E44FF40"

This is a multi-part message in MIME format.

------=_NextPart_000_017A_01CB6964.0E44FF40
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset="iso-8859-1"

targa cccccccccccccc
text
text
text here
text

__ Informazioni da ESET NOD32 Antivirus, versione del database =
delle firme digitali 5519 (20101011) __

Il messaggio =E8 stato controllato da ESET NOD32 Antivirus.

www.nod32.it

__ Informazioni da ESET NOD32 Antivirus, versione del database =
delle firme digitali 5520 (20101011) __

Il messaggio =E8 stato controllato da ESET NOD32 Antivirus.

www.nod32.it

------=_NextPart_000_017A_01CB6964.0E44FF40

------=_NextPart_000_017A_01CB6964.0E44FF40
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META name=3DGENERATOR content=3D"MSHTML 8.00.6001.18939">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2 face=3DArial>targa <FONT size=3D3=20
face=3D"Times New Roman">CCCCCCCCCCCC</FONT></FONT></DIV>
<DIV>text</DIV>
<DIV>saluti</DIV>
<DIV><FONT size=3D2 face=3DArial>textextexthere</FONT></DIV>

__ Informazioni da ESET =
NOD32=20
Antivirus, versione del database delle firme digitali 5519 (20101011)=20


Il messaggio =E8 stato controllato da ESET NOD32=20
Antivirus.

<A=20
href=3D"http://www.nod32.it&quot;>www.nod32.it&lt;/A> [^]

__ =
Informazioni=20
da ESET NOD32 Antivirus, versione del database delle firme digitali 5520 =

(20101011) __

Il messaggio =E8 stato controllato da ESET =
NOD32=20
Antivirus.

<A=20
href=3D"http://www.nod32.it&quot;>www.nod32.it&lt;/A> [^]
</BODY></HTML>
------=_NextPart_000_017A_01CB6964.0E44FF40

------=_NextPart_000_017A_01CB6964.0E44FF40--
[/code]

SL-Gundam

SL-Gundam

2010-10-25 11:42

reporter   ~0027155

@UVI, you must be running an older version of EmailReporting. Please upgrade to the latest version. If the problem still persists after that, let us know.

SL-Gundam

UVI

UVI

2010-11-02 09:31

reporter   ~0027221

@ SL-Gundam

We've upgraded to Mantis-1.1.1-changed_files_only-unofficial-v1.tgz because our mantis version is currently 1.1.1. It's correct?
The problem persists.
I've to upgrade to another mail version?
If yes could you tell me the correct version for my mantis 1.1.1 ??

Thanks

philou2024

philou2024

2010-11-02 12:16

reporter   ~0027222

about possibility to get categories of a defined project (datacompboy latest note), a very simple solution could be
print_category_option_list( $t_value, helper_get_current_project() )
in place of
print_category_option_list( $t_value, ALL_PROJECTS )

SL-Gundam

SL-Gundam

2010-11-02 13:07

reporter   ~0027223

I'm unable to provide adequate support for mantis versions older then 1.2.0.

That is because in Mantisbt 1.2.0 a plugin system was introduced. During that conversion i improved a lot of the EmailReporting code. I barely did any work on the script before that time.

Your best guess if you don't want to upgrade to 1.2.x is to use one of the following two archives found in the attachments of this issue:
Mantis-1.1.1-changed_files_only-unofficial-v1.tgz
Mantis-1.1.2-changed_files_only-unofficial_v2.zip

Also don't forget to add the fields found in the /doc/bug_report_mail.sql if you use one of those versions

I hope it works but i can only provide a minimum of support i'm afraid

UVI

UVI

2010-11-10 06:29

reporter   ~0027325

@ SL-Gundam

Now it works!
I have overwrited all files located in /Mail folder with files contained in Mantis-1.1.2-changed_files_only-unofficial_v2.zip and the issue is solved.
Thanks for your support.

SL-Gundam

SL-Gundam

2010-11-25 16:42

reporter   ~0027487

it's been a while and 2 versions have not been released here

0.8.2 - contained mainly changes for plugin developers
0.8.3 - very closely followed by 0.8.4 because of small improvements in 0.8.4 to project category change in 0.8.3
0.8.4 - currently being released

You can find the new version in the attachment to this issue (MantisBT-1.2.3_plugin_EmailReporting-0.8.4.rar) and also in the git repository (http://git.mantisforge.org/w/EmailReporting.git)

Changelog:
Nov 2010 - EmailReporting-0.8.4

  • Improved the project category list
  • If no attachment filename has been found, EmailReporting will generate a name instead of rejecting the file
  • Relative paths are converted to absolute paths for mail_debug_directory and mail_tmp_directory.

Sep 2010 - EmailReporting-0.8.3

  • Officially compatible with Mantis 1.2.2 and 1.2.3
  • Updated readme
  • Changed conflicting language variable names for title, description and author to plugin_title, plugin_description and plugin_author.
  • Updated PEAR packages supplied with EmailReporting
  • Non-global categories can now also be selected as a category for a mailbox (datacompboy)
  • Fixed incorrect function call in parser.php on line 306 and 310 (obstbaum80)

May 2010 - EmailReporting-0.8.2

  • Fixed a problem when both remove mantis and remove all replies are turned ON (obones)
  • Configuration option type array is now called string_multiline
  • Configuration option type dropdown_mailbox_encryption is now called dropdown_encryption
  • Configuration option type dropdown_mailboxes is now called dropdown_descriptions
  • yes and no strings now come from the core language files
  • mailbox_ part of the indexes for the mailbox arrays have been removed
  • Fixed wrong variable usage during testing of mailbox
  • zero_mailboxes lang index name changed to zero_descriptions
  • Language indexes for actions that ended on _mailbox have been changed to _action
  • The configuration option that defines what identifies a reply is now a multiline input box (obones)
  • New function which returns the GLOBALS index name of the mailbox_api (ERP_get_mailbox_api_name())
  • 2 new functions which can return mailbox data (ERP_get_current_mailbox and ERP_get_mailboxes)
  • Updated readme based on added plugins that depend on EmailReporting
  • hostname and port are no longer stored in a sub array within mailbox. They now have there own indexes
  • Event added that allows the addition of extra mailbox form fields (see readme)
  • New config type added called dropdown_descriptions_multiselect
  • Added 2 specific ERP events for manipulating data before adding bug reports and bugnotes
  • Some texts in the ERP_output_config_option will always use the EmailReporting plugins translation even if its called from another plugin
  • Get from LDAP is now also an option for the preferred usernames. This will be attempted using the email address
  • Email addresses will now be compared to LDAP records incase login_method is LDAP and use_ldap_email is ON
  • Small optimization to the creation of the global path_erp variable

SL-Gundam

keen4000

keen4000

2010-12-08 03:27

reporter   ~0027568

How is the e-mail content used? Is it just like e-mail suject used as issue summary and e-mail content used as issue description?

Or are there any keywords I can use in the e-mail to define other fields as priority, category, "steps to reproduce" and so on?

Thx, keen

SL-Gundam

SL-Gundam

2010-12-10 03:45

reporter   ~0027576

no keywords... not yet anyway.

SL-Gundam

SL-Gundam

2010-12-10 12:47

reporter   ~0027580

Last edited: 2010-12-14 19:54

On second thought that answer was a bit short so here is a more detailed answer

Currently the category is set by your mailbox setup in EmailReporting. You can add multiple mailboxes from which to retrieve emails and connect them to different projects with different categories

Priority is read from the email priority

For the rest it has a very simplified methode of removing reply's and has the ability to scan for original mantis notification emails and remove it, if enabled, from bugnotes.

A rule system with the possibility for keywords is in development and hopefully will be in the next major version. But who knows when that will be.

keen4000

keen4000

2010-12-13 04:23

reporter   ~0027586

Ok thanks for your response!
I was just wondering why there is always an equal sign "=" added at the end of the bug description. This made me think that there must be some interpretation of the mail content done in the background...
Regards, Keen

SL-Gundam

SL-Gundam

2010-12-14 19:52

reporter   ~0027600

http://pear.php.net/package/Mail_mimeDecode/download

In the latest version (1.5.5) of the PEAR package mimedecode somebody changed the way that worked and that causes the problem you have.

The mimedecode package thats provided with EmailReporting is version 1.5.4 and does not have that problem but it will only be used if you don't have the mimedecode package installed from the PEAR database

SL-Gundam

jurgenhaas

jurgenhaas

2011-01-05 11:40

reporter   ~0027815

I'm now running into a new problem as we changed the mail server backend. Here is our configuration:

Mantis 1.2.4
EmailReporting 0.8.4
Exchange Server with IMAP

And when we check emails with plugins/EmailReporting/scripts/bug_report_mail.php we are receiving this error:

2915,/mantisbt/plugins/EmailReporting/core/Net/IMAPProtocol_1.0.3.php,PROTOCOL ERROR!:PARSE ERROR!!! must be a '\r\n' here but is a ' '!!!! (getting the next line)|STR:| A0007 OK STATUS completed. | 2871,/mantisbt/plugins/EmailReporting/core/Net/IMAPProtocol_1.0.3.php,PROTOCOL ERROR!:must be a but is a 'A0007' !!!! 2903,/mantisbt/plugins/EmailReporting/core/Net/IMAPProtocol_1.0.3.php,PROTOCOL ERROR!:bogus response!!!! (COMMAND: ) 2915,/mantisbt/plugins/EmailReporting/core/Net/IMAPProtocol_1.0.3.php,PROTOCOL ERROR!:PARSE ERROR!!! must be a '\r\n' here but is a 'OK'!!!! (getting the next line)|STR:| STATUS completed. | 2871,/mantisbt/plugins/EmailReporting/core/Net/IMAPProtocol_1.0.3.php,PROTOCOL ERROR!:must be a but is a 'STATUS' !!!! 2903,/mantisbt/plugins/EmailReporting/core/Net/IMAPProtocol_1.0.3.php,PROTOCOL ERROR!:bogus response!!!! (COMMAND: ) 2915,/mantisbt/plugins/EmailReporting/core/Net/IMAPProtocol_1.0.3.php,PROTOCOL ERROR!:PARSE ERROR!!! must be a '\r\n' here but is a 'COMPLETED.'!!!! (getting the next line)|STR:| | Mailbox: Support Mailbox IMAP [pear_error: message=", " code=0 mode=return level=notice prefix="" info=""] Done checking all mailboxes

Any idea what's wrong here?

SL-Gundam

SL-Gundam

2011-01-10 08:50

reporter   ~0027870

Ok. Got no clue atm.

So i need the following:
Which exchange server version are you running? My company has Exchange server 2010 SP1. So maybe i can test it on that
Please specify what changed as detailed as possible

SL-Gundam

cas

cas

2011-01-24 10:49

reporter   ~0028049

Just upgraded to Mantis 1.2.4 and the latest version of the plugin. We have the following issue:
If we run the plugin via the browser, calling the plugin, all is fine.
If we run the script, we have a problem with the attachments. They cannot be uploaded which is caused by the working directory. This points to plugins/EmailReporting/scripts and not to the root of mantis.
Our upload path is to the files directory in the root of mantis so the plugin tries to store it to plugins/EmailReporting/scripts/ files rather tahn to files/.
Any clue/suggestion how to handle this?

SL-Gundam

SL-Gundam

2011-01-24 15:11

reporter   ~0028054

On the configuration page of EmailReporting you need to adjust the setting called "Directory for saving temporary email content" and optionally also "Save email contents to this directory if debug mode is activated".

Note: The php ini setting upload_tmp_dir (the default for the first setting mentioned above) is usually an absolute path, not a relative one as its globally set for all php programs on a webserver, not just for MantisBT.

SL-Gundam

cas

cas

2011-01-24 16:07

reporter   ~0028057

The problem is not with the temp location but with the final (DISK) location.
That temp location has also been set in php.ini so that works out.
It really stumbles on the mantis location.

cas

cas

2011-01-25 05:56

reporter   ~0028074

I have uploaded bug_report_mail2.php. This is a variant on the standard script and needs to be stored in the root of Mantis. Using this script for scheduled tasks (under windows) ensures proper working of importing emails with attachments.
Reason for this was that the standard functionality, in our setup (using DIsK), had problems with the working directory not being adjusted to the root. This caused the script not to find the proper location for the files.
Batch file for schedule, under windows, must be like this (to be adjusted according local setup):
g:
cd \inetpub\wwwroot\mantis
php.exe bug_report_mail2.php

paulala

paulala

2011-02-04 15:27

reporter   ~0028166

Hi all,

Im not a programmer, just an end user with a bit of basic knowledge about php. If this is not the place to post this then I apologise. I have been trying to get this to work all afternoon on my implementation of mantis and have a problem. Well 2 problems really.

  1. Is there any comprehensive documentation for this plugin that deals with the basics like file permissions etc on shared hosts.
  2. (main problem) when I try and manage configuration options all I get is a 403 forbidden. Ive been scratching around messing with chmods all day.... nothing!
    Im not even sure if im even supposed to bother setting what Im trying to set up in manage configuration options but im guessing its something I need to do. You all seem to know exactly what to do so im guessing there is some big documentation repository somewhere that I dont yet know about right? Failing that :-s , can someone give me some advice on why trying to save configuration options gets me a 403 every single time without fail on the administrators account.

tia,

Paula

SL-Gundam

SL-Gundam

2011-02-22 05:12

reporter   ~0028274

@cas a absolute path instead of a relative path for the storage dir would have fixed it as well

@paulala

  1. check the emailreporting/doc/ directory. That contains all the documentation currently available. Another source is all the posts in this issue.
  2. A possibility is a module for apache that could block some pages with a 403 error.
    Another possibility is linux access rights. This could occur when you placed the files on the server using a different account then the one used by the webserver to read them. But this is unlikely as by default (usually) everybody has read rights for those files
ddeprekel

ddeprekel

2011-03-03 14:45

reporter   ~0028362

Hello,
I have tried to locate this in the notes and either it is not there or my search-fu is badly lacking. I also could not locate it in the documentation.

I am using mantisbt 1.2.4 and the latest build of emailreporting 0.8.4. Is there a way to have the system send a response to the submitter of an issue to show that it has in fact been received and provide the ticket id # in the email so they can reference it in future conversations? I don't see anything like this in the configuration at all.

Any help is appreciated!

Doug

SL-Gundam

SL-Gundam

2011-03-12 12:58

reporter   ~0028407

@ddeprekel
MantisBT by itself has a setting called email_receive_own. Which enables a user to receive emails about the users own actions (only when those actions would normally generate e-mail notifications, see "Manage -> Manage Configuration -> E-mail Notifications").

You can also enable "Should users receive emails for their own actions" in the configuration page for EmailReporting. This will only enable email_receive_own for EmailReporting (again see above for those notification options).

jurgenhaas

jurgenhaas

2011-03-18 03:53

reporter   ~0028437

Since we upgraded to the latest version (0.8.4) we are facing a problem with parsing of multipart emails. All seems to be configured right as it usually works, just from a few customers, it isn't working.

I have uploaded th file jurgenhaas_parse_html_issue.zip which includes two complete emails, one of which is working OK and the other fails. Failing means that we get 'No description found' in the bug description, although all content is in the attached complete file to the bug.

We can't figure out what's the difference between the two emails that could be causing the problem. Can you please help us with this?

SL-Gundam

SL-Gundam

2011-04-05 17:22

reporter   ~0028540

Last edited: 2011-04-05 17:26

@jurgenhaas. Both emails provided parse correctly in my tests. So i see only 2 options

  1. A possible bug in the pear packages that are used. Try disabling these so that the pear package provided with EmailReporting are used.

  2. If "Remove all replies from bugnotes" is enabled, check what it searches for in "Use this text to identify the start of a reply"

Hope this helps

SL-Gundam

jurgenhaas

jurgenhaas

2011-04-06 14:39

reporter   ~0028545

As for 1.) How do I find out which PEAR package is used and how do I disable a possible wrong one?

As for 2.) "Remove all replies" is disabled, it's just "Remove MantisBT notification emails from replies." being enabled and the "Use this text to identify the start of a reply" is set to the default "-----Original Message-----"

cor3huis

cor3huis

2011-04-07 10:42

reporter   ~0028552

This issue IMHO should be changed to Plugin Task

SL-Gundam

SL-Gundam

2011-04-07 21:02

reporter   ~0028562

Last edited: 2011-04-07 21:11

@jurgenhaas, For 1. Rename the core_pear directory (if present) to something else temporarily and run a test on a mailbox. If everything still works then you have a directory somewhere which contains the pear files. Check the phpinfo() page for the include_path variable. One of the directories in that variable should be your pear directory.

The core_pear directory is only used when the necessary pear files are not found somewhere else.

Which version were you running before you upgraded to 0.8.4?

jurgenhaas

jurgenhaas

2011-04-11 12:56

reporter   ~0028591

Here is the report of further tests, nothing has been successful yet:

  • I renamed the directory "core_pear" into "org_core_pear" and went to the EmailReporting configuration page in Mantis where I received error messages straight away telling me that the file Net/Pop3.php can't be found

  • That makes me believe that there is nor other pear package available on my system and that the files in core_php are really used and required. So I renamed the directory back to its original name and tried again - this time without an error message.

  • Then I checked which version of EmailReporting I used before and that was 0.8.1 and I replaced the core_pear directory with the files from that earlier version and tried again. All worked as before just that the broken emails still didn't get parsed properly.

I have uploaded another zip archive containing files from the debug log which are not showing up in Mantis with their bodies. One of the files is been from the old core_pear (-ALT) and the other one from the new core_pear (-NEU).

Could you please try and check them again for me?

SL-Gundam

SL-Gundam

2011-04-11 19:46

reporter   ~0028598

Last edited: 2011-04-11 20:05

Found the problem. Its in the pear package mimedecode.

The latest pear package available does not have the problem (1.5.5), but the version currently delivered with EmailReporting does (1.5.4)

The problem has definitely been present in 0.8.3 and 0.8.4. I'm not completely sure about earlier versions but from your tests it seems this bug has been in the pear package for quite some time.

I've pushed some changes to the git repository - http://git.mantisforge.org/w/EmailReporting.git.

Now until a new stable version of EmailReporting is released you can fix this in a couple ways

  • Download the latest version available from the GIT repository (0.9.0-DEV). This is a development version so it could contain other bugs and contains in progress work.
  • Only download the mimedecode.php and overwrite the existing one in the core_pear/mail directory -> http://git.mantisforge.org/w/EmailReporting.git?a=blob_plain;f=core_pear/Mail/mimeDecode.php;hb=master (use "right mouse button" and "save as"). You can also download the full 0.9.0-DEV version and only extract mimedecode.php
  • Install the official pear packages. EmailReporting will automatically use them instead of the ones in the core_pear directory

Personally i do not advise the first option as it is a development release and therefore i cannot provide adequate support for it.

Let me know if your problem still persists

Thx Jurgenhaas for your patience

AlexYarmoshko

AlexYarmoshko

2011-04-13 07:01

reporter   ~0028613

Hi Guys,

Apparently, there is a bug in this plugin causing continues repeating of the same issue when some error interrupted email parsing/issue reporting.

In our case it was the size of the attachment which went over default MySQL limit of 1MB. As a result the same email was registered as an issue many times until it was manually removed from the mailbox. Additionally, no other emails are processed as plugin is stuck with the email causing problem and cannot move to another one.

I suggest to have some mechanism to skip an email if it was already added as an issue or caused exception or something like that.

Thanks.

SL-Gundam

SL-Gundam

2011-04-17 12:01

reporter   ~0028636

Last edited: 2011-04-19 13:54

There is a mechanism which checks the maximum allowed size of the attachment. It does this the same way Mantis does with attachments

This is based on the following settings:
php variable 'upload_max_filesize'
php variable 'post_max_size'
mantisbt variable 'max_file_size'

In this case you set the mantisbt variable 'max_file_size' too high. You should have set it to the maximum size allowed by your server setup or lower than that depending on what you want to allow.

Besides that, MantisBT has enough warnings in the admin / install interface about the mysql limit. So rather then a bug i see this as a misconfiguration on your side

SL-Gundam

jurgenhaas

jurgenhaas

2011-04-18 10:14

reporter   ~0028646

Just downloaded the mimedecode.php and replaced the existing file with it and that seems to have resolved my issue. Thanks a lof SL-Gundam, great support.

ayadav

ayadav

2011-04-19 08:41

reporter   ~0028666

How can the issues be tagged ?

Use case: We use the tagging feature a lot on day to day basis. It would be great if the bugs reported through this tool can be tagged directly. With this I can directly filter for my tag defined for bugs reported via email.
The tags can be configured (defined) in the "Manage Configuration Options" page for this plugin.

Has anyone already implemented such a feature already ?

SL-Gundam

SL-Gundam

2011-04-19 13:53

reporter   ~0028672

Last edited: 2011-04-19 13:55

Not to my knowledge. But who knows what modifications other people created to extend functionality for EmailReporting.

I'm currently developing a rule based system for the next version of EmailReporting. I will try to implement a option to apply tags within that

SL-Gundam

AlexYarmoshko

AlexYarmoshko

2011-04-22 09:43

reporter   ~0028690

Hi SL-Gundam,

In this case you set the mantisbt variable 'max_file_size' too high. You should have set it to the maximum size allowed by your server setup or lower than that depending on what you want to allow.

Besides that, MantisBT has enough warnings in the admin / install interface about the mysql limit. So rather then a bug i see this as a misconfiguration on your side

I agree that this particular size limit issue is misconfiguration. But this is not a point of my report.

Point is: The EmailReporting plugin will not be able to handle email fetching correctly if for whatever reason saving of the particular email failed. In this case plugin will try to post this failed email into the Mantis system forever until either problem is resolved or email was deleted from the inbox.

To make things worse - each time a new duplicate issue is registered.

Regards,
Alex.

cas

cas

2011-04-26 03:49

reporter   ~0028694

Alex,
not too sure if the plugin needs to cater for different configuration on your side. We had the same problem and synched the max size between mailserver and php. This took care of that issue.

SL-Gundam

SL-Gundam

2011-04-28 20:09

reporter   ~0028717

Last edited: 2011-04-28 20:13

@AlexYarmoshko. EmailReporting already checks a lot of possible errors, which could break the processing of emails and prevents them from breaking the processing of the emails. But some of them do depend on proper configuration on the client side. Also some errors just cannot be prevented, no matter how many checks we build in the system.

If you find another email that breaks the processing of emails for EmailReporting let me know and we'll investigate the cause.

I've updated the readme a little bit to make it clear this setting is important and needs to be checked by the person installing the plugin.

There is one option which could possibly prevent problems like these permanently:
If an email breaks EmailReporting, i can try to make sure that the email is deleted before that time. But if an email is not imported correctly you will lose the change of ever retrieving it again. If i add this functionality it will be behind a configuration option which is by default disabled, since some businesses find it unacceptable to lose these emails. Keep in mind that with this a client has a lot more trouble finding the cause of emails that are not properly processed into mantis

Before i even begin with adding functionality like that, i would like to know some other peoples opinions. Personally i'd rather have EmailReporting break processing emails like it does now so that it is clearer that there is a actual problem somewhere and that once the problem is fixed the email is imported correctly. The duplicate issues can easily be cleaned up by a mantis admin and he can also stop the scheduled job from running to debug the cause of his current problems.

SL-Gundam

cas

cas

2011-04-29 01:38

reporter   ~0028718

Personally I would never activate such option, as you already stated, loosing emails, not even knowing why it went missing, is just not an option.
This only could be an option if the email is first forwarded to an alternate mail address (or different folder).
Question is where does it stop?

libregeek

libregeek

2011-05-09 02:15

reporter   ~0028761

We now have a dedicated wiki page for EmailReporting:
http://www.mantisbt.org/wiki/doku.php/mantisbt:emailreporting

Please contribute.

wheels

wheels

2011-05-20 06:39

reporter   ~0028805

I'm trying to make a very simple (I hope) change to the EmailReporting plugin, and I was hoping someone could help.

All I need is to change the order of the notes in the actual email report you receive on any modification to a ticket. Basically, I need the order to be reversed in the notification mail so that newer notes are at the top, not the bottom.

Anyone?

cas

cas

2011-05-20 07:52

reporter   ~0028806

That is depending on the preferences of the recipient.
You can define that sequence in the preferences of the user (My Account /Preferences).
If you want to change for all, adjust the default setting:
$g_default_bugnote_order = 'ASC';
to :
$g_default_bugnote_order = 'DESC';

In short, do not touch the plugin!

Cipriano

Cipriano

2011-05-22 03:36

reporter   ~0028807

I have a problem with this plugin.

My clients use Microsoft Outlook (same problem with yahoo or hotmail emails in html format), in order to send to the IT team, bug reports by email that are automatically added as issues into Mantis.
This works verry well, except when the emails are in html format and they contain screenshots (90% of their email contain screenshots, along with formatted text, etc).
In this case,the problem is, Mantis plugin extracts the text and puts it in the Bug Description field, and it transforms the screen captures in separate images attached to the mantis bug.

I would like the Mantis bug description field to respect EXACTLY the format of the email sent by the client (css included).
Is it possible ?

Can the bug description field in the /bugs/view.php page in Mantis contain images ? I mean, the same images we see in the 'Attached files ' field on the same page...

SL-Gundam

SL-Gundam

2011-05-22 07:40

reporter   ~0028809

No sorry the plugin has not been prepared for usage like that. The reason for that is that MantisBT would not allow it since the descriptions are plain text and therefore would not allow html css and ofcourse inline pictures.

If in the future MantisBT would allow it, then of course an attempt will be made to also add support in EmailReporting

SL-Gundam

Cipriano

Cipriano

2011-05-22 12:23

reporter   ~0028811

Thank you!

In this case, without modifying the core Mantis, another solution for the developer to read the client's request in more or less the original format, would be that the plugin add a Mantis bug with a minimal text (email's subject for example) and add the html email's body :

  • as an attachment to this bug having a "show content" link
  • as a first Bug Note in html format, displyed inline

There is no plugin configuration doing this ?

SL-Gundam

SL-Gundam

2011-05-22 16:48

reporter   ~0028812

Last edited: 2011-05-22 16:49

The best EmailReporting is currently able to offer is: If you want to add the complete raw email with text, html and attachments to the issue you can activate the debug mode and activate the option to add the complete email. I doubt that is what you want but you can have a look at it if you wish.

It would be possible to add only the html email as attachment to the issue but its still not possible to add pictures inline when opening that html attachment as the attached pictures are also attachments in the issue which is different from attachments in emails.

One way or the other inline pictures is not yet possible because a mantis issue is inherently different from an email.

If i ever think of something that could facilitate this i will of course investigate further, but at the moment i can't think of anything.

If you do see a solution or want to try to find one, i suggest creating a proof of concept or even modify the EmailReporting plugin yourself and provide the code in this issue (maybe even commit it yourself into the git repository).

What i currently want to look at is what is the cause for this wish. The company i work at is also using Microsoft Outlook 2007 and Exchange 2010 server to facilitate its email needs. My colleagues also use inline pictures and i've never had any problems with the current setup of EmailReporting with the created issues by that system.
I did change some specific settings in the Exchange 2010 server for some of the EmailReporting mailboxes. When a pop3 client (EmailReporting) connects to the mailbox it can only retrieve plain text emails (of course attachments are included) from the Exchange server. This can be set in the exchange server in the pop3 settings of every mailbox.

Please clarify the reason for the wish or the problems it currently causes.

SL-Gundam

captmkg

captmkg

2011-06-30 18:09

reporter   ~0029082

Some background from me, I have not installed this plugin and this individual who did install this is no longer working with me.

I'm trying to get this plugin to do what it says it will do: submit a ticket via e-mail.

I've tried to test the mailboxes and they have all failed.

I'm not sure what e-mail address I should be sending issues to or even how this is set up.

Can someone help provide some information to this? Many thanks to any help!

libregeek

libregeek

2011-07-06 01:46

reporter   ~0029105

EmailReporting Plugin now has a dedicated forum at Mantis-Forums. Please use the forum for help in installing and using this plugin.;

http://www.mantisbt.org/forums/viewforum.php?f=13

zdroyer

zdroyer

2011-07-14 04:14

reporter   ~0029166

Last edited: 2011-07-15 10:33

Hi
I've just added my small patch to the latest git dev version.
I'm starting Mantis in quite special environment when most of the bug reports and all the communication with reporters-customers is to be made by emails. The message to our customers is: "Send us an email with square bracketed ticket number in the subject" so I needed some relaxed rules to recognize a note-email.

1) The regexp for bug id recognition now accepts:

  • currently accepted format (backward compatibility)
  • just the bug number in square brackets, no project name required (e.g. [20], [ 20], [ 20 ])
  • any prefixes before the opening square brackets (e.g. Re: [20], Fwd:[20])
  • any number of leading zeros [0000000000000000020]

2) A config option "Write the email subject as the first line of the bugnote" was added. Since the subject of an email can be "custom" so it can include some info we would like to save in the note content

ToDo:
An interface to convert a bug into a bug note an vice-versa.
I'm not sure if it should be a part of the EmailReporting Plugin. Any suggestions?

libregeek

libregeek

2011-07-15 01:00

reporter   ~0029172

EmailReporting plugin is now in GitHub along with other MantisBT plugins.

The stable releases can be downloaded from the following URL: https://github.com/mantisbt-plugins/EmailReporting/downloads

If you wish to contribute to the plugin, please fork the repo in github and push your changes.

Please do not submit patches to this bug report.

libregeek

libregeek

2011-07-15 01:08

reporter   ~0029173

@zdroyer:
It would be easy if you could fork the plugin in GitHub and commit the changes there. We can then review the code easily and merge it to master if there are no conflicts.

I think the features you mentioned in ToDo should go to a separate plugin as it is out of scope of EmailReporting plugin. May be you can request a repo in https://github.com/mantisbt-plugins and invite contributors.

zdroyer

zdroyer

2011-07-15 11:19

reporter   ~0029177

@libregeek, I've just committed my mod to GitHub (I need to practice a bit git - a 15 minute tutorial is not enough to us git fluently ;)

If it is essential in my Mantis installation to have Bug<->Note converter, I will start developing it using github.

andrea.mills

andrea.mills

2011-07-21 16:33

reporter   ~0029258

Mantis:1.2.5
EmailReporting: 0.8.4 with 0.9.0 mimedecode.php
PHP: 5.3.6 with PEAR installed.

How can I resolve this error?

[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]

Fatal error: Cannot use object of type PEAR_Error as array in C:\wamp\www\mantis
\plugins\EmailReporting\core\Net\IMAP_1.0.3.php on line 176

I have a mail account, mantis user using that mail account.
Mailbox type: IMAP
Mailbox connection encryption: NONE
Mailbox auth method: USER

andrea.mills

andrea.mills

2011-07-22 10:57

reporter   ~0029272

the problem was that I had PEAR installed, but not the packages? Once I installed PEAR packages, that error was resolved, and now I'm having the parsing error of previous notes (c0027815). I updated PEAR mime_Decode to 1.5.5, but the parsing error is having issues in \EmailReporting\core\Net\IMAPProtocol_1.0.3.php

The error:
2915,C:\wamp\www\mantis\plugins\EmailReporting\core\Net\IMAPProtocol_1.0.3.php,P
ROTOCOL ERROR!:PARSE ERROR!!! must be a '\r\n' here but is a ' '!!!! (getting t
he next line)
STR: A0007 OK STATUS completed.
2871,C:\wamp\www\mantis\plugins\EmailReporting\core\Net\IMAPProtocol_1.0.3.php,P
ROTOCOL ERROR!:must be a but is a 'A0007' !!!!
2903,C:\wamp\www\mantis\plugins\EmailReporting\core\Net\IMAPProtocol_1.0.3.php,P
ROTOCOL ERROR!:bogus response!!!! (COMMAND: )
2915,C:\wamp\www\mantis\plugins\EmailReporting\core\Net\IMAPProtocol_1.0.3.php,P
ROTOCOL ERROR!:PARSE ERROR!!! must be a '\r\n' here but is a 'OK'!!!! (getting
the next line)
STR: STATUS completed.
2871,C:\wamp\www\mantis\plugins\EmailReporting\core\Net\IMAPProtocol_1.0.3.php,P
ROTOCOL ERROR!:must be a but is a 'STATUS' !!!!
2903,C:\wamp\www\mantis\plugins\EmailReporting\core\Net\IMAPProtocol_1.0.3.php,P
ROTOCOL ERROR!:bogus response!!!! (COMMAND: )
2915,C:\wamp\www\mantis\plugins\EmailReporting\core\Net\IMAPProtocol_1.0.3.php,P
ROTOCOL ERROR!:PARSE ERROR!!! must be a '\r\n' here but is a 'COMPLETED.'!!!! (
getting the next line)
STR:

Mailbox: Test
[pear_error: message=", " code=0 mode=return level=notice prefix="" info=""]

and my installed pear packages:
C:\wamp\bin\php\php5.3.6>pear list
INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET:

PACKAGE VERSION STATE
Archive_Tar 1.3.7 stable
Console_Getopt 1.2.3 stable
Mail 1.2.0 stable
Mail_Mime 1.8.1 stable
Mail_mimeDecode 1.5.5 stable
Net_IMAP 1.0.3 stable
Net_POP3 1.3.8 stable
Net_Socket 1.0.10 stable
PEAR 1.9.1 stable
Structures_Graph 1.0.3 stable
XML_Util 1.2.1 stable

C4Vette

C4Vette

2011-09-06 04:15

reporter   ~0029643

Thank you all for this very nice plugin.
One question:
The 'priority' doesn't seem to function as aspected. A mail created with Outlook has priority-options low, normal or high. The default is 'normal' and the new issue gets the priority 'normal. But when the mail has the priority 'high' the issue shows "@50@".
Can I change this behaviour?

Ed

oboeck

oboeck

2011-09-13 09:17

reporter   ~0029696

Hello,

I hope you could help me to find a solution for my problem.

We installed the Plugin on a Mantis Version 1.2.3 and it runs smooth. It's some kind of windows server with an inetpub-folder (I don't have real access to this, because it's an customer).
The database has UTF-8 and in the plugin-setting is UTF-8 too.
Email Reporting Version is 0.8.2. and on the server runs PHP 5.2.14.

But at the time an email with cyrillian characters is collected from the postbox, the plugin crashes and throw this error Message.
The message is:

APPLICATION ERROR 0000401

Database query failed. Error received from database was 0001366: Incorrect string value: '\x93junk...' for column 'description' at row 1 for the query: INSERT INTO mantis_bug_text_table
( description, steps_to_reproduce, additional_information) VALUES ( ?,?,?).
Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.

Previous non-fatal errors occurred. Page content follow.
[...
SYSTEM WARNING: mb_convert_encoding() [..]: Unable to detect the character encoding
....]

I don't know if this here relates to my problem, but there "SL-Gundam (Manager)" fixed the problem via mail.
http://www.mantisbt.org/bugs/view.php?id=4286#c25072 (post 25072 to 25134)
http://www.mantisbt.org/bugs/view.php?id=11770 (this is the same just seperatly)

Kind Regards
oboeck

SL-Gundam

SL-Gundam

2011-09-13 19:24

reporter   ~0029700

@C4Vette. See the configuration options page. You seem to have modified the default priorities delivered with MantisBT so you need to adjust the priorities array accordingly

@oboeck. See forum

Socrates

Socrates

2011-09-15 05:09

reporter   ~0029724

Hi all,

First off, great plugin. I've made some changes to suit it entirely to my liking and thought I'd give these changes back to the community.

I've created my patch against MantisBT-1.2.3_plugin_EmailReporting-0.8.4.rar as found attached to this issue. I've tested and confirmed this working on my Mantis 1.2.8 setup. Of course a disclaimer, your mileage may vary, don't come to me if your entire mantis database is gone after using my patch (should in no way ever be able to happen, but there, i've said it).

I've first implemented the patch relaxed_bugid_reqexp_and_subject_in_note.path (partly by hand because patching with this file to this codebase didn't work entirely correctly). After that I've made changes to do the following:

  • Add the CC header from the mail into the new issue or bug note
  • Add the Date header from the mail into the new issue or bug note
  • Changed 'Email from: ' to be just 'From: ' for the description
  • Changes to always add the Subject line, not only in bug note but also in new issue
  • Changed order of headers to always be as follows: From, CC, Date, Subject
  • Some indenting/spacing/style changes to match original code style

Of course CC and Date header adding have been added in such a way that they are configurable from the 'Manage plugins' page and default to 'off'.

Hope someone will find this helpful, patch file is called note_and_new_issue_add_subject_cc_date.patch and is attached to this issue.

Socrates

Socrates

2011-09-15 06:04

reporter   ~0029726

Hi all,

back again so soon. I've decided to also add the 'To' field. This might look strange to some of you because you use this to actually mail to an account, but we use the thunderbird Mail Redirect addon (http://mailredirect.mozdev.org/index.html) to bounce messages in a mailbox where Mantis will find them. This means the original To: header is still intact so I thought I'd also show that to log who the mail originally was sent to.

I've also removed a leftover debug print statement from the code.

Patch added is note_and_new_issue_add_subject_cc_date_to.patch and supersedes the previous patch as this is again a patch against the codebase in MantisBT-1.2.3_plugin_EmailReporting-0.8.4.rar. This means you don't have to use both my patch files, you can just use this last one.

nhartung

nhartung

2011-10-03 17:47

reporter   ~0029907

Last edited: 2011-10-03 17:49

Can you explain or suggest a workaround, why when multiple emails are listed on a ticket, e.g. in CC. and one of the CC'd persons reply-all, a new ticket is being created? In this particular example I email manits@xxxx, this is the email configured to be parsed my the email reporting tool. A group mygroup@xxxx is CC'd. Then one of the user of the group hit reply-all. This will trigger a new email. The user does have permissions to mantis/project/ticket.

a. can this be integrated in a patch?
b. what would be a workaround
c. how can we prevent this, not include the group, instead include individuals?

We're using Mantis 1.2.7 with EmailReporting-0.8.4
Thank you!!!

SL-Gundam

SL-Gundam

2011-10-20 17:05

reporter   ~0030015

@nhartung, EmailReporting searches the subject line for an issue id number.

  1. First create the issue
  2. With an email from MantisBT containing the issue number start mailing back and forth with other people.

EmailReporting only recognizes issue notes when the subject line contains the issue number.
Something like this: "RE: [project 0001234] subject line"

yloo

yloo

2011-11-23 13:12

reporter   ~0030270

Hi to all,

I m desperate.
I installed the plugin 0.8.4 successfully ( i can see the new menu and manage the plugin) but I got this error when I test it.

Operation NOT successful

Mailbox description: example - bug
Mailbox type: POP3
Mailbox hostname: mail.example.com
Mailbox port (optional): 26
Mailbox connection encryption: None
Mailbox username: help@example.com
Mailbox password: ****
Mailbox authentication method: USER

[pear_error: message="220 and/or bulk e-mail." code=-1 mode=return level=notice prefix="" info=""]

Please help me to fix this. I didn t see this kind of error here.

yloo

yloo

2011-11-23 13:13

reporter   ~0030271

Hi to all,

I m desperate.
I installed the plugin 0.8.4 successfully ( i can see the new menu and manage the plugin) but I got this error when I test it.

Operation NOT successful

Mailbox description: example - bug
Mailbox type: POP3
Mailbox hostname: mail.example.com
Mailbox port (optional): 26
Mailbox connection encryption: None
Mailbox username: help@example.com
Mailbox password: ****
Mailbox authentication method: USER

[pear_error: message="220 and/or bulk e-mail." code=-1 mode=return level=notice prefix="" info=""]

Please help me to fix this. I didn t see this kind of error here.

SL-Gundam

SL-Gundam

2011-11-23 17:54

reporter   ~0030272

Last edited: 2011-11-23 18:10

i take it example.com is not your real mail servers domain.

Anyways this is an error from your mail server. I suggest you consult its manual on how to retrieve emails using the pop3 protocol

Secondly i think 26 is not the correct port number for the pop3 protocol for your mail server. Maybe try leaving it empty and use the default ports

belfar

belfar

2011-11-23 18:37

reporter   ~0030281

teste

nhartung

nhartung

2011-11-23 18:57

reporter   ~0030323

@SL-Gundam: the ticket will be created with an email.

To: mantis@xxxxx
CC: usergroup@xxxx

Then a user which is a member of 'usergroup' reply-all to the email. This triggers a new ticket. not sure why, because the subject has the ticket number in it.

SL-Gundam

SL-Gundam

2011-11-24 11:21

reporter   ~0030334

Please give me the complete subject line you are using

eejape

eejape

2011-12-01 02:47

reporter   ~0030446

Last edited: 2011-12-01 03:31

A bug with long email addresses!
I am using Mantis 1.2.8 and emailreporting 0.84. I also have signup new users enabled. If the email address of a new reporter is longer than 30 chars the user is not added to the database, and the mail is lost!
To make it short the sender emails:
bbbbbbbbbbbbbbbbbbbbbbb@gmail.com Don't work
bbbbbbbbbbbbbbbbbbbbbb@gmail.com Works!
Error received when manually run the script:
Mailbox: [Omitted] Message: Failed to create user based on: Teppo Testaaja - bbbbbbbbbbbbbbbbbbbbbbbbbb@gmail.com Mailbox: [Omitted] Message: Could not get a valid reporter. Email will be ignored Mailbox:

The obvious workaround is to enable fall back to default reporter

One more problem is that the username generation does not seem to work. The username is always generated like this firstname_lastname_domain_randomnumbers no matter which selection is made on the configuration page.

libregeek

libregeek

2011-12-01 04:19

reporter   ~0030447

@eejape
You can change DB_FIELD_SIZE_USERNAME to overcome the long email address problem. Make sure that you change it in DB as well.

eejape

eejape

2011-12-01 05:49

reporter   ~0030448

Thanks @libregeek, long emails fixed.

Still remains the problem with the username generation...

SL-Gundam

SL-Gundam

2011-12-01 11:29

reporter   ~0030455

In MantisBT 1.2.6 they changed the name of 2 constants thats why this functionality does not work as expected.

You have 2 options to fix this

  • update to 0.9.0-DEV. Its a development version so be carefull in production environments -> https://github.com/mantisbt-plugins/EmailReporting
  • Manually change all occurences of USERLEN and REALLEN to DB_FIELD_SIZE_USERNAME and DB_FIELD_SIZE_REALNAME in plugins/EmailReporting/core/mail_api.php
coolman

coolman

2012-01-27 04:25

reporter   ~0031054

Hi all,

Install the 0.84 version on Mantis 1.2.4, works like a breeze. Thank you for this great plugin.

I do have a quick question, what's the mechanism to get an email added to an existing bug?

When I send an email to Mantis it creates a bug. But when I get a response from someone (outside Mantis) on this bug, I'd like that response to add to the bug in stead of creating a new one.

SL-Gundam

SL-Gundam

2012-01-27 12:50

reporter   ~0031062

Users need to respond to Mantis notification emails. These emails contain a subject line more or less like: "RE: [project 0001234] test issue"

EmailReporting will retrieve the issue id from the email and will try adding a note to the issue in question.

This will fail if the issue has passed the readonly border. See 'bug_readonly_status_threshold'.

For all other cases if it can find the issue id in the subject line it should work

Bedlore

Bedlore

2012-03-01 22:10

reporter   ~0031364

Is there a way to have the "from:" field to be custom per project so that people can simply click reply and their email would be added as a note. I've setup to use one email box per project, but perhaps this is a mistake in hindsight?

Any suggestions please.

libregeek

libregeek

2012-03-02 00:24

reporter   ~0031365

@Bedlore
Please see comment 0004286:0031062. SL-Gundam has explained how the notes are added when an user replies to the Mantis notification mail. Hope this helps.

jeansupport

jeansupport

2012-06-22 09:17

reporter   ~0032153

Hi!
I have many questions. First of all, i have Mantis 1.2.10 and installed EmailReporting 0.84, would it work?
What I want is just creating new issues by mail and maybe add notes to existing issues.
How should I write emails? Is there any required way?

Lastly, I have about 15 projects, how can I select where to add a new issue by mail? Should I create 15 different accounts?

Thanks so much.

SL-Gundam

SL-Gundam

2012-06-22 11:11

reporter   ~0032154

In future please ask questions on the forums: http://www.mantisbt.org/forums/viewforum.php?f=13

Also see:
The readme in the "doc" folder
http://www.mantisbt.org/wiki/doku.php/mantisbt:emailreporting

As for your questions

  • If you use MantisBT 1.2.6 or later i advise you use 0.9.0-DEV which can be found here: https://github.com/mantisbt-plugins/EmailReporting (Click on "ZIP")
  • Write the emails as much as possible in plaintext because html is not supported
  • EmailReporting can direct emails from one mailbox to one project. If you want emails to be imported into 15 different projects then you need to add 15 different mailboxes in EmailReporting. This could be 15 different folders in 1 mailbox if you use IMAP, but for POP3 it needs to be 15 different mailbox with different email addresses

SL-Gundam

jeansupport

jeansupport

2012-06-26 03:43

reporter   ~0032181

Thanks!

SL-Gundam

SL-Gundam

2014-11-07 18:23

reporter   ~0041794

I see grangeway moved this to another project.

Could this please be moved back to the EmailReporting project?

xcolgk

xcolgk

2015-01-23 15:49

reporter   ~0048660

test

xcolgk

xcolgk

2015-01-23 15:50

reporter   ~0048661

test

xcolgk

xcolgk

2015-01-23 15:51

reporter   ~0048662

test

xcolgk

xcolgk

2015-01-23 15:51

reporter   ~0048663

test

xcolgk

xcolgk

2015-01-23 15:52

reporter   ~0048664

test

SL-Gundam

SL-Gundam

2015-01-23 19:05

reporter   ~0048665

EmailReporting has a project within MantisBT now so no need for one gigantic issue about this

For further reference and notifying us about bugs please check: https://www.mantisbt.org/wiki/doku.php/mantisbt:emailreporting