[ZBX-18307] emails are not grouped to threads in Gmail web client Created: 2020 Aug 27  Updated: 2024 Apr 10  Resolved: 2022 Jun 03

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 5.0.3
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: Oleksii Zagorskyi Assignee: Zabbix Development Team
Resolution: Won't fix Votes: 2
Labels: gmail, threading
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
Team: Team C

 Description   

It's related to ZBXNEXT-1899.

I've tested and I can see that simple alerts, where the only difference in Subject is PROBLEM|OK first word, having the same "In-Reply-To" header are not grouped in Gmail.

But they are nicely grouped in Thunderbird, as it should !

Just FYI: What is the fun, that multiple emails (trigger multiple problems generation) having the same Subject, but sent by different events, so having different  "In-Reply-To" headers - they are grouped in Gmail, which probably not what we planned to have.

Would be nice if Gmail cold group email the same way as classic clients.

This article could explain why it happens - https://gsuiteupdates.googleblog.com/2019/03/threading-changes-in-gmail-conversation-view.html

Gmail want to use "Message-Id" header, which was considered by our devs during designing the feature, but not selected for unknown reason.



 Comments   
Comment by Pavel [ 2020 Aug 27 ]

It looks like Gmail never groups messages with different subjects despite of matching References/In-Reply-To with Message-Id. So, if the first message have "PROBLEM" in subject and second message have "OK", there is no way to group them into thread on Gmail.

But... Gmail can have dynamic message content. It's possible to update message in Gmail inbox according to alarm state.

Comment by Artjoms Rimdjonoks [ 2020 Sep 08 ]

Investigation

Zabbix mechanism of grouping e-mails currently relies on attaching the hashed event id to the "In-Reply-to" header with "@zabbix.com" at the end:

In-Reply-To: 75.507cfa22746afcfb0c66285ae6e8a412.1.a989dfbbbba75c6abfd6fe11fd2f900f@zabbix.com

The event-id used for the reply comes from the Problem for both Problem and Recovery:

Problem:  eventid 78, In-Reply-To id:  hash(78)+"@zabbix.com"
Recovery: eventid 79, In-Reply-To id:  hash(78)+"@zabbix.com"

So that "In-Reply-to" is the same for the both Problem and Recovery.

Needless to say such message does not exist. However, Thunderbird does not care and happily groups such messages into the same thread as long as their "In-Reply-to" is the same.

Gmail however, apparently requires the "In-Reply-To" point to the valid "Message-ID" that it can find:

In-Reply-To: <[email protected]>

Only then, it will group emails into the thread. Note that "References:" header might or might not be present. Threading that relies on the "In-Reply-To" header does not require that.

The "References:" header is only required (in Gmail) for the threading that relies on the emails having:

    The same sender or recipients,
    The same subject,
    And is sent within one week of an earlier message in the thread.

but that does not seem to be a suitable mechanism for Zabbix. (we need to group e-mails regardless of the subject since problem and resolution might have different subjects).
So that, if we decided to stop relying on the "In-Reply-To" header for threading and started using the "Subject" - we would still have to store the previous "Message-ID".

Proposed Fix

So, that leaves us continuing relying on the "In-Reply-To" header. It would need to be changed, so that it no longer hashes the event id but instead references the previous e-mail. We would need to save the "Message-ID" of the previously sent e-mail somewhere in the database (in alerts tables) and then use it instead of the event id.

Although adding "References" header is not required - we still could add it in addition to the modified "In-Reply-To" header. It would have the same value as the "In-Reply-To" . Gmail does it when it generates its own reply-to messages:

References: <[email protected]>
In-Reply-To: <[email protected]>

Note
I did not test any of this with Outlook. (but it seems that using the "In-Reply-To" header that references the real-email should be enough)

UPDATE

I was wrong saying that Gmail can group messages using In-Reply-To headers. Actually, Gmail ONLY groups messages if they have the same Subject. Response Message can have the correct In-Reply-To and References headers but it is irrelevant. I was confused in my initial tests because I used there the same Subject.

This is easy to test. Just reply to an existing email from Gmail web interface but edit the subject - it will not be threaded (even all In-Reply-To/References headers correctly point to the original message).

There seems to be no any way to group emails with different Subjects in Gmail.

Comment by Kim Jongkwon [ 2024 Feb 02 ]

I found some guidelines on how Gmail handles email grouping, LINK

Emails are grouped if each message meets the following:

  • The same recipients, senders, or subject as a previous message
  • A reference header with the same IDs as a previous message
  • Sent within one week of a previous message
Generated at Sat May 31 03:21:56 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.