Skip to content

Validate emails against multiple databases with disposable email domains

License

Notifications You must be signed in to change notification settings

eusonlito/disposable-email-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Disposable Email Validator

Downloads Packagist License MIT

Validate emails against multiple databases with disposable email domains.

Current databases (domains, wildcard and whitelist):

Installation

Via Composer:

composer require eusonlito/disposable-email-validator

Usage

Basic use of email validator against built-in domains list:

<?php

require __DIR__.'/vendor/autoload.php';

use Eusonlito\DisposableEmail\Check;

// Simple
// Validate emailFilter, domain and wildcard

Check::email('me@my-email.com'); // true
Check::email('me@10minutemail.com'); // false

// Other methods

Check::emailFilter('me@my-email.com');     // Validate email with filter_var
Check::emailExpression('me@my-email.com'); // Validate email with regular expression
Check::domain('my-email.com');             // Validate domain and wildcard domains
Check::wildcard('my-email.com');           // Validate only wildcard domains

Integration with Laravel 5

To integrate this library with your Laravel 5.x project add the following line to the providers key within your config/app.php file:

'providers' => [
    ...

    Eusonlito\DisposableEmail\Laravel\DisposableEmailServiceProvider::class

    ...
];

You can then use the library within your project like so:

<?php
use InvalidArgumentException;
use Eusonlito\DisposableEmail\Check;

class Signup
{
    public function validate(Request $request)
    {
        if (!Check::email($request->input('email'))) {
            throw new InvalidArgumentException('Invalid email');
        }
    }

    public function getValidator(array $data)
    {
        return Validator::make($data, [
             'email' => 'required|email|disposable_email' // Use after email validator
        ]);
    }
}

About

Validate emails against multiple databases with disposable email domains

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages