How do I test two email addresses for equality

Viewed 3654

Is there a comprehensive way to test if two email addresses are equal? I know that I can universally LOWER both. But there are some other rules that differ from server to server. For example "william.burroughs@gmail.com", "will.iam.burroughs@gmail.com", and "williamburroughs@gmail.com" are all equivalent for gmail. But I don't think this is true in all cases. So given two email addresses I need to ensure they are equivalent. Currently my code does not consider "william.burroughs@gmail.com" and "williamburroughs@gmail.com" to be the same. I can start special casing something like "gmail" so they are but I was hoping there is a better approach.

4 Answers
Related