I am working on ticketing system in PHP. I convert mails to tickets. When a user replies to the mail from the Ticketing system, it is sending the mail to the customer as a new mail. No message/mail threading.
I think, my problem is related to the added ticket id at the end of the subject. (e.g. Subject: Installation Problem [#EMSY45]
)
I have passed the Message ID and References in the Header
I am using PHPMailer to send the mail.
Here is my code:
$mail = new PHPMailer();
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = str_replace('/', '', $host); // Specify main and backup SMTP servers
if($outgoing_server_details['smtp_auth'] == 1)
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $outgoing_server_details['server_username']; // SMTP username
$mail->Password = $outgoing_server_details['server_password']; // SMTP password
$mail->SMTPSecure = $protocol; // Enable TLS encryption, `ssl` also accepted
$mail->Port = $port;
$mail->setFrom($outgoing_server_details['from_email_field'], $from_name);
$mail->addAddress($data['_from'], $to_name); // Add a recipient
$mail->addReplyTo($outgoing_server_details['from_email_field'], $reply_to_name);
$message_id = $data['message_id'];
$mail->AddCustomHeader('In-Reply-To', $message_id);
$mail->AddCustomHeader('References', $message_id);
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $data['subject'];
$mail->Body = $mail_content;
$mail->send();