erlandmuchasaj/laravel-email-verify

Validate email addresses that they are valid and non disposable.

1.0.8 2024-12-24 16:05 UTC

This package is auto-updated.

Last update: 2024-12-24 16:05:51 UTC


README

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.

Installation

You can install the package via composer:

composer require erlandmuchasaj/laravel-email-verify

Run the command update the list of disposable domains:

php artisan email-verify:update-disposable-domains

Config file

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'),

Optionally

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();
 }

Usage

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',

@todo:

Add more services for email verification:

Support me

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.

buy me a coffee

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please see SECURITY for details.

Credits

License

The MIT License (MIT). Please see License File for more information.