1. Go to this page and download the library: Download citco/email-validator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
citco / email-validator example snippets
// Include the composer autoloader
lValidatorFactory::create('[email protected]');
$jsonResult = $validator->getValidationResults()->asJson();
$arrayResult = $validator->getValidationResults()->asArray();
echo $jsonResult;
namespace EmailValidation\Validations;
class GmailValidator extends Validator
{
public function getValidatorName(): string
{
return 'is_gmail';
}
public function getResultResponse(): bool
{
$hostName = $this->getEmailAddress()->getHostPart();
return strpos($hostName, 'gmail.com') !== false;
}
}
use EmailValidation\Validations\GmailValidator;
eate('[email protected]');
$validator->registerValidator(new GmailValidator());
echo $validator->getValidationResults()->asJson();
declare(strict_types=1);
namespace EmailValidation;
class CustomEmailDataProvider implements EmailDataProviderInterface
{
public function getEmailProviders(): array
{
return ['custom.com'];
}
public function getTopLevelDomains(): array
{
return ['custom'];
}
public function getDisposableEmailProviders(): array
{
return ['custom.com', 'another.com'];
}
public function getRoleEmailPrefixes(): array
{
return ['custom'];
}
}