承接 epifrin/disposable-email-checker 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

epifrin/disposable-email-checker

最新稳定版本:1.0.2

Composer 安装命令:

composer require epifrin/disposable-email-checker

包简介

The library allows checking if the email address is disposable

README 文档

README

The library allows checking if the email address is disposable.

Build status Latest Stable Version PHP Version Require Total Downloads License

How it works

The library utilizes a third-party Debounce Disposable Email API, by sending requests and receiving responses. While the API is free to use, there are restrictions on the number of requests allowed. To minimize the number of requests, the library maintains its list of well-known email domains and implements a caching mechanism for previous responses.

Requirements

PHP ^8.1

guzzlehttp/guzzle ^7.0

Installation

Run the Composer require command to install the package:

composer require epifrin/disposable-email-checker

Usage

Basic use of DisposableEmailChecker

<?php

require_once './vendor/autoload.php';

use Epifrin\DisposableEmailChecker\DisposableEmailChecker;

$disposableEmailChecker = new DisposableEmailChecker();
$disposableEmailChecker->isEmailDisposable('foo@gmail.com'); // false
$disposableEmailChecker->isEmailDisposable('foo@mailinator.com'); // true

Please note. In case of reaching the Debounce API limitation will be thrown RateLimitException.

To reduce the number of requests to the Debounce API, it is recommended to pass a PSR-16 cache implementation as the first parameter when sending a significant amount of requests.

<?php

require_once './vendor/autoload.php';

use Epifrin\DisposableEmailChecker\DisposableEmailChecker;

$cache = new RedisCache(); // for example some Redis Cache implementation
$disposableEmailChecker = new DisposableEmailChecker($cache);
$disposableEmailChecker->isEmailDisposable('foo@mailinator.com'); // true

$disposableEmailChecker->isEmailDisposable('foo@mailinator.com'); // this request will not be sent to the Debounce API while it present in Redis

If you want to use your custom disposable email checker you can implement CheckerInterface and pass it as a second parameter.

<?php

class MyOwnChecker implements \Epifrin\DisposableEmailChecker\Checker\CheckerInterface
{
    public function isEmailDisposable(string $emailAddress): bool
    {
        // TODO: Implement isEmailDisposable() method.
    }
}
<?php

require_once './vendor/autoload.php';

use Epifrin\DisposableEmailChecker\DisposableEmailChecker;

$cache = new RedisCache();
$disposableEmailChecker = new DisposableEmailChecker(new Cache(), new MyOwnChecker());

Trust domains

Trust domains help to reduce the number of requests to the Debounce API. Emails from trust domains will not be checked by the Debounce API.

How to add trust domains.

<?php

require_once './vendor/autoload.php';

use Epifrin\DisposableEmailChecker\DisposableEmailChecker;

$disposableEmailChecker = new DisposableEmailChecker();
$disposableEmailChecker->addTrustDomains(['domain.com', 'my.domain.com']);

$disposableEmailChecker->isEmailDisposable('foo@domain.com'); // false

Warning

Do not recommend using this library in the long-running application without your PSR-16 cache implementation.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固