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