简体   繁体   中英

Algorithm to retrieve associated mails present in Inbox of Gmail

I wanted to know the algorithm followed by Gmail to retrieve the associated mails.

Example: I'm considering two people, Tom and John. Tom has started a conversation with John.

Note: these are some representation of mails sent by Tom and John

  (J-mail-1) : John's first mail.
  (T-mail-1) : Tom's first mail.
  (T-mail-2) : Tom's second mail.
  (J-mail-2) : John's second mail.
  (J-mail-3) : John's third mail.
  • Tom: Send a mail from his mail to John.(T-mail-1)
  • John: Reply back to mail to Tom.(J-mail-1)
  • Tom: Again he sent in a same thread to Tom.(T-mail-2)
  • John: This time John, give response to first mail sent by Tom(J-mail-2)
  • John: Again John reply to second mail of tom.(J-mail-3)

Now if we see in the inbox of Tom's Gmail, we can find the response for 1st mail of the John is get associated or mapped with first mail and last mail of Tom.

So, I wanted to know what algorithm in server side is done to perform above type of operation. How is this properly mapped.

Final Outcome of above scenario.(In Tom's Inbox)

(T-mail-1) ::::(Associated/Mapped) ::::: (J-mail-1) and (J-mail-2)

(T-mail-2) :::: (Associated/Mapped) :::::  (J-mail-3)

Thanks

Not sure what exactly Google does, but...

RFC 2822 (among many others) defines email. Each email should have a message ID, passed in the Message-ID: header. When you reply to an email, the mail client should include an In-Reply-To: header with a value of the message id of the message you reply to ( section 3.6.4 ). Now in the inbox, you look at each email, check if it has a In-Reply-To: header, and look for the email with that ID. That would be its parent.

Some retarded email customer support systems may throw away the In-reply-to: header. As a second best guess, you can look at the email's Subject: header and use a regular expression to see if two emails are probably from the same conversation: if they only differ in a "Re:" prefix, they may be in the same conversation. Count the "Re:" prefixes and compare the time stamps to figure out the conversation order.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM