PHPackages                             danjam/gmail-matcher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. danjam/gmail-matcher

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

danjam/gmail-matcher
====================

Library to check and match the varying formats of Gmail addresses

1.0.0(7y ago)03MITPHPPHP ^7.1

Since Feb 8Pushed 7y ago1 watchersCompare

[ Source](https://github.com/danjam/gmail-matcher)[ Packagist](https://packagist.org/packages/danjam/gmail-matcher)[ Docs](https://github.com/danjam/gmail-matcher)[ RSS](/packages/danjam-gmail-matcher/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (11)Versions (2)Used By (0)

gmail-matcher
=============

[](#gmail-matcher)

[![Latest Stable Version](https://camo.githubusercontent.com/917f8c4bec3775cda5d80c541c82461ecb2f770e4b5446415656cc3f44ed8d30/68747470733a2f2f706f7365722e707567782e6f72672f64616e6a616d2f676d61696c2d6d6174636865722f762f737461626c65)](https://packagist.org/packages/danjam/gmail-matcher) [![Build Status](https://camo.githubusercontent.com/eef48b134f983f2106d34ffa17f20aa95794dc7bfce7b9ed8b47908546b3687f/68747470733a2f2f7472617669732d63692e6f72672f64616e6a616d2f676d61696c2d6d6174636865722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/danjam/gmail-matcher) [![Coverage Status](https://camo.githubusercontent.com/054be90522996d9682cbb70cb9accf49314f182f05020a8c04067e7f2c304ad9/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f64616e6a616d2f676d61696c2d6d6174636865722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/danjam/gmail-matcher?branch=master) [![Infection MSI](https://camo.githubusercontent.com/f51e2f25c5cf7e56fd4eb4059316183f593fa4692a13e7f6a35a4153e0a95cde/68747470733a2f2f62616467652e737472796b65722d6d757461746f722e696f2f6769746875622e636f6d2f64616e6a616d2f676d61696c2d6d6174636865722f6d6173746572)](https://infection.github.io)

**TL;DR: This is a PHP 7.1+ class that can normalize and compare different formats of the same Gmail address.**

Gmail address rules have some caveats:

- Dots in email addresses are disregarded (`foobar@gmail.com` is the same as `foo.bar@gmail.com`). ([Source](https://support.google.com/mail/answer/7436150))
- Addresses are case insensitive (`FOOBAR@gmail.com` is the same as `foobar@gmail.com`)
- The `gmail.com` domain is interchangeable with `googlemail.com` (`foobar@gmail.com` is the same as `foobar@googlemail.com`) ([Source](https://support.google.com/mail/answer/10313))
- Pluses are allowed in emails (`foobar+baz@gmail.com`)

Because of this it is very possible for a system to have multiple variations of the same Gmail address associated with different users.

This class attempts to address this by providing a `match(…)` method to check variations against each other and a `normalize(…)` method to retrieve a normalized version of the address. Also exposed is a method for determining if an address is a Gamil address, `isGmailAddress(…)`.

Between these three methods it should be possible to check, normalize and store Gmail addresses, for example to prevent duplicate signups within a system.

Install
-------

[](#install)

Via [Composer](https://getcomposer.org/)

```
$ composer require danjam/gmail-matcher

```

Usage
-----

[](#usage)

```
// instantiate new matcher
$gmailMatcher = new \danjam\GmailMatcher\GmailMatcher();

// you can also specify the domain used when normalizing. Must be one of gmail.com, googlemail.com. Defaults to gmail.com
$gmailMatcher = new \danjam\GmailMatcher\GmailMatcher('googlemail.com');

// normalizes the address - returns foo@gmail.com
$gmailMatcher->normalize('F.O.O@gmail.com');

// check if two addresses are the same - returns true
$gmailMatcher->match('F.O.O@gmail.com', 'foo@gmail.com');

// returns false
$gmailMatcher->match('foo@gmail.com', 'bar@gmail.com');

// returns false - addresses with + should NOT be treated as the same address
$mailMatcher->match('foo@gmail', 'foo+bar@gmail.com');

// multiple addresses
$gmailMatcher->match('bar@gmail.com', 'b.a.r@gmail.com', 'bar@googlemail.com', ...);

// validate the address is a Gmail address - returns true
$gmailMatcher->isGmailAddress('foo@gmail.com');

// returns false
$gmailMatcher->isGmailAddress('bar@example.com');
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2652d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab7117085b0953f370a4f79432658f65f17f393c1f0342fd77558c184f78f1dc?d=identicon)[danjam](/maintainers/danjam)

---

Top Contributors

[![danjam](https://avatars.githubusercontent.com/u/3920749?v=4)](https://github.com/danjam "danjam (5 commits)")

---

Tags

gmail

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/danjam-gmail-matcher/health.svg)

```
[![Health](https://phpackages.com/badges/danjam-gmail-matcher/health.svg)](https://phpackages.com/packages/danjam-gmail-matcher)
```

###  Alternatives

[benpickles/peity

Peity (sounds like deity) is a jQuery plugin that converts an element's content into a mini `&lt;svg&gt;` pie, donut, line or bar chart.

4.2k2.8k](/packages/benpickles-peity)[2amigos/yii2-grid-view-library

GridView Widget Extensions for Yii2.

56147.2k12](/packages/2amigos-yii2-grid-view-library)[zhuravljov/yii2-datetime-widgets

Datetime widgets for Yii2.

21118.6k3](/packages/zhuravljov-yii2-datetime-widgets)[smajti1/laravel-wizard

Wizard component for laravel.

409.2k](/packages/smajti1-laravel-wizard)[tivie/command

An utility library that harmonizes OS differences and executes external programs in a safer way

1455.3k1](/packages/tivie-command)[jfcherng-roundcube/show-folder-size

A Roundcube plugin which shows folder size.

2515.2k](/packages/jfcherng-roundcube-show-folder-size)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
