Skip to content

martynasbakanas/php-disposable-emails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Disposable / Temporary Email Address Filter

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

Installation

To install via Composer:

composer require martynasbakanas/php-disposable-emails

Usage in Laravel

AppServiceProvider.php

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

YourController.php

public function store(Request $request)
{
    $request->validate([
        'email' => [
            'required',
            'email',
            'max:255',
            'unique:users',
            'not-disposable'
        ],
    ];

    ...
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages