mattketmo/email-checker 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mattketmo/email-checker

最新稳定版本:v2.5.0

Composer 安装命令:

composer require mattketmo/email-checker

包简介

Throwaway email detection library

README 文档

README

Code quality... Downloads Packagist License MIT

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 Symfony

This library also provides a constraint validation for your Symfony project:

<?php

use EmailChecker\Constraints as EmailCheckerAssert;
use Symfony\Component\Validator\Constraints as Assert;

class User
{
    #[Assert\NotBlank] 
    #[EmailCheckerAssert\NotThrowawayEmail] 
    private string $email;
}

Integration with Laravel

To integrate this library with your Laravel 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

License

EmailChecker is released under the MIT License. See the bundled LICENSE file for details.

统计信息

  • 总下载量: 1.91M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 279
  • 点击次数: 1
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 270
  • Watchers: 16
  • Forks: 79
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-03-18