mattketmo / email-checker
一次性电子邮件检测库
v2.3.0
2023-12-07 13:10 UTC
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库,用于检查电子邮件是否来自 一次性电子邮件提供商。
为了检测无效电子邮件,它提供了一个包含 内置数据库 的1000多个一次性电子邮件提供商,但您也可以使用自己的数据。
安装
通过Composer
composer require mattketmo/email-checker
使用方法
使用内置的弃用电子邮件列表的基本使用方法EmailChecker
<?php require __DIR__.'/vendor/autoload.php'; use EmailChecker\EmailChecker; $checker = new EmailChecker(); $checker->isValid('foo@bar.org'); // true $checker->isValid('foo@yopmail.com'); // false
或使用自定义适配器
<?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
您可以通过实现AdapterInterface来简单地构建自己的适配器(以使用另一个数据库)。
Symfony2集成
此库还为您的Symfony2项目提供约束验证
<?php use EmailChecker\Constraints as EmailCheckerAssert; use Symfony\Component\Validator\Constraints as Assert; class User { /** * @Assert\NotBlank * @EmailCheckerAssert\NotThrowawayEmail */ protected $email; }
Laravel 5集成
要将此库与您的Laravel 5.x项目集成,请将以下行添加到您的config/app.php
文件中的providers
键
EmailChecker\Laravel\EmailCheckerServiceProvider::class
如果您想使用EmailChecker
外观,您还必须在您的config/app.php
文件中的aliases
键中添加以下行
'EmailChecker' => EmailChecker\Laravel\EmailCheckerFacade::class
然后您可以在项目中这样使用库
<?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' ]); } }
一些一次性电子邮件数据库列表
- 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/
许可证
EmailChecker在MIT许可证下发布。有关详细信息,请参阅捆绑的LICENSE文件。