Shubham Kumar
Shubham Kumar

Reputation: 31

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.

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

Upvotes: 1

Views: 130

Answers (1)

Robert
Robert

Reputation: 8683

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.

Upvotes: 1

Related Questions