# Email threading broken

**URL:** https://meta.discourse.org/t/email-threading-broken/221879
**Category:** Bug
**Created:** [March 24, 2022, 3:45pm UTC](https://meta.discourse.org/t/email-threading-broken/221879 "2022-03-24T15:45:40Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![tomtjes](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tomtjes/32/131271_2.png) [@tomtjes](https://meta.discourse.org/u/tomtjes)
#### Post date: [March 24, 2022, 3:45pm UTC](https://meta.discourse.org/t/email-threading-broken/221879/1 "2022-03-24T15:45:40Z")

</div>

My email client no longer groups emails from Discourse in threads. I assume it has to do with the fact that `In-Reply-To` never matches a previous `Message-ID`:

First post:

```plaintext
Message-ID: <topic/1084.23319831779de465ac375ecf@mydomain.com>
References: <topic/1084@mydomain.com>

```

1st reply:

```plaintext
Message-ID: <topic/1084/2214.3da8a000c93bc4ebe1be7dc8@mydomain.com>
In-Reply-To: <topic/1084@mydomain.com>
References: <topic/1084@mydomain.com>

```

2nd reply

```plaintext
Message-ID: <topic/1084/2215.9e39f57fbc3836748bbb7407@mydomain.com>
In-Reply-To: <topic/1084/2214.1db1dbd94b11c9d94ca45b3a@mydomain.com>
References: <topic/1084@mydomain.com>

```

My instance runs Discourse 2.9.0.beta2 ([ea3a58d051](https://github.com/discourse/discourse/commits/ea3a58d051c27548cd55afdcc99a38f9512f9a86))

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 25, 2022, 4:06am UTC](https://meta.discourse.org/t/email-threading-broken/221879/2 "2022-03-25T04:06:12Z")

</div>

@martin recently worked on this and fixed issues, can you try updating to latest?

---

<div class="post-metadata">

### Author: ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)
#### Post date: [March 25, 2022, 4:32am UTC](https://meta.discourse.org/t/email-threading-broken/221879/4 "2022-03-25T04:32:36Z")

</div>

Hi @tomtjes ,

Thanks for reporting. We have received a report that this new threading is not working well with Thunderbird, are you using that as your email client, or something else?

We may consider further refinements to it if it’s causing more people issues.

---

<div class="post-metadata">

### Author: ![tomtjes](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tomtjes/32/131271_2.png) [@tomtjes](https://meta.discourse.org/u/tomtjes)
#### Post date: [March 25, 2022, 1:02pm UTC](https://meta.discourse.org/t/email-threading-broken/221879/5 "2022-03-25T13:02:12Z")

</div>

Hmm, so it does indeed depend on the client. My main client is [MailMate](https://freron.com), but I now tested a few other ones and there the threading works just fine.

---

<div class="post-metadata">

### Author: ![traut](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@traut](https://meta.discourse.org/u/traut)
#### Post date: [March 30, 2022, 9:42am UTC](https://meta.discourse.org/t/email-threading-broken/221879/6 "2022-03-30T09:42:17Z")

</div>

I think it’s not the problem of thunderbird, but of any mail client which supports threading. But I don’t know whether the difference between different informations within in-reply-to and references here may depend on different interpretations.

What I actually see is that you fixed References by now, according to rfc5322:  
In-Reply-To: quotes the message-id of the message you reply to.  
References: appends the message id of the replied message to the former references

First post

`Message-ID: <msg-id1>`  
…and no References

1st reply

```plaintext

`
Message-ID: <msg-id2>
In-Reply-To: <msg-id1>
References: <msg-id1>
`

```

2nd reply:  
…

```plaintext
Message-ID: <msg-id3>
In-Reply-To: <msg-id2>
References: <msg-id1> <msg-id2>

```

…

However, you broke the message IDs as indicated within

> [@Mailing list mode: threading is broken](https://meta.discourse.org/t/mailing-list-mode-threading-is-broken/222492):
>
> Hi all, as member of the openstreetmap I found several problems with disourse, which is used for their online forum now. I was told that the mailing list interface should work very well. However, I found a but that threading becomes broken when you reply by e-mail. Then a new message ID is generated instead of re-using the original ones Example The main concept is ok - it used e.g. format: thread msg-id in-reply-id 1 topic/851. the initial thread 1.1 topic/851/2747. topic/851 Message 274…

BTW: Is there another bug that marking multiple lines as `preformatted text` does include the cmd-e marking not once, but many times, for each line one?

---

<div class="post-metadata">

### Author: ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)
#### Post date: [March 30, 2022, 11:04pm UTC](https://meta.discourse.org/t/email-threading-broken/221879/8 "2022-03-30T23:04:45Z")

</div>

Thank you for reporting that too – I hope to schedule some work on on this soonish.

---

<div class="post-metadata">

### Author: ![traut](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@traut](https://meta.discourse.org/u/traut)
#### Post date: [March 30, 2022, 8:15am UTC](https://meta.discourse.org/t/email-threading-broken/221879/9 "2022-03-30T08:15:47Z")

</div>

Hi all, as member of the openstreetmap I found several problems with disourse, which is used for their online forum now.

I was told that the mailing list interface should work very well. However, I found a but that threading becomes broken when you reply by e-mail. Then a new message ID is generated instead of re-using the original ones

Example  
The main concept is ok - it used e.g.

format: thread msg-id in-reply-id  
1 topic/851.

the initial thread

1.1 topic/851/2747. topic/851

Message 2747 in thread 851 is a reply to initial topic 851, as indicated by the headers in-reply-to: and references:

1.1.1 ee76eed4-a255-6d1c-0f5b-59da9772f230@gmx topic/851/2747.

That’s an e-mail reply to topic/851/2747 with message id ee76eed4-a255-6d1c-0f5b-59da9772f230@gmx

1.1.1.1 topic/851/2749. ee76eed4-a255-6d1c-0f5b-59da9772f230@gmx

Here the forum reply 2749 threads properly to my message-id ee76eed4-a255-6d1c-0f5b-59da9772f230@gmx

1.1.1.1.1 07289952-0e88-c08a-ea66-b34774c8554e@gmx topic/851/2749.

…and so on

However, when I do reply in msg-id ee76eed4-a255-6d1c-0f5b-59da9772f230@gmx to the previous topic, I reference

References:… \<topic/851/2747. **bae9c8af72f1f7ef599f1bcd** @OSM\>

But my own message (a HTML forum version) is sent back to me with  
References: …  
\<topic/851/2747. **ae42d62b1252f1572b2a9a07** @OSM\>

Do you notice the difference within the message id of the references?

The forum’s system does break message ids within references!

This results in broken threads with  
1.2 topic/851/2748. topic/851/2747.  
1.3 topic/851/2751. topic/851/2749.

where 1.2 is the forum version of 1.1.1 (new message-id topic/851/2748.e6be773dbcc599ad5f35bae5@OSM instead of my original message-id)  
and 1.3 is the forum version of 1.1.1.1.1

I did not verify yet whether others receive crippled threads - since they would not receive my original reply with message-id of  
1.1.1 ee76eed4-a255-6d1c-0f5b-59da9772f230@gmx,  
but would also receive the forum version  
1.2 with message id topic/851/2748.e6be773dbcc599ad5f35bae5@OSM, while also receiving reply  
1.1.1.1 with references to ee76eed4-a255-6d1c-0f5b-59da9772f230@gmx

I have crippled the domain names here since this forum translates those message IDs to mailto links and thus exceeds my limit of permitted links

---

<div class="post-metadata">

### Author: ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)
#### Post date: [July 29, 2022, 1:24am UTC](https://meta.discourse.org/t/email-threading-broken/221879/10 "2022-07-29T01:24:45Z")

</div>

Closing this topic in favour of [Discourse email messages are incorrectly threaded - #36 by sam](https://meta.discourse.org/t/discourse-email-messages-are-incorrectly-threaded/233499/36) , we are sorting this all out there.

---

<div class="post-metadata">

### Author: ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)
#### Post date: [July 29, 2022, 1:24am UTC](https://meta.discourse.org/t/email-threading-broken/221879/11 "2022-07-29T01:24:47Z")

</div>


