diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb
index 8cbc9eefc7b73e6dea9b4dd1160272959d2d38e2..e7331d885172199755ed3d6e3cd849eb83cb49ee 100644
--- a/app/mailers/notify.rb
+++ b/app/mailers/notify.rb
@@ -121,11 +121,17 @@ def mail_thread(model, headers = {})
   #
   # See: mail_answer_thread
   def mail_new_thread(model, headers = {})
-    headers['Message-ID'] = message_id(model)
+    headers['Message-ID'] = message_reply_id
+    headers['In-Reply-To'] = message_id(model)
+    headers['References'] = message_id(model)
 
     mail_thread(model, headers)
   end
 
+  def message_reply_id
+    Gitlab.config.incoming_email["address"].gsub("%{key}", reply_key)
+  end
+
   # Send an email that responds to an existing conversation thread,
   # with headers suitable for grouping by thread in email clients.
   #
diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb
index d4b6f6d120db2bc78173296fcbc4aa51a380c48d..d55bacde5b09b31a08d9d2f86bcb920cd78dd421 100644
--- a/lib/gitlab/email/receiver.rb
+++ b/lib/gitlab/email/receiver.rb
@@ -63,6 +63,10 @@ def message
       end
 
       def reply_key
+        key_from_to_address || key_from_in_reply_to_header
+      end
+
+      def key_from_to_address
         key = nil
         message.to.each do |address|
           key = Gitlab::IncomingEmail.key_from_address(address)
@@ -72,6 +76,17 @@ def reply_key
         key
       end
 
+      def key_from_in_reply_to_header
+        reply_key = nil
+
+        message[:in_reply_to].message_ids.each do |message_id|
+          reply_key = Gitlab::IncomingEmail.key_from_address(message_id)
+          break if reply_key
+        end
+
+        reply_key
+      end
+
       def sent_notification
         return nil unless reply_key
 
diff --git a/spec/fixtures/emails/key_in_headers_reply.eml b/spec/fixtures/emails/key_in_headers_reply.eml
new file mode 100644
index 0000000000000000000000000000000000000000..8f288775d0ae9d409b49b931c1ffcac9101e02bf
--- /dev/null
+++ b/spec/fixtures/emails/key_in_headers_reply.eml
@@ -0,0 +1,42 @@
+Return-Path: <jake@adventuretime.ooo>
+Received: from iceking.adventuretime.ooo ([unix socket]) by iceking (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA; Thu, 13 Jun 2013 17:03:50 -0400
+Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) by iceking.adventuretime.ooo (8.14.3/8.14.3/Debian-9.4) with ESMTP id r5DL3nFJ016967 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>; Thu, 13 Jun 2013 17:03:50 -0400
+Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <reply@appmail.adventuretime.ooo>; Thu, 13 Jun 2013 14:03:48 -0700
+Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
+In-Reply-To: <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>
+References: <issue_1@localhost> <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>
+Date: Thu, 13 Jun 2013 17:03:48 -0400
+From: Jake the Dog <jake@adventuretime.ooo>
+To: reply@appmail.adventuretime.ooo
+Message-ID: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
+Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux'
+Mime-Version: 1.0
+Content-Type: text/plain;
+ charset=ISO-8859-1
+Content-Transfer-Encoding: 7bit
+X-Sieve: CMU Sieve 2.2
+X-Received: by 10.0.0.1 with SMTP id n7mr11234144ipb.85.1371157428600; Thu,
+ 13 Jun 2013 14:03:48 -0700 (PDT)
+X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1
+
+I could not disagree more. I am obviously biased but adventure time is the
+greatest show ever created. Everyone should watch it.
+
+- Jake out
+
+
+On Sun, Jun 9, 2013 at 1:39 PM, eviltrout via Discourse Meta
+<reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo> wrote:
+>
+>
+>
+> eviltrout posted in 'Adventure Time Sux' on Discourse Meta:
+>
+> ---
+> hey guys everyone knows adventure time sucks!
+>
+> ---
+> Please visit this link to respond: http://localhost:3000/t/adventure-time-sux/1234/3
+>
+> To unsubscribe from these emails, visit your [user preferences](http://localhost:3000/user_preferences).
+>
diff --git a/spec/fixtures/emails/valid_reply.eml b/spec/fixtures/emails/valid_reply.eml
index 1e696389954ca0b2ca63fe4a0f4dfd5853f5e61a..e2b974174bdfaf358432d7661226f76ffea45c3c 100644
--- a/spec/fixtures/emails/valid_reply.eml
+++ b/spec/fixtures/emails/valid_reply.eml
@@ -3,6 +3,8 @@ Received: from iceking.adventuretime.ooo ([unix socket]) by iceking (Cyrus v2.2.
 Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) by iceking.adventuretime.ooo (8.14.3/8.14.3/Debian-9.4) with ESMTP id r5DL3nFJ016967 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>; Thu, 13 Jun 2013 17:03:50 -0400
 Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>; Thu, 13 Jun 2013 14:03:48 -0700
 Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
+In-Reply-To: <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>
+References: <issue_1@localhost> <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>
 Date: Thu, 13 Jun 2013 17:03:48 -0400
 From: Jake the Dog <jake@adventuretime.ooo>
 To: reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo
@@ -37,4 +39,4 @@ On Sun, Jun 9, 2013 at 1:39 PM, eviltrout via Discourse Meta
 > Please visit this link to respond: http://localhost:3000/t/adventure-time-sux/1234/3
 >
 > To unsubscribe from these emails, visit your [user preferences](http://localhost:3000/user_preferences).
->
\ No newline at end of file
+>
diff --git a/spec/lib/gitlab/email/receiver_spec.rb b/spec/lib/gitlab/email/receiver_spec.rb
index abe179cd4af160d27f5bff11e688ba62d03ce11b..13fd83ec7baaa64fc87a1703f650c13ba49dc20a 100644
--- a/spec/lib/gitlab/email/receiver_spec.rb
+++ b/spec/lib/gitlab/email/receiver_spec.rb
@@ -137,5 +137,18 @@
 
       expect(note.note).to include(markdown)
     end
+
+    context "when the reply key is in the In-Reply-To header" do
+      let(:email_raw) { fixture_file("emails/key_in_headers_reply.eml") }
+
+      it "creates a comment" do
+        expect { receiver.execute }.to change { noteable.notes.count }.by(1)
+        note = noteable.notes.last
+
+        expect(note.author).to eq(sent_notification.recipient)
+        expect(note.note).to include("I could not disagree more.")
+      end
+    end
   end
 end
+
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 9b47acfe0cd1027f5023a8fc63a1cfb7496188b2..0f3de33f361a431aa49a26c93a4a2a2f313aa0e2 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -217,7 +217,11 @@
           end
 
           it 'has the correct message-id set' do
-            is_expected.to have_header 'Message-ID', "<merge_request_#{merge_request.id}@#{Gitlab.config.gitlab.host}>"
+            is_expected.to have_header 'Message-ID', /<reply\+(.*)@#{Gitlab.config.gitlab.host}>/
+          end
+
+          it 'has the correct references set' do
+            is_expected.to have_header 'References', "<merge_request_#{merge_request.id}@#{Gitlab.config.gitlab.host}>"
           end
 
           context 'when enabled email_author_in_body' do
diff --git a/spec/mailers/shared/notify.rb b/spec/mailers/shared/notify.rb
index 6019af544d3f79bf7187d28794e995a5ef19ce47..eafc5e5044b62c048619e7073288da9279572a72 100644
--- a/spec/mailers/shared/notify.rb
+++ b/spec/mailers/shared/notify.rb
@@ -50,7 +50,8 @@
   include_examples 'an email with X-GitLab headers containing project details'
 
   it 'has a discussion identifier' do
-    is_expected.to have_header 'Message-ID',  /<#{message_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
+    is_expected.to have_header 'Message-ID',  /<reply\+(.*)@#{Gitlab.config.gitlab.host}>/
+    is_expected.to have_header 'References',  /<#{message_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
   end
 end