A Laravel Wrapper for the MailCheck.ai disposable email API made by @tompec.
This package was previously called "Validator.Pizza". See the following guide if you want to migrate your previous installation.
Migration Guide
composer remove romanzipp/laravel-validator-pizza
composer require romanzipp/laravel-mailcheck
Update the configuration file name.
- config/mailcheck.php
+ config/mailcheck.php
- romanzipp\ValidatorPizza\
+ romanzipp\MailCheck\
- 'email' => 'required|email|validator_pizza',
+ 'email' => 'required|email|disposable',
The default new table name will be mailcheck_checks
. If you want to keep the previous validator_pizza
table name change the entry in your config file.
- validator_pizza
+ mailcheck_checks
- Query the MailCheck.ai API for disposable Emails & Domains
- Cache responses
- Store requested domains in database
composer require romanzipp/laravel-mailcheck
Copy configuration to your project:
php artisan vendor:publish --provider="romanzipp\MailCheck\Providers\MailCheckProvider"
Run the migration:
php artisan migrate
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function handleEmail(Request $request)
{
$request->validate([
'email' => 'required|email|disposable',
]);
// ...
}
}
$checker = new \romanzipp\MailCheck\Checker;
// Validate domain
$validDomain = $checker->allowedDomain('ich.wtf');
// Validate mail address (uses domain check endpoint internally)
$validEmail = $checker->allowedEmail('ich@ich.wtf');
You can make your disposable checks more hard or loose by configuring the edge case behavior. There are 3 possible outcomes to set:
romanzipp\MailCheck\Enums\ApiIssue::ALLOW
- allow the domain/mailromanzipp\MailCheck\Enums\ApiIssue::DENY
- deny the chekechecked domain/mailromanzipp\MailCheck\Enums\ApiIssue::EXCEPTION
- throw aDisposableMailException
return [
// ...
'decision_rate_limit' => \romanzipp\MailCheck\Enums\ApiIssue::EXCEPTION,
];
There is no MX DNS entry present on the checked domain which means they can not receive any messages.
return [
// ...
'decision_no_mx' => \romanzipp\MailCheck\Enums\ApiIssue::EXCEPTION,
];
return [
// ...
'decision_invalid' => \romanzipp\MailCheck\Enums\ApiIssue::EXCEPTION,
];