View Issue Details

IDProjectCategoryView StatusLast Update
0004286Plugin - EmailReporting[All Projects] Generalpublic2016-07-21 15:17
ReporterindyAssigned ToSL-Gundam 
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Version 
Target VersionFixed in Version 
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

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

2004-08-06 10:38

 

Mantis.tgz (2,101 bytes)
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

2004-08-09 16:25

 

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)
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

2004-09-15 10:30

 

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)
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.

2004-09-15 12:00

 

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)
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.

2004-11-06 12:55

 

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)

2004-11-21 11:49

 

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)
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 ;)

2004-12-26 08:30

 

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)
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.

2005-02-12 08:45

 

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'];
 
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 < 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.

2005-08-07 07:02

 

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)
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

2005-08-07 08:52

 

mantis-1.0.0rc1.patch-2 (40,308 bytes)
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"; 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:

"(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()))" )
);

?>

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?

2005-10-31 05:25

 

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)

2005-10-31 05:25

 

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)

2005-10-31 05:25

 

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)
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: move_uploaded_file( $p_tmp_file, $t_disk_file_name ) 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:

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

mail_api.php:
...
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');
#unlink($t_file_name);
}
}
...
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:

config_inc.php:
$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 );

mail_api.php - mail_parse_content
...
$v_mail['Subject'] = $t_structure->headers['subject'];
$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'];
}

...

mail_api.php - mail_add_bug
...
$t_mail_save_from = config_get( 'mail_save_from' );
$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' );

    $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...

2006-05-10 08:46

 

mantis-1.0.3.patch.gz (34,492 bytes)
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_projectfiletable'),"
@@ -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.

2006-09-17 09:09

 

mantis-1.0.5.patch.gz (109,299 bytes)
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 < 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."-".$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 ) {
$t_mail_debug = config_get( 'mail_debug' );
$t_mail_fetch_max = config_get( 'mail_fetch_max' );

...

if ( $t_mail_debug ) {
print_r($t_mail);
mail_save_message_to_file( $t_msg );
}

#mail_save_message_to_file( $t_msg );
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 )

2007-06-06 11:51

 

Mantis-1.1.0a3-changed_files_only.zip (88,472 bytes)

2007-06-06 13:43

 

Mantis-1.1.0a3-changed_files_only-v2.zip (88,472 bytes)
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.

2007-06-08 20:10

 

Mantis-1.1.0a3-changed_files_only-v3.zip (88,477 bytes)
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&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.
case 'application/x-pkcs7-signature': //E-Mail Certificate

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...

2008-02-04 05:18

 

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)

2008-02-04 05:20

 

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)

2008-02-04 20:58

 

Mantis-1.1.1-changed_files_only-unofficial.tgz (88,898 bytes)
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.

2008-02-04 22:07

 

Mantis-1.1.1-changed_files_only-unofficial-v1.tgz (88,948 bytes)
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: cat ${f} | /usr/bin/w3m -T text/html -dump
and e.g.
b) on windows: htmlparser\parse.bat ${f}

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 OFF. 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.

2008-02-11 11:30

 

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)
brody

brody

2008-02-11 11:31

reporter   ~0017012

Last edited: 2008-02-12 05:10

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

2008-02-12 05:09

 

mail_api.php.patch-v2 (2,616 bytes)
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';

2008-02-13 04:51

 

1202890957da93014a9e1d86b8b0fc26e66b637721 (12,353 bytes)
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

2008-02-21 10:39

 

NOURL-patches.zip (1,214 bytes)
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: "/usr/bin/w3m -T text/html -dump"
$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>@strangeway: 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.

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

@Indy: 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 . "/" . 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 . " " . $file);
        } else {
            # others: piped command
            $this->_body = shell_exec("cat " . $file . " | " . $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 . "/" . 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 . " " . $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("cat " . $file . " | " . $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 . " " . $file);
                    } else {
                            # others: piped command
            $this->_body = shell_exec("cat " . $file . " | " . $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) ){

2008-07-11 08:53

 

Mantis-1.1.2-changed_files_only-unofficial.zip (130,466 bytes)
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

2008-07-14 07:29

 

Mantis-1.1.2-changed_files_only-unofficial_v2.zip (130,518 bytes)
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("/\[([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;
            }
    }

... 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.

Found what the problem was.

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?

Found what the problem was.

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 Fw:[Diverse cases 2032903]: <case_name>, 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 added a check that if mail is too ols and has been check before..
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 Reported by feild in Mantis?

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

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

John Doe is always a user in Mantis and i want his name to be imported into Reported by filed instead of Reporter [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 $g_mail_use_reporter OFF!
what should i do with $g_mail_save_from

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

@indy: 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 Reporeted by 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 "From: " 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 = "Mail";
$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 "file_uploads = TRUE" 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: "/usr/bin/w3m -T text/html -dump"
# 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&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      = "localhost";
$g_db_username   = "testun";
$g_db_password   = "testpwd";
$g_database_name = "testdb";
$g_db_type       = "mysql";

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

# the "From: " 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 = "Mail";
$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 Reported by mail 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 "Additional Information"
# 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: "/usr/bin/w3m -T text/html -dump"
# 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 "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%';

#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.

2009-01-21 14:40

 

Recmail.zip (60,416 bytes)
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.

2009-02-10 06:50

 

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)
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.

2009-02-18 22:10

 

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 );
 		}
 		
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&VarIdt=1&SitIdt=18&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.

2009-02-20 08:14

 

Recmail095.zip (60,670 bytes)

2009-02-20 08:40

 

Recmail095a.zip (60,666 bytes)
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