PHP code example of auvernhat / easyemailvalidator
1. Go to this page and download the library: Download auvernhat/easyemailvalidator 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/ */
auvernhat / easyemailvalidator example snippets
use Auvernhat\EasyEmailValidator\EasyValidator;
$validator = new EasyValidator();
// Validate a single email address
$isValid = $validator->validate('[email protected]'); // true or false
// Validate multiple email addresses
$allValid = $validator->validateMultiple([
'[email protected]',
'[email protected]'
]); // true if all are valid, false otherwise
use Auvernhat\EasyEmailValidator\EasyValidator;
use Auvernhat\EasyEmailValidator\Providers\AdamLovingProvider;
$validator = new EasyValidator(new AdamLovingProvider());
$isValid = $validator->validate('[email protected]');
$validator = new EasyValidator(); // Uses DisposableProvider by default
use Auvernhat\EasyEmailValidator\Providers\ProviderAbstract;
class MyCustomProvider extends ProviderAbstract
{
public function getAllowDomains(): array
{
// Return your list of allowed domains
return ['example.com'];
// Return nothing if you only want a deny list
return [];
}
public function getDenyDomains(): array
{
// Return your list of denied domains
return ['tempmail.com', 'mailinator.com'];
// Return nothing if you only want an allow list
return [];
}
}
use Auvernhat\EasyEmailValidator\Providers\ProviderAbstract;
class MyCustomProvider extends ProviderAbstract
{
public function getAllowDomains(): array
{
return ['mycompany.com'];
}
public function getDenyDomains(): array
{
return [];
}
}
$validator = new EasyValidator(new MyCustomProvider);
$res = $validator->validate("[email protected]");
// returns false
$res = $validator->validate("[email protected]");
// returns true
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.