Sometimes I'll notice false positives (includes an email that isn't part of the thread) and false negatives (misses an email that should have been part of the thread). How does Gmail decide which messages should and shouldn't be part of a thread?
The following conditions must be met:
- The subject must be similar (e.g.
re: testwill work; but
- The sender must be a part of the thread OR the in-reply-to header must be used.
The in-reply-to header can be used via Gmail's interface by simply replying to the thread. This is what enables forwarded messages to be a part of the same thread even though the sender is different.
If you want more information, you can check out my blog post where I posted more detailed information about my findings.
The short answer: the subject line.
a conversation will break off into a new thread if the subject line of the conversation is changed, or if the conversation reaches over 100 messages.
There are headers in an email message which contain information about which thread the email message belongs to. I don't know for sure that Gmail uses these headers, but I would be very surprised if it didn't. You can see the headers of an email message in Gmail.com by clicking the three dots and then "Show original".
If those headers don't exist, I presume Gmail will then fall back to guessing based on the subject line.
Relevent email headers:
Message-ID: every email message can include this header, and it is used to identify that email message uniquely. It can look like anything as long as it is unique, for instance,
[email protected]is a valid Message-ID.
In-Reply-To: this will contain the message ID of the email message that the current message is in response to. Gmail can use this information to put the message in the correct conversation.
References: this will contain a list of all the message IDs of all the previous emails in the conversation, according to the software that sent the email message. This is more durable than
In-Reply-To, in case the recipient doesn't have the previous message in the conversation, but does have some of the messages before that.
- Blog post by Wes Morgan (2012) Understanding Email Headers, Part II - The Basics
- Quora answer How does Gmail decide which emails go into which threads?