From 5a42156bf7b2543b7995ba9b86e693f64eda38a5 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 10 Apr 2015 08:06:44 -0500
Subject: [PATCH] mailer: Try harder to find References header

Ensure that the References header that is included with outbound email
definitely includes the References header from an email received into the
system, if at all possible.
---
 include/class.mailer.php | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/class.mailer.php b/include/class.mailer.php
index 7dfb867e3..41c0005ae 100644
--- a/include/class.mailer.php
+++ b/include/class.mailer.php
@@ -304,11 +304,13 @@ class Mailer {
         if (isset($options['thread'])
             && $options['thread'] instanceof ThreadEntry
         ) {
-            $headers += array('References' => $options['thread']->getEmailReferences());
             if ($irt = $options['thread']->getEmailMessageId()) {
                 // This is an response from an email, like and autoresponse.
                 // Web posts will not have a email message-id
-                $headers += array('In-Reply-To' => $irt);
+                $headers += array(
+                    'In-Reply-To' => $irt,
+                    'References' => $options['thread']->getEmailReferences()
+                );
             }
             elseif ($parent = $options['thread']->getParent()) {
                 // Use the parent item as the email information source. This
-- 
GitLab