PHP – Gmail Address Normalization

An email address from Google’s Gmail can be transformed in various ways into different looking email addresses while still going to the same account. A Gmail user can do the following to have multiple email addresses:

  • Using a plus address: is really
  • Changing the host to; is
  • Adding additional dots to the name: still goes to

To see which Gmail email addresses belong to the same account, run them through gmail_address() and verify if any of the results are

function gmail_address($mail) {
  $mail_part = explode(‘@’, strtolower($mail));
  if ($mail_part[1] !== ‘’ && $mail_part[1] !== ‘’) {
    return $mail;
  $plus_position = strpos($mail_part[0], ‘+’);
  if ($plus_position !== false) {
    $mail_part[0] = substr($mail_part[0], 0, $plus_position);
  return str_replace(‘.’, ”, $mail_part[0]) . ‘’;

Examples of usage:

echo gmail_address(‘’); //
echo gmail_address(‘’);     //
echo gmail_address(‘’); //

Other email addresses are returned unmodified.

Leave a Reply

Your email address will not be published. Required fields are marked *