I'm attempting to reply to an email with php. I use php imap to fetch the email from the mail server and get the `message-id`.. i'm attempting to reply to the email but the email still shows up as a new message rather than a reply with threaded messages?
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to email: ' . imap_last_error());
$emails = imap_search($inbox,'ALL');
if($emails) {
rsort($emails);
foreach($emails as $email_number) {
$overview = imap_fetch_overview($inbox,$email_number,0);
$message_id = $overview[0]->message_id;
$references[] = $overview[0]->message_id;
}
$references = implode(" ",$references);
$headers = "From: <test@domain.co.uk> \r\n";
$headers .= "In-Reply-To: $message_id\r\n";
$headers .= "References: $references\r\n";
$headers .= "Content-Type: text/html;\r\n";
$subject = "testing";
$message = "test message2";
mail( "test2@domain.co.uk", $subject, $message, $headers );
How do i solve? I'm using the headers from http://www.jwz.org/doc/threading.html.