epifrin/disposable-email-checker
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.
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.
epifrin/disposable-email-checker 适用场景与选型建议
epifrin/disposable-email-checker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 02 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 epifrin/disposable-email-checker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 epifrin/disposable-email-checker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-02-07