PHPackages                             imliam/php-unique-gmail-address - 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. imliam/php-unique-gmail-address

ActiveLibrary

imliam/php-unique-gmail-address
===============================

Ensure that a Gmail address is unique

v2.0.0(1y ago)914.9k4[1 PRs](https://github.com/imliam/php-unique-gmail-address/pulls)MITPHPPHP ^8.0CI passing

Since Sep 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/imliam/php-unique-gmail-address)[ Packagist](https://packagist.org/packages/imliam/php-unique-gmail-address)[ Docs](https://github.com/imliam/php-unique-gmail-address)[ GitHub Sponsors](https://github.com/imliam)[ RSS](/packages/imliam-php-unique-gmail-address/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (5)Used By (0)

Unique Gmail Address
====================

[](#unique-gmail-address)

[![Latest Version on Packagist](https://camo.githubusercontent.com/882f0cee5fa3955264f543d648cb6f0d9c3c1d19fc77cd2737446833bf0f5f76/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696d6c69616d2f7068702d756e697175652d676d61696c2d616464726573732e737667)](https://packagist.org/packages/imliam/php-unique-gmail-address)[![Total Downloads](https://camo.githubusercontent.com/9d7573726e50a36a8c78012e40e905be4c24ab5ac2aa4055b5f410d473f7e6b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696d6c69616d2f7068702d756e697175652d676d61696c2d616464726573732e737667)](https://packagist.org/packages/imliam/php-unique-gmail-address)

A package to ensure that a Gmail address is unique.

The Gmail platform offers some features that other email platforms don't. There can be an infinite number of different Gmail addresses that point to a single Gmail inbox/account, which can make it very easy for malicious users to abuse with no effort.

To learn more about how a user can make a infinite addresses for one Gmail inbox, [check out this article](https://liamhammett.com/make-infinite-gmail-addresses-for-one-inbox-nqoVprjX).

This package makes it possible to **detect duplicate addresses for one Gmail account** and to ensure they're unique.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require imliam/php-unique-gmail-address
```

Usage
-----

[](#usage)

The primary usage of this package revolves around the supplied `UniqueGmailAddress` class, which can be passed an email address to compare:

```
$email = new UniqueGmailAddress('example@gmail.com');
```

The `isGmailAddress` method will check if the given address belongs to a Gmail account:

```
$one = new UniqueGmailAddress('example@gmail.com');
$one->isGmailAddress(); // true

$two = new UniqueGmailAddress('example@googlemail.com');
$two->isGmailAddress(); // true

$three = new UniqueGmailAddress('example@example.com');
$three->isGmailAddress(); // false
```

The `normalizeAddress` method will take an email address and normalize it to the simplest variation:

```
$email = new UniqueGmailAddress('ex.am.ple+helloworld@googlemail.com');
$email->normalizeAddress(); // example@gmail.com
```

> ⚠️ It's best to save and use the email address exactly as the user gave instead of only saving a normalized version. If a user enters a denormalized email address, they probably expect any emails they receive to be at that exact address and not the normalized version.

The `getRegex` and `getRegexWithDelimeters` methods will return a regular expression that can be used to compare the original email address to another one, using a function like `preg_match`:

```
$email = new UniqueGmailAddress('example@gmail.com');
$email->getRegex(); // ^e(\.?)+x(\.?)+a(\.?)+m(\.?)+p(\.?)+l(\.?)+e(\+.*)?\@(gmail|googlemail).com$
```

The `matches` method will immediately match the regular expression against another value, returning `true` if both email addresses belong to the same Gmail account:

```
$email = new UniqueGmailAddress('example@gmail.com');
$email->matches('ex.am.ple+helloworld@googlemail.com'); // true
```

Laravel Rule
------------

[](#laravel-rule)

One of the most common use cases for wanting to check duplicate Gmail accounts is to prevent multiple users signing up to your service with the same email address.

To handle this case, the package also provides a [Laravel validation rule class](https://laravel.com/docs/master/validation) that can be used to check the database if a matching email address is already present.

```
$request->validate([
    'email' => [new UniqueGmailAddressRule()],
]);
```

By default, it will check the `email` column in the `users` table, but these can be overriden if needed when using the rule:

```
$request->validate([
    'email' => [new UniqueGmailAddressRule('contacts', 'email_address')],
]);
```

**This rule assumes that you are storing denormalized email addresses in the database.** This rule will use a regex match against every row in the database to check if

> 💡 If you don't want to use a regex match against every row of the database, you could instead store the normalized email address in a second column alongside the original email address, for example in a `normalized_email` column.
>
> This would allow you use the regular [exists](https://laravel.com/docs/master/validation#rule-exists) rule to do a direct match against, much more efficiently.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Liam Hammett](https://github.com/ImLiam)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance44

Moderate activity, may be stable

Popularity34

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 85% 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

Every ~1639 days

Total

2

Last Release

435d ago

Major Versions

v1.0.0 → v2.0.02025-03-09

PHP version history (2 changes)v1.0.0PHP ^7.4

v2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3e8a14b9f997cf85aacea7d39da9dc33c38cc05fe03360578327ea9bcb25f4d9?d=identicon)[ImLiam](/maintainers/ImLiam)

---

Top Contributors

[![imliam](https://avatars.githubusercontent.com/u/4326337?v=4)](https://github.com/imliam "imliam (17 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (2 commits)")[![paulhennell](https://avatars.githubusercontent.com/u/4799852?v=4)](https://github.com/paulhennell "paulhennell (1 commits)")

---

Tags

gmaillaravelphpimliamphp-unique-gmail-address

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/imliam-php-unique-gmail-address/health.svg)

```
[![Health](https://phpackages.com/badges/imliam-php-unique-gmail-address/health.svg)](https://phpackages.com/packages/imliam-php-unique-gmail-address)
```

###  Alternatives

[imliam/laravel-env-set-command

Set a .env file variable from the command line

118352.4k10](/packages/imliam-laravel-env-set-command)[imliam/laravel-blade-helper

An easier way to define custom Blade directives.

185121.0k](/packages/imliam-laravel-blade-helper)[imliam/laravel-throttle-simultaneous-requests

Throttle the current user's requests based on how many requests are currently being executed.

4623.0k](/packages/imliam-laravel-throttle-simultaneous-requests)

PHPackages © 2026

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