Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Email threading

I'm working at a helpdesk application where i have a standalone script that queries a mail server and parses the mail it finds there.
I'm facing the following issue: How do i figure it out in a reliable way what mail is in reply to what mail?
I could add something in the subject like "[ticket:21312]" and look for that but what if the user changes the subject? Is there another way? Can i do it by setting a custom mail header and look for that or the header will not be preserved between mail servers on reply back from user? What about when i send a message from my application to a non existing user or a user that has quota full and his server replies back with the usual standard message "the mail daemon at .... could not ...." then the subject will also be modified and i can't place the message correctly as a reply to an existing mail.

How does gmail do it? There the messages are sorted perfectly in almost all of the cases.

like image 314
daniels Avatar asked Dec 29 '22 07:12

daniels


1 Answers

in helpdesk email piping there are 3 basic methods:

a) include the id in the subject somewhere (works fine in practice)

b) have the id in the body somewhere

c) use an auto-generated email alias with the id, like "[email protected]". that can easily be handled by something like procmail or a script to pick out the id.

gmail might use a combination of the subject, In-Reply-To header (may not be defined) (References and Original-Message-ID headers possibly as well), and various heuristics, which work very well, but of course not necessarily bulletproof, and slightly more involved to implement. something like nestscape's original threading algorithm perhaps. though some have reported that gmail doesn't use the In-Reply-To header and relies mostly on the subject (as in this post).

like image 151
jspcal Avatar answered Jan 18 '23 16:01

jspcal