在构建用户注册系统时,你是否也曾为垃圾邮件和虚假用户而烦恼?很多用户会选择使用一次性邮箱(也称为临时邮箱或抛弃式邮箱)进行注册,这给网站管理带来了诸多问题,例如:
为了解决这个问题,我找到了
mattketmo/email-checker
安装
使用 Composer 安装非常简单:
<pre class="brush:php;toolbar:false;">composer require mattketmo/email-checker
使用
安装完成后,就可以在你的代码中使用
EmailChecker
<pre class="brush:php;toolbar:false;"><?php
require __DIR__.'/vendor/autoload.php';
use EmailChecker\EmailChecker;
$checker = new EmailChecker();
$checker->isValid('foo@bar.org'); // true - 普通邮箱
$checker->isValid('foo@yopmail.com'); // false - 一次性邮箱isValid()
true
false
自定义适配器
如果你想使用自己的邮箱列表,也可以自定义适配器:
<pre class="brush:php;toolbar:false;"><?php
use EmailChecker\EmailChecker;
use EmailChecker\Adapter;
$checker = new EmailChecker(new Adapter\ArrayAdapter([
'foo.org',
'baz.net'
]));
$checker->isValid('foo@bar.org'); // true
$checker->isValid('foo@baz.net'); // false只需要实现
AdapterInterface
Symfony 和 Laravel 集成
mattketmo/email-checker
EmailCheckerAssert\NotThrowawayEmail
not_throw_away
优势
实际应用效果
在我的项目中,使用
mattketmo/email-checker
总而言之,
mattketmo/email-checker
以上就是垃圾邮件横行?mattketmo/email-checker如何解决一次性邮箱注册问题的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号