Add a simple email verification to your Laravel application. It detects if the email is disposable (temporary/throwaway/fake) email addresses. This tool also helps to avoid communication errors and blocks spam addresses.
You can install the package via composer:
composer require erlandmuchasaj/laravel-email-verify
php artisan email-verify:update-disposable-domains
Publish the configuration file using artisan.
php artisan vendor:publish --provider="ErlandMuchasaj\LaravelEmailVerify\EmailVerifyServiceProvider"
Now you have access to the laravel-email-verify.php
configuration file in the config
directory. Here you can
configure which service to use for email verification. Defaults to kickbox
.
The only thing you need to pay attention to is the connections
key where you need to set the token for the service you are using.
'connections' => [
'kickbox' => [
'domain' => 'https://open.kickbox.io/v1/disposable/',
'email' => 'https://api.eu.kickbox.com/v2/verify',
'key' => 'your-kickbox-api-key',
],
//
],
You can also change the default service to use for email verification by changing the default
key.
/*
|--------------------------------------------------------------------------
| Default Email verifier
|--------------------------------------------------------------------------
|
| This option controls the default verifier that is used to verify any email
|
| Supported: "kickbox", "usercheck", "mails", "block-temporary-email", "zerobounce"
| "verifyright", "mailboxvalidator", "emaillistverify"
*/
'default' => env('INDISPOSABLE_SERVICE', 'kickbox'),
It's highly advised to update the disposable domains list regularly. You can either run the command yourself now and then or, if you make use of Laravel scheduler,
you can register the php artisan email-verify:update-disposable-domains
command:
In routes/console.php
:
use Illuminate\Support\Facades\Schedule;
Schedule::command('email-verify:update-disposable-domains')->weekly();
Or if you use Laravel 10 or below, head over to the Console kernel:
protected function schedule(Schedule $schedule)
{
$schedule->command('email-verify:update-disposable-domains')->monthly();
}
Use validation rule email_verify
to check that specific field does not contain a disposable email address.
Note
❗ Place it after the email
validator to ensure that only valid emails are processed.
Example:
// Using validation rule name:
'email_field' => 'required|email|email_verify',
I invest a lot of time and resources into creating best in class open source packages.
If you found this package helpful you can show support by clicking on the following button below and donating some amount to help me work on these projects frequently.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please see SECURITY for details.
The MIT License (MIT). Please see License File for more information.