Skip to content

Track, deduplicate and unalias Google Mail and Google Apps emails

License

Notifications You must be signed in to change notification settings

lucasmichot/unaliaser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unaliaser

A PHP library to track, de-duplicate and un-alias Google Mail and Google Apps emails.

Latest Stable Version Total Downloads Build Status

Requiring / Loading

If you're using Composer to manage dependencies, you can include the following in your composer.json file:

"require": {
    "unaliaser/unaliaser": "dev-master"
}

Then, after running composer update or php composer.phar update, you can load the class using Composer's autoloading:

require 'vendor/autoload.php';

Otherwise, you can simply require the file directly:

require_once 'path/to/Unaliaser/src/Unaliaser/Unaliaser.php';

Methods

__construct()

Creates a new instance of Unaliaser.

$unaliaser = new Unaliaser('[email protected]');

If the email is not valid, an InvalidArgumentExcpetion will be thrown.

cleanEmail()

Returns a clean email.

$unaliaser = new Unaliaser('  [email protected]  ');
echo $unaliaser->cleanEmail();
// '[email protected]'

domainName()

Returns a the domain name for the email.

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->domainName();
// 'bar.com'

isGmail()

Check if an email is managed by Google Mail.

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGmail();
// true

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGmail();
// false

isGoogleApps()

Check if an email is managed by Google Apps.

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGoogleApps();
// false

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGoogleApps();
// false

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGoogleApps();
// true

isGoogle()

Check if an email is managed by Google (Gmail or Google Apps).

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGoogle();
// true

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGoogle();
// false

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGoogle();
// true

uniqueDomainName()

Get the unique domain name for a Gmail address.

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->uniqueDomainName();
// 'gmail.com'

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->uniqueDomainName();
// 'googlemail.com'

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->uniqueDomainName();
// 'yahoo.com'

mxRecords()

Get the MX records for the domain name of an email address.

$unaliaser = new Unaliaser('[email protected]');
print_r($unaliaser->mxRecords());
// display an array containing various MX records for the domain of this email address

userName()

Get the username for an email address.

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userName();
// 'johndoe'

userAlias()

Get the user alias for a Google address, if any.

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userAlias();
// 'dummyalias'

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userAlias();
// null

hasUserAlias()

Determines if a Google email address contains an user alias.

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->hasUserAlias();
// false

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->hasUserAlias();
// true

userOrigin()

Get the original username for a email.

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userOrigin();
// 'johndoe+alias'

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userOrigin();
// 'johndoe'

userUndottedOrigin()

Get the original un-dotted username for a Google address.

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userUndottedOrigin();
// 'john.doe'

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userUndottedOrigin();
// 'johndoe'

userIsDotted()

Determines if a Google address is dotted.

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userIsDotted();
// false

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userIsDotted();
// true

unique()

Get the unique email address.

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->unique();
// '[email protected]'

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->unique();
// '[email protected]'

isUnique()

Determines if the provided email is unique (dotted or aliased).

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isUnique();
// true

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isUnique();
// false

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isUnique();
// false

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isUnique();
// true

Tests

From the project directory, tests can be ran using phpunit

License

Released under the MIT License - see LICENSE.txt for details.

About

Track, deduplicate and unalias Google Mail and Google Apps emails

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages