mattketmo / email-checker
Throwaway email detection library
Installs: 1 556 185
Dependents: 6
Suggesters: 0
Security: 0
Stars: 265
Watchers: 19
Forks: 79
Open Issues: 17
Requires
- php: ^7.1 || ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.18
- illuminate/support: ^5.0 || ^6.0 || ^7.0 || ^8.0
- knplabs/gaufrette: ^0.10
- phpunit/phpunit: ^7.5 || ^9.5
- symfony/validator: ^3.0 || ^4.0 || ^5.0
Suggests
- knplabs/gaufrette: Use filesystem abstraction layer to read data
- symfony/validator: Add validation constraints
README
PHP library to check if an email comes from a disposable email provider.
To detect invalid emails, it provides a built-in database of 1000+ disposable email providers, but you can also use your own data.
Installation
Via Composer:
composer require mattketmo/email-checker
Usage
Basic use of EmailChecker with built-in throwaway email list:
<?php require __DIR__.'/vendor/autoload.php'; use EmailChecker\EmailChecker; $checker = new EmailChecker(); $checker->isValid('foo@bar.org'); // true $checker->isValid('foo@yopmail.com'); // false
Or using a custom adapter:
<?php use EmailChecker\EmailChecker; use EmailChecker\Adapter; $checker = new EmailChecker(new Adapter\ArrayAdapter(array( 'foo.org', 'baz.net' ))); $checker->isValid('foo@bar.org'); // true $checker->isValid('foo@baz.net'); // false
You can build your own adapter (to use another database) simply by implementing the AdapterInterface.
Integration with Symfony2
This library also provides a constraint validation for your Symfony2 project:
<?php use EmailChecker\Constraints as EmailCheckerAssert; use Symfony\Component\Validator\Constraints as Assert; class User { /** * @Assert\NotBlank * @EmailCheckerAssert\NotThrowawayEmail */ protected $email; }
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:
EmailChecker\Laravel\EmailCheckerServiceProvider::class
If you would like to use the EmailChecker
facade, you must also add the
following line to the aliases
key within your config/app.php
file:
'EmailChecker' => EmailChecker\Laravel\EmailCheckerFacade::class
You can then use the library within your project like so:
<?php class MyClass { public function foo() { // Facade Access EmailChecker::isValid('address@domain.com'); // Container Access $checker = app()->make('email.checker'); $checker->isValid('address@domain.com'); } public function getValidator(array $data) { // Not thow away validator return Validator::make($data, [ 'email' => 'required|email|not_throw_away' ]); } }
List of some disposable emails database
- http://10minutemail.com
- http://spamdecoy.net
- http://temp-mail.org
- http://torvpn.com/temporaryemail.html
- http://www.bloggingwv.com/big-list-of-disposable-temporary-email-services/
- http://www.fakemailgenerator.com/
- http://www.warriorforum.com/main-internet-marketing-discussion-forum/147524-list-temporary-email-services-you-may-want-block-your-autoresponder-little-rant.html
- http://xenforo.com/community/threads/ban-temporary-email-addresses.5461/
License
EmailChecker is released under the MIT License. See the bundled LICENSE file for details.