What is threading

protz edited this page Feb 16, 2012 · 13 revisions

If you're here, you probably posted a feature request or complained about strange threading with Thunderbird Conversations. This page attempts to summarize what "threading" is, and tries to clear a few misconceptions. This is basically a sum-up of the two links below in a version hopefully understandable by users (unlike the two links, which are mainly aimed at developers).

Some references are:

Some currently open bugs about threading: bug 646225 and bug 663270.

Email structure

An email is made of headers followed by the message body. Headers contain metadata about the message: who sent it, to who, when the message was sent, what the subject is, etc. etc.. The message body is, well, the message body. To see the headers, select a message in your message list, and in the menus, hit View > Message source. You will see the raw contents of the message. Everything before the first blank line in the message source is headers. The rest is the message body. We'll mainly talk about headers here.

Default behavior in Thunderbird 3

About message ids

When an email is sent, it is assigned a unique message id. This message id is stored in the Message-Id: header.

When Alice sends a message to Bob, Alice's message is assigned a message id, say, for the sake of example, "AliceMsg1". Now when Bob replies to Alice's message, Bob's message is also assigned a message id, say, "BobMsg1". If we leave the situation "as is", when Bob's reply arrives in Alice's mailbox, Alice's MUA (Mail User Agent, i.e. the program she uses to read and send email) has no way to figure out that Bob's reply actually relates to Alice's original email.

To alleviate this problem, Bob's MUA adds an additional header called In-Reply-To:, whose value is "AliceMsg1". This header tells which message Bob is replying to, which allows Alice's MUA to figure out that "AliceMsg1" and "BobMsg1" relate together. There is another header that serves the same purpose, but that can hold more than one value, called the References: header.

Thunderbird 3, by default, will analyze these headers and thread related messages together. Make sure you hit View > Sort by > Threaded, and Thunderbird will thread related messages for you.

By default, Thunderbird will NOT analyze the subjects to determine threading.

Extra threading

In case two messages in Alice's inbox refer to message id "SomeMsg1", and the message which has this id no longer exists in Alice's inbox, Thunderbird will thread the two messages together anyway, because they refer to a common ancestor.

Why does threading fail?

Some badly behaved MUAs will fail to set the correct References: or In-Reply-To: headers. This is bad attitude, because the recipient's MUA will have no information to thread the resulting messages together. If Thunderbird Conversations fails to thread messages together, ask the other participants in the conversation to use a modern MUA!

Another reason why threading fails is that there's an email gateway in-between you and your recipient that rewrites Message-IDs. When the message with ID "AliceMsg1" is re-dispatched (say, by an enterprise mail server), its message-id is changed to "FooBar". When Bob replies, there may be a In-Reply-To header, but it refers to "FooBar" instead of "AliceMsg1".

Mailing lists that try to offer different gateways (google groups, email, NNTP) also often exhibit this behavior.

Hidden threading preferences

Using the subject to figure out threading

Thunderbird can be configured to use the email's subjects to figure out threading. This is potentially dangerous, because it might thread together messages that aren't related. If person A sends a message with subject Hello, and another person sends a message with subject Re: Hello, the two will be threaded together always.

To enable this behavior, change the hidden pref mail.strict_threading from true to false.

More aggressive threading

Thunderbird can thread together emails which share a common subject, without requiring the Re: part in the subject.

To enable this behavior, change the hidden pref mail.thread_without_re from false to true.

Why does not Thunderbird Conversations do XXX?

Well Thunderbird Conversations is built inside Thunderbird, so it can't really do more than what Thunderbird's doing already. If you tweak hidden prefs, Thunderbird Conversations will do its best to be compatible, but for ill-formed conversations (i.e. those which do not have correct headers), it will fail to find related messages in other folders. Thunderbird Conversations will continue to work just fine with well-formed conversations.

The following are currently not easily feasible within Thunderbird (although I could provide guidance should anyone be interested in fixing these):

  • manually marking which messages belong to a common thread,
  • fixing the In-Reply-To: of a message which was sent to you,
  • basically anything that implies modifying messages you've already received.

Unrelated threads are grouped together!

Someone was lazy, and instead of composing a new message, just hit "Reply All", and changed the subject. You need to educate these people and tell them not to use reply all when they intend to start a new thread.


Gmail has a very powerful threading algorithm that mixes headers analysis, subject analysis, and content analysis. So it does work better than Thunderbird's threading algorithm. Feel free to start hacking on Thunderbird to improve its threading analysis!