eusonlito / disposable-email-validator
A PHP package to detect disposable emails based on multiple lists.
Installs: 52 203
Dependents: 1
Suggesters: 0
Security: 0
Stars: 8
Watchers: 4
Forks: 2
Open Issues: 0
Requires
- php: >=5.4
Requires (Dev)
- fgribreau/mailchecker: master-dev
- ivolo/disposable-email-domains: master-dev
- martenson/disposable-email-domains: *
- mattketmo/email-checker: master-dev
README
Validate emails against multiple databases with disposable email domains.
Current databases (domains, wildcard and whitelist):
- https://github.com/ivolo/disposable-email-domains
- https://github.com/MattKetmo/EmailChecker
- https://github.com/fgribreau/mailchecker
- https://github.com/martenson/disposable-email-domains
Installation
Via Composer:
composer require eusonlito/disposable-email-validator
Usage
Basic use of email validator against built-in domains list:
<?php require __DIR__.'/vendor/autoload.php'; use Eusonlito\DisposableEmail\Check; // Simple // Validate emailFilter, domain and wildcard Check::email('me@my-email.com'); // true Check::email('me@10minutemail.com'); // false // Other methods Check::emailFilter('me@my-email.com'); // Validate email with filter_var Check::emailExpression('me@my-email.com'); // Validate email with regular expression Check::domain('my-email.com'); // Validate domain and wildcard domains Check::wildcard('my-email.com'); // Validate only wildcard domains
Integration with Laravel 5
To integrate this library with your Laravel 5.x project add the following
line to the providers
key within your config/app.php
file:
'providers' => [ ... Eusonlito\DisposableEmail\Laravel\DisposableEmailServiceProvider::class ... ];
You can then use the library within your project like so:
<?php use InvalidArgumentException; use Eusonlito\DisposableEmail\Check; class Signup { public function validate(Request $request) { if (!Check::email($request->input('email'))) { throw new InvalidArgumentException('Invalid email'); } } public function getValidator(array $data) { return Validator::make($data, [ 'email' => 'required|email|disposable_email' // Use after email validator ]); } }