Unaliaser
A PHP library to track, de-duplicate and un-alias Google Mail and Google Apps emails., (*1)
, (*2)
Requiring / Loading
If you're using Composer to manage dependencies, you can include the following
in your composer.json file:, (*3)
"require": {
"unaliaser/unaliaser": "dev-master"
}
Then, after running composer update or php composer.phar update, you can
load the class using Composer's autoloading:, (*4)
require 'vendor/autoload.php';
Otherwise, you can simply require the file directly:, (*5)
require_once 'path/to/Unaliaser/src/Unaliaser/Unaliaser.php';
Methods
__construct()
Creates a new instance of Unaliaser., (*6)
$unaliaser = new Unaliaser('foo@bar.com');
If the email is not valid, an InvalidArgumentExcpetion will be thrown., (*7)
cleanEmail()
Returns a clean email., (*8)
$unaliaser = new Unaliaser(' FOO@BAR.COM ');
echo $unaliaser->cleanEmail();
// 'foo@bar.com'
domainName()
Returns a the domain name for the email., (*9)
$unaliaser = new Unaliaser('foo@bar.com');
echo $unaliaser->domainName();
// 'bar.com'
isGmail()
Check if an email is managed by Google Mail., (*10)
$unaliaser = new Unaliaser('johndoe@gmail.com');
echo $unaliaser->isGmail();
// true
$unaliaser = new Unaliaser('johndoe@yahoo.com');
echo $unaliaser->isGmail();
// false
isGoogleApps()
Check if an email is managed by Google Apps., (*11)
$unaliaser = new Unaliaser('johndoe@gmail.com');
echo $unaliaser->isGoogleApps();
// false
$unaliaser = new Unaliaser('johndoe@yahoo.com');
echo $unaliaser->isGoogleApps();
// false
$unaliaser = new Unaliaser('johndoe@semalead.com');
echo $unaliaser->isGoogleApps();
// true
isGoogle()
Check if an email is managed by Google (Gmail or Google Apps)., (*12)
$unaliaser = new Unaliaser('johndoe@gmail.com');
echo $unaliaser->isGoogle();
// true
$unaliaser = new Unaliaser('johndoe@yahoo.com');
echo $unaliaser->isGoogle();
// false
$unaliaser = new Unaliaser('johndoe@semalead.com');
echo $unaliaser->isGoogle();
// true
uniqueDomainName()
Get the unique domain name for a Gmail address., (*13)
$unaliaser = new Unaliaser('johndoe@gmail.com');
echo $unaliaser->uniqueDomainName();
// 'gmail.com'
$unaliaser = new Unaliaser('johndoe@googlemail.com');
echo $unaliaser->uniqueDomainName();
// 'googlemail.com'
$unaliaser = new Unaliaser('johndoe@yahoo.com');
echo $unaliaser->uniqueDomainName();
// 'yahoo.com'
mxRecords()
Get the MX records for the domain name of an email address., (*14)
$unaliaser = new Unaliaser('johndoe@gmail.com');
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., (*15)
$unaliaser = new Unaliaser('johndoe@gmail.com');
echo $unaliaser->userName();
// 'johndoe'
userAlias()
Get the user alias for a Google address, if any., (*16)
$unaliaser = new Unaliaser('johndoe+dummyalias@gmail.com');
echo $unaliaser->userAlias();
// 'dummyalias'
$unaliaser = new Unaliaser('johndoe@gmail.com');
echo $unaliaser->userAlias();
// null
hasUserAlias()
Determines if a Google email address contains an user alias., (*17)
$unaliaser = new Unaliaser('johndoe+alias@yahoo.com');
echo $unaliaser->hasUserAlias();
// false
$unaliaser = new Unaliaser('johndoe+alias@gmail.com');
echo $unaliaser->hasUserAlias();
// true
userOrigin()
Get the original username for a email., (*18)
$unaliaser = new Unaliaser('johndoe+alias@yahoo.com');
echo $unaliaser->userOrigin();
// 'johndoe+alias'
$unaliaser = new Unaliaser('johndoe+alias@gmail.com');
echo $unaliaser->userOrigin();
// 'johndoe'
userUndottedOrigin()
Get the original un-dotted username for a Google address., (*19)
$unaliaser = new Unaliaser('john.doe@yahoo.com');
echo $unaliaser->userUndottedOrigin();
// 'john.doe'
$unaliaser = new Unaliaser('john.doe@gmail.com');
echo $unaliaser->userUndottedOrigin();
// 'johndoe'
userIsDotted()
Determines if a Google address is dotted., (*20)
$unaliaser = new Unaliaser('john.doe@yahoo.com');
echo $unaliaser->userIsDotted();
// false
$unaliaser = new Unaliaser('john.doe@gmail.com');
echo $unaliaser->userIsDotted();
// true
unique()
Get the unique email address., (*21)
$unaliaser = new Unaliaser('john.doe+alias@yahoo.com');
echo $unaliaser->unique();
// 'john.doe+alias@yahoo.com'
$unaliaser = new Unaliaser('john.doe+alias@googlemail.com');
echo $unaliaser->unique();
// 'johndoe@gmail.com'
isUnique()
Determines if the provided email is unique (dotted or aliased)., (*22)
$unaliaser = new Unaliaser('john.doe+alias@yahoo.com');
echo $unaliaser->isUnique();
// true
$unaliaser = new Unaliaser('john.doe+alias@googlemail.com');
echo $unaliaser->isUnique();
// false
$unaliaser = new Unaliaser('johndoe@googlemail.com');
echo $unaliaser->isUnique();
// false
$unaliaser = new Unaliaser('johndoe@gmail.com');
echo $unaliaser->isUnique();
// true
Tests
From the project directory, tests can be ran using phpunit, (*23)
License
Released under the MIT License - see LICENSE.txt for details., (*24)