| Recommend this page to a friend! |
| Info | Documentation | Reputation | Support forum | Blog | Links |
| Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
| 2025-11-08 (1 month ago) | Not yet rated by the users | Total: Not yet counted | Not yet ranked | |||||
| Version | License | PHP version | Categories | |||
| easyemailvalidator 1.0.0 | MIT/X Consortium ... | 8 | Email, Web services, Validation, PHP 8 |
Please read this document to learn how to validate a list of email addresses reading the list of disallowed domains from a provider.
A lightweight PHP package to validate email addresses against allowed and denied domain lists.
Add the package to your project with Composer:
composer require auvernhat/easyemailvalidator
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
EasyEmailValidator supports multiple providers to fetch lists of allowed or denied email domains.
A provider is a PHP class that extends the abstract class ProviderAbstract and implements two methods:
Several providers are included by default:
You can specify the provider to use when creating the validator:
use Auvernhat\EasyEmailValidator\EasyValidator;
use Auvernhat\EasyEmailValidator\Providers\AdamLovingProvider;
$validator = new EasyValidator(new AdamLovingProvider());
$isValid = $validator->validate('[email protected]');
If you don't specify a provider, the default is DisposableProvider:
$validator = new EasyValidator(); // Uses DisposableProvider by default
To add your own provider, create a new class in src/Providers/ that extends ProviderAbstract and implements the required methods:
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 [];
}
}
You can create a custom provider that only allows emails from your own company domain. For example, to only accept @mycompany.com addresses:
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
This is useful if you want to restrict access or registration to your own organization only.
Simple, fast, and effective for filtering disposable emails!
| File | Role | Description | ||
|---|---|---|---|---|
| Data | Auxiliary data | |||
| Lic. | License text | |||
| Data | Auxiliary data | |||
| Doc. | Documentation | |||
| / | src | / | Providers |
| File | Role | Description |
|---|---|---|
| |
Class | Class source |
| |
Class | Class source |
| |
Class | Class source |
| |
Class | Class source |
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
| Version Control | Unique User Downloads | |||||||
| 100% |
|
| Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.