1. Go to this page and download the library: Download stymiee/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/ */
use EmailValidator\Validator\AValidator;
use EmailValidator\EmailAddress;
use EmailValidator\Policy;
class MyCustomValidator extends AValidator
{
public function validate(EmailAddress $email): bool
{
// Your custom validation logic here
return $email->getDomain() === 'example.com';
}
}
// Register your custom validator
$emailValidator = new EmailValidator();
$emailValidator->registerValidator(new MyCustomValidator(new Policy()));
// Use it like any other validator
$isValid = $emailValidator->validate('[email protected]');