Google Mail Conversation Threading, and how to prevent
Tired of Google mail taking your e-mail and matching it to a gmail conversation incorrectly? Google mail has many cool features, one of which is the e-mail conversation thread view. This view shows e-mails matched based on subject, time, and correspondence grouped together to see a chronological conversation. While this is a neat feature that has made Gmail unique for so long, it can become cumbersome to companies and web developers as they try to ship out monthly statements, e-mail notices, or any other e-mail that for some reason has the same subject every time it is sent out.
The question I asked was: Is it sufficient to change the subject text every time I send out an e-mail?
The answer was no. The reason(s) were simple: the e-mail may need the same subject and/or you may not want to send your customer an e-mail with a unique character sequence in it that the user can see and potentially become confused about.
The solution: Follow suit with another cool feature Google mail has made apparent, the use of virtual inboxing. Add a short web-friendly unique code to your e-mail address username, appending with a + sign.
ephekt@gmail.com becomes ephekt+nM2eY@gmail.com
The key to this is that you should have a friendly name on your e-mail so that the recipient does not see the difference in e-mail addresses. Thus, with slight modification we now arrive at:
Mike R <ephekt@gmail.com> becomes Mike R <ephekt+nM2eY@gmail.com>
And to the end user all is sane. There are a few ways to generate unique tokens... In a Ruby on Rails project I used the built-in base 64 encoder, passing in a random number up to 3 characters long so that my generated code would not only be highly unique but relatively short.
def friendly_email_token ActiveSupport::Base64.encode64(rand(0x10000).to_s).tr("/+","_.").gsub(/=*\n/,"") end
Just throw the above method into one of your classes and then you can define a method that appends this friendly_email_token to your e-mail address.
def randomize_address email unless email.blank? username, domain = email.split("@", 2) "#{username}+{friendly_email_token}@#{domain}" end end
And voila! We're good to go. Call the randomize_address method with your e-mail (with or without a friendly name) and it will do the work.