定制 arraypress/email-blocklist 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

arraypress/email-blocklist

Composer 安装命令:

composer require arraypress/email-blocklist

包简介

A simple, efficient library for checking email addresses against disposable email provider lists.

README 文档

README

A simple, efficient library for checking email addresses against disposable email provider lists. Uses data from the disposable-email-domains project.

Installation

composer require arraypress/email-blocklist

Usage

Quick Check

// Using the helper function
if ( is_disposable_email( 'user@tempmail.com' ) ) {
    // Reject registration
}

Using the Class

use ArrayPress\EmailBlocklist\Blocklist;

$blocklist = new Blocklist();

// Check if disposable
$blocklist->is_disposable( 'user@tempmail.com' );     // true
$blocklist->is_disposable( 'user@gmail.com' );        // false

// Check if blocked (includes custom blocked domains)
$blocklist->is_blocked( 'user@tempmail.com' );        // true

// Check if explicitly allowed
$blocklist->is_allowed( 'user@company.com' );         // false

Custom Blocked/Allowed Domains

// Via constructor
$blocklist = new Blocklist(
    blocked: ['competitor.com', 'banned.org'],
    allowed: ['partner.com', 'trusted.org']
);

// Or fluent methods
$blocklist = new Blocklist();
$blocklist->block( ['competitor.com', 'banned.org'] );
$blocklist->allow( ['partner.com', 'trusted.org'] );

// Single domain
$blocklist->block( 'spammer.com' );
$blocklist->allow( 'friend.com' );

// Remove from custom lists
$blocklist->unblock( 'competitor.com' );
$blocklist->disallow( 'partner.com' );

// Clear all custom entries
$blocklist->clear();

With Email Objects

Works with any object that has a domain() method:

use ArrayPress\EmailUtils\Email;
use ArrayPress\EmailBlocklist\Blocklist;

$email = Email::parse( 'user@tempmail.com' );
$blocklist = new Blocklist();

if ( $email && $blocklist->is_disposable( $email ) ) {
    // Reject
}

Custom Data Path

// Use a custom directory for data files
$blocklist = new Blocklist(
    data_path: '/path/to/your/data'
);

How It Works

The library uses array flipping for O(1) lookups:

// Instead of O(n) search through 170k domains
in_array( $domain, $huge_list );  // Slow

// We use O(1) hash lookup
isset( $flipped_list[ $domain ] );  // Instant

Subdomain matching is supported — if tempmail.com is blocked, sub.tempmail.com is also blocked.

Priority Order

When checking an email:

  1. Custom allowlist — If domain is in custom allowlist, allowed
  2. Built-in allowlist — If domain is in source allowlist, allowed
  3. Custom blocklist — If domain is in custom blocklist, blocked
  4. Disposable list — If domain matches disposable list, blocked
  5. Default — Allow

Available Methods

Method Returns Description
is_disposable($email) bool Check if email is from disposable provider
is_blocked($email) bool Check if email is blocked (disposable + custom)
is_allowed($email) bool Check if email is in allowlist
block($domains) self Add domain(s) to custom blocklist
allow($domains) self Add domain(s) to custom allowlist
unblock($domain) self Remove domain from custom blocklist
disallow($domain) self Remove domain from custom allowlist
get_blocked() array Get custom blocked domains
get_custom_allowed() array Get custom allowed domains
clear() self Clear all custom entries
count() int Count of disposable domains

Data Source

This library uses data from:

The list contains ~170,000 disposable email domains and is actively maintained.

Requirements

  • PHP 8.0+

License

GPL-2.0-or-later

arraypress/email-blocklist 适用场景与选型建议

arraypress/email-blocklist 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「email」 「validation」 「spam」 「disposable」 「blocklist」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 arraypress/email-blocklist 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 arraypress/email-blocklist 我们能提供哪些服务?
定制开发 / 二次开发

基于 arraypress/email-blocklist 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2025-11-27