phpauth/phpauth.email-validator

0.1.1 2022-08-23 14:53 UTC

This package is not auto-updated.

Last update: 2024-11-13 23:49:12 UTC


README

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 = [
    'karel.wintersky@gmail.com',
    'foo@0d00.com',
    '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