Custom e-mail validator (for 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);
});
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;
}
Q: Why static class? A: Email validator uses internal cache for storing loaded domains. It can be useful for sequential checks.
- https://github.com/MattKetmo/EmailChecker
- https://github.com/FGRibreau/mailchecker
- legacy PHPAuth
domains.json
and legacydatabase_emails_banned.sql