15

When any email is send with a Message-ID header, then any replies to it include In-Reply-To, naming that ID, and References which can name a list of parent message ID's. So email clients can use this information to construct threads when viewing a list of emails in threaded view.

My question is: Do all email clients (Outlook, Gmail, Exchange, etc) append In-Reply-To field in email header when replying to any existing email?

I referred RFC 2822 but it says In-Reply-To field is optional.

Though optional, every message SHOULD have a "Message-ID:" field.
Furthermore, reply messages SHOULD have "In-Reply-To:"

Example of In-Reply-To email header:

First email:

Message-ID <foobar-1234-0@server.com>

Second email:

Message-ID <foobar-1234-1@server.com>
In-Reply-To: <foobar-1234-0@server.com>
References: <foobar-1234-0@server.com>

Third email:

Message-ID <foobar-1234-2@server.com>
In-Reply-To: <foobar-1234-1@server.com>
References: <foobar-1234-0@server.com> <foobar-1234-1@server.com>
U. Windl
  • 3,480
  • 26
  • 54
slayer
  • 393
  • 1
  • 5
  • 19
  • 2
    My guess is "No", because I occasionally receive e-mail replies from others that do not include the "In-Reply-To" header. So, their e-mails are received by my e-mail client as "new" and not added to any on-going thread that may exist. – Arya Jun 02 '18 at 18:25

2 Answers2

7

Arya is correct. I've seen that the majority of email clients/servers do use the In-Reply-To (or more commonly, the References) header(s). Although, it is not required by RFC 2822 standards (as you pointed out).

There are a few ways around this / to work with this. The more you can pull from the email, the more likely it will thread to the correct email chain. I tried to prioritize this matching, and tried something as follows:

  • If the email has an In-Reply-To header, add it to the list of References
  • Use References, if it exists, to match to Message Ids of other emails (in whatever system/code you're working with)
  • If exchanged emails have a certain reference number such as [ref: XXXXXXXXX :ref] (Salesforce formats Email to Case like this by default), you could check for that. Downside is, clients/agents could remove it.
Ben Mitchell
  • 71
  • 1
  • 3
  • 1
    "If exchanged emails have a certain reference number such as [ref: XXXXXXXXX :ref]" In which part of the email would that be specified? The subject? Or is that another header? – kelvin May 10 '21 at 08:20
  • 1
    @kelvin in any part of the email while you will have to parse it out yourself to see if it's in reply to related mails with same reference identifier. In support mails, it's nice to add ticket id to subject itself, so no need to fetch body. If need to be less obvious, then can hide reference in html of the body. – Lukas Liesis Nov 27 '22 at 03:58
  • Trying threading based on the subject is probably both: Unreliable and not always correct; that's why those header fields exist. – U. Windl Aug 09 '23 at 20:53
0

The short answer "no" given is most likely correct, but I want to point out why that might be so:

First the current specification is RFC 5322: Internet Message Format, dated October 2008, and the correct phrase is "header field".

The SHOULD specification for Message-ID, In_Reply-To and References was used instead of MUST, because those header fields are not technically necessary for successful email message exchange (see also RFC 2119: Key words for use in RFCs to Indicate Requirement Levels).

Also there are very poor email clients, specifically when sending automated messages, that create rather minimalistic header fields. So the MTAs (Message Transfer Agents) like sendmail can be configured to add missing header fields like Message-ID or Date, but they won't add In-Reply-To or References, because the MTA actually cannot know in general. Actually the MSA (Message Submission Agent) receiving the initial message should do that, but historically the MTAs also were MSAs.

Still, while not technically necessary, RFC 2119 clearly says about SHOULD:

This word, or the adjective "RECOMMENDED", mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.

Back in 1985 or so there was an open source "graphical" (i.e.: TUI (Terminal User Interface)) email program (MUA, Mail User Agent) named "ELM" (by Dave Taylor, HP at that time) that supported the "In-Reply-To" header field, so actually there is little excuse for modern programs not to do.

U. Windl
  • 3,480
  • 26
  • 54