tempmailchecker/php-sdk
Composer 安装命令:
composer require tempmailchecker/php-sdk
包简介
PHP SDK for TempMailChecker API - Detect disposable email addresses in real-time
README 文档
README
TempMailChecker PHP SDK
Detect disposable email addresses in real-time with the TempMailChecker API. Block fake signups, prevent spam, and protect your platform from abuse.
🚀 Quick Start
Installation
composer require tempmailchecker/php-sdk
Basic Usage
<?php require 'vendor/autoload.php'; use TempMailChecker\TempMailChecker; // Initialize with your API key $checker = new TempMailChecker('your_api_key_here'); // Check if an email is disposable if ($checker->isDisposable('user@tempmail.com')) { echo "Blocked: This is a disposable email"; } else { echo "Valid: This is a legitimate email"; }
📖 Documentation
Check Email Address
$checker = new TempMailChecker('your_api_key'); // Simple boolean check $isDisposable = $checker->isDisposable('test@10minutemail.com'); // Get full response $result = $checker->check('user@example.com'); // Returns: ['temp' => false]
Check Domain
// Check just the domain $isDisposable = $checker->isDisposableDomain('tempmail.com'); // Get full response $result = $checker->checkDomain('guerrillamail.com');
Regional Endpoints
Use regional endpoints for lower latency. All endpoints use /check and /usage directly (no /api prefix):
use TempMailChecker\TempMailChecker; // EU endpoint (default) $checker = new TempMailChecker('your_api_key'); // or explicitly: $checker = new TempMailChecker('your_api_key', TempMailChecker::ENDPOINT_EU); // US endpoint $checker = new TempMailChecker('your_api_key', TempMailChecker::ENDPOINT_US); // Asia endpoint $checker = new TempMailChecker('your_api_key', TempMailChecker::ENDPOINT_ASIA);
Check Usage
$usage = $checker->getUsage(); // Returns: ['usage_today' => 15, 'limit' => 25, 'reset' => 'midnight UTC']
Error Handling
use TempMailChecker\TempMailChecker; use Exception; try { $isDisposable = $checker->isDisposable('user@example.com'); } catch (Exception $e) { if (strpos($e->getMessage(), 'Rate limit') !== false) { // Handle rate limit } else { // Handle other errors echo "Error: " . $e->getMessage(); } }
🎯 Use Cases
- Block Fake Signups: Stop disposable emails at registration
- Prevent Promo Abuse: Protect referral programs and coupons
- Clean Email Lists: Remove throwaway addresses from newsletters
- Reduce Spam: Filter out disposable emails in contact forms
- Protect Communities: Ensure real users in forums and chat
⚡ Features
- ✅ Simple API: One method call, one boolean response
- ✅ Fast: Sub-millisecond processing, ~70ms real-world latency
- ✅ Massive Database: 277,000+ disposable email domains
- ✅ Auto-Updates: Database updated daily automatically
- ✅ Regional Endpoints: US, EU, and Asia for optimal performance
- ✅ Free Tier: 25 requests/day, no credit card required
🔑 Get Your API Key
- Sign up at tempmailchecker.com
- Get 25 free requests per day
- Start blocking disposable emails immediately
📚 Examples
Laravel Integration
namespace App\Services; use TempMailChecker\TempMailChecker; use Exception; class EmailValidationService { private $checker; public function __construct() { $apiKey = config('services.tempmailchecker.key'); if (empty($apiKey)) { throw new Exception('TempMailChecker API key not configured'); } $this->checker = new TempMailChecker($apiKey); } public function validateEmail(string $email): bool { try { return !$this->checker->isDisposable($email); } catch (Exception $e) { \Log::warning('TempMailChecker API error: ' . $e->getMessage()); return true; // Fail open } } }
Symfony Integration
// services.yaml services: TempMailChecker\TempMailChecker: arguments: $apiKey: '%env(TEMPMAILCHECKER_API_KEY)%'
WordPress Plugin
use TempMailChecker\TempMailChecker; use Exception; add_filter('registration_errors', function($errors, $sanitized_user_login, $user_email) { try { $checker = new TempMailChecker(get_option('tempmailchecker_api_key')); if ($checker->isDisposable($user_email)) { $errors->add('disposable_email', 'Disposable email addresses are not allowed.'); } } catch (Exception $e) { // Log error but don't block registration error_log('TempMailChecker error: ' . $e->getMessage()); } return $errors; }, 10, 3);
🛠️ Requirements
- PHP 7.4 or higher
- cURL extension
- JSON extension
- Composer (for installation)
📝 License
This library is open-source software licensed under the MIT License.
🤝 Support
- Documentation: tempmailchecker.com/docs
- Issues: GitHub Issues
- Email: support@tempmailchecker.com
⭐ Why TempMailChecker?
- 277,000+ domains in our database
- Sub-millisecond API processing
- ~70ms latency from global endpoints
- Auto-updates daily
- Free tier with 25 requests/day
- No SDK dependencies - works with any PHP version
Made with ❤️ by TempMailChecker
tempmailchecker/php-sdk 适用场景与选型建议
tempmailchecker/php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 12 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「email」 「validation」 「sdk」 「spam」 「temporary」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tempmailchecker/php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tempmailchecker/php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tempmailchecker/php-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Adds request-parameter validation to the SLIM 3.x PHP framework
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
A jQuery augmented PHP library for creating and validating HTML forms
A Laravel validator for delimiter-separated list of emails.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-18