From 2c508f205ac25bbce1abea1d356fe06c222ca7be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 6 Apr 2016 21:04:30 +0200 Subject: [PATCH] FEATURE: properly set 'In-Reply-To' header when sending an email that is a reply to an incoming email --- lib/email/sender.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/email/sender.rb b/lib/email/sender.rb index 6168b086dfc..34233d67d20 100644 --- a/lib/email/sender.rb +++ b/lib/email/sender.rb @@ -78,10 +78,16 @@ module Email if topic_id.present? email_log.topic_id = topic_id + incoming_email = IncomingEmail.find_by(post_id: post_id, topic_id: topic_id) + + incoming_message_id = nil + incoming_message_id = "<#{incoming_email.message_id}>" if incoming_email.try(:message_id).present? + topic_identifier = "" post_identifier = "" + @message.header['Message-ID'] = post_identifier - @message.header['In-Reply-To'] = topic_identifier + @message.header['In-Reply-To'] = incoming_message_id || topic_identifier @message.header['References'] = topic_identifier topic = Topic.where(id: topic_id).first