Skip to content

PHPAuth/PHPAuth.EMailValidator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHPAuth.EmailValidator

Custom e-mail validator (for PHPAuth)

Use with PHPAuth

require_once __DIR__ . '/path/to/vendor/autoload.php';

// ...

$config = new \PHPAuth\Config($pdo);

$config = $config->setEMailValidator(static function ($email) {
    return \PHPAuth\EMailValidator::isValid($email);
});

Standalone usage:

require_once __DIR__ . '/path/to/vendor/autoload.php';

$l = [
    '[email protected]',
    '[email protected]',
    'xxxx'
];

foreach ($l as $e) {
    var_dump(\PHPAuth\EMailValidator::check($e)->state);
    echo "{$e} ==> " . ( \PHPAuth\EMailValidator::isValid($e) ? 'VALID' : 'INVALID' ) . PHP_EOL;
}

FAQ

Q: Why static class? A: Email validator uses internal cache for storing loaded domains. It can be useful for sequential checks.

Thanks to