Solution
I made this solution. This looks like a lot of text, but it's a very easy hack, just read check it out. All emails from a the same email address go to the same Ticket ID. I'm sure it could be re-written and there could be some problems that come up but I've tested it and it works. When you get an email from someone who is already in the Database with a Ticket of any status, this will append the response to that Ticket just like if the TicketID were in the email subject. If that email address is not in the database it will make a new ticket. Before applying this I would Delete all tickets except for one per email address. Feel free to improve on this code and post the replies in this thread, or any problems and questions.
The file to edit is include/class.mailfetch.php
Find these two lines, they are around 240 in the file.
$newticket=true;
//Check the subject line for possible ID.
I insert the following between these two lines.
//New Match compare email and not TicketID
$sql5='SELECT email,ticketID FROM ticket WHERE email="'.$var.'"';
$msgres =db_query($sql5);
while ($msg_row = db_fetch_array($msgres)) {
if($msg_row==$var) {
$extid = $msg_row;
$ticket= new Ticket(Ticket:($extid));
}
}
UPDATE 30 MINUTES LATER.
I thought it might be wise / preferable and ideal in my case to update the SUBJECT when the new email was received. This way it will change the subject of the existing ticket to the subject of the new email from the user with the same email address as the previously opened tickets. With the cost of email these days a lot of couples / family's share address and this will allow them to note in the subject which person is actually sending the email.
Here is the new code, just use it in place of the previous code if you want to update the subject, the direction are the same.
//New Match compare email and not TicketID
$sql5='SELECT email,ticketID FROM ticket WHERE email="'.$var.'"';
$msgres =db_query($sql5);
while ($msg_row = db_fetch_array($msgres)) {
if($msg_row==$var) {
$extid = $msg_row;
$ticket= new Ticket(Ticket:($extid));
//Start UPDATE SUBJECT
$sql='UPDATE ticket SET updated=NOW(),subject='.db_input(Format:($var)).' WHERE ticketID='.db_input($extid);
//echo $sql;
if(db_query($sql)){
//success
}
//END Update Subject
}
}