Skip to content

Latest commit

 

History

History
49 lines (32 loc) · 979 Bytes

README.md

File metadata and controls

49 lines (32 loc) · 979 Bytes

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