This package provides a method for determining whether an email address is a disposable / temporary email address.
All credit to the maintaining of the list of disposable / temporary email addresses goes to https://raw.githubusercontent.com/disposable/disposable-email-domains.
Emails are added from https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.txt
To install via Composer:
composer require martynasbakanas/php-disposable-emails
<?php
...
use MartynasBakanas\PHPDisposableEmails\EmailCheck;
public function register(): void
{
...
$this->app->singleton('email-check', function () {
return new EmailCheck();
});
}
public function boot(): void
{
...
Validator::extend('not-disposable', function ($attribute, $value, $parameters) {
return app('email-check')->isValid($value);
});
}
public function store(Request $request)
{
$request->validate([
'email' => [
'required',
'email',
'max:255',
'unique:users',
'not-disposable'
],
];
...
}