Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to track an email thread programmatically

Tags:

email

I'm working on a system that handles customer inquiries and sends emails to customers related to their inquiries. When a customer replies, I need to know which inquiry (and email thread) the email belongs to. One customer may have multiple inquiries, so I cannot tell this just based on her email address.

I tried to google a bit and it seems that adding some kind of inquiry ID to the subject and the body may be a solution, but this is not 100% safe (customer can delete both).

I also see that for example AirBnb sends customer emails from a special, unique email address and my reply also goes back to that address, but I don't know if it is an inquiry specific email address or what.

As this seems to be a common problem in similar systems, I would appreciate any pointers to best practices.

like image 311
wanderlusted Avatar asked Feb 21 '26 15:02

wanderlusted


1 Answers

I'm not sure if this completely fits your needs, but there is a standard algorithm that mail clients use to group messages by "conversation" that is described by Jamie Zawinski here and, later, by the IETF Standards Organization, here.

There are a number of implementations of this algorithm for various languages including my own implementation in c# (source code). Typically you can search for it by the name "jwz threading algorithm".

like image 100
jstedfast Avatar answered Feb 25 '26 00:02

jstedfast