Page 1 of 1

Checking similar gmail email ids

Posted: Mon Aug 15, 2011 6:39 pm
by leon_nerd
Hi Guys,

I am working on an application where we need to have each user input unique email id. Now, the problem is with gmail IDs. In gmail username@gmail is same as user.name@gmail.com which is again same as use.r.name@gmail.com.

Now, how to make sure that only one of a kind of email id is allowed. I am storing the email IDs in the database. Should, I be using a query involving LIKE ? Please suggest.

Re: Checking similar gmail email ids

Posted: Mon Aug 15, 2011 8:49 pm
by Jonah Bron
Before storing them in the database, or querying for them, strip out all dots from the local part of the email address.

Code: Select all

$email = 'john.doe@gmail.com';
$localLength = strpos($email, '@');
$email = substr_replace($email, str_replace('.', '', substr($email, 0, $localLength)),  0, $localLength);
// $email == 'johndoe@gmail.com'
(cite for that Gmail-specific normalization here: http://en.wikipedia.org/wiki/Email_addr ... malization)