kolaybi/mail-checker
Composer 安装命令:
composer require kolaybi/mail-checker
包简介
A Laravel package providing e-mail validation for better email delivery.
关键字:
README 文档
README
A Laravel package providing comprehensive e-mail validation for better email delivery.
Features
- Validate email format and structure
- Check against disposable email domains
- Blacklist and whitelist domain support
- Integration with external validation services
- Flexible configuration
- Detailed exception handling
Installation
You can install the package via composer:
composer require kolaybi/mail-checker
Configuration
Publish the configuration file:
php artisan vendor:publish --provider="KolayBi\Validation\Mail\ServiceProvider"
This will create a mail-checker.php configuration file in your application's config directory.
Environment Variables
Configure the following environment variables in your .env file:
# Local domain lists paths MAIL_CHECKER_WHITELIST_STORAGE_PATH=data/domains/whitelisted_domains.json MAIL_CHECKER_BLACKLIST_STORAGE_PATH=data/domains/blacklisted_domains.json MAIL_CHECKER_DISPOSABLE_STORAGE_PATH=data/domains/disposable_domains.json MAIL_CHECKER_DISPOSABLE_URL=https://rawgit.com/andreis/disposable-email-domains/master/domains.json # Cache configuration MAIL_CHECKER_LOCAL_CACHE_ENABLED=true MAIL_CHECKER_LOCAL_CACHE_TTL=604800 MAIL_CHECKER_LOCAL_CACHE_STORE=file MAIL_CHECKER_EXTERNAL_CACHE_ENABLED=true MAIL_CHECKER_EXTERNAL_CACHE_TTL=86400 MAIL_CHECKER_EXTERNAL_CACHE_STORE=file # External provider configuration MAIL_CHECKER_FAIL_IF_NO_PROVIDERS=true MAIL_CHECKER_EXTERNAL_PROVIDER_PRIORITY=abstract_api,mailboxlayer,mailgun MAIL_CHECKER_EXTERNAL_TIMEOUT=10 # AbstractAPI configuration ABSTRACT_API_EMAIL_ENDPOINT=https://emailvalidation.abstractapi.com/v1/ ABSTRACT_API_EMAIL_API_KEY=your_api_key ABSTRACT_API_EMAIL_TIMEOUT=10 # Bouncer configuration BOUNCER_ENDPOINT=https://api.usebouncer.com/v1.1/email/verify BOUNCER_API_KEY=your_api_key BOUNCER_TIMEOUT=10 # Emailable configuration EMAILABLE_ENDPOINT=https://api.emailable.com/v1/verify EMAILABLE_API_KEY=your_api_key EMAILABLE_TIMEOUT=10 # Hunter configuration HUNTER_VALIDATION_ENDPOINT=https://api.hunter.io/v2/email-verifier HUNTER_API_KEY=your_api_key HUNTER_TIMEOUT=10 # Kickbox configuration KICKBOX_ENDPOINT=https://api.kickbox.com/v2/verify KICKBOX_API_KEY=your_api_key KICKBOX_TIMEOUT=10 # MailboxLayer configuration MAILBOX_LAYER_ENDPOINT=https://apilayer.net/api/check MAILBOX_LAYER_ACCESS_KEY=your_access_key MAILBOX_LAYER_TIMEOUT=10 # Mailgun configuration MAILGUN_VALIDATION_ENDPOINT=https://api.mailgun.net/v4/address/validate MAILGUN_API_KEY=your_api_key MAILGUN_TIMEOUT=10 # NeverBounce configuration NEVER_BOUNCE_VALIDATION_ENDPOINT=https://api.neverbounce.com/v4/single/check NEVER_BOUNCE_API_KEY=your_api_key NEVER_BOUNCE_TIMEOUT=10
Usage
Basic Validation
use KolayBi\Validation\Mail\MailChecker; use KolayBi\Validation\Mail\Exceptions\AbstractMailException; try { MailChecker::check('user@example.com'); // Email is valid } catch (AbstractMailException $e) { // Handle specific validation errors echo $e->getMessage(); }
Simplified Boolean Check
if (MailChecker::isValid('user@example.com')) { // Email is valid } else { // Email is invalid }
Skip External Validation
// Perform only local validation checks MailChecker::check('user@example.com', skipExternalControl: true);
// Perform only local validation checks if (MailChecker::isValid('user@example.com', skipExternalControl: true)) { // Email is valid } else { // Email is invalid }
Advanced Validation Methods
The package provides granular validation methods for specific checks:
// Check individual validation aspects if (MailChecker::isWhitelisted('user@example.com')) { // Email domain is in whitelist - trusted domain } if (MailChecker::isBlacklisted('user@example.com')) { // Email domain is explicitly blocked } if (MailChecker::isDisposable('user@example.com')) { // Email is from a temporary/disposable email provider } if (MailChecker::isValidFormat('user@example.com')) { // Email format passes validation checks } // Inverse methods for negative checks if (MailChecker::isNotWhitelisted('user@example.com')) { // Email requires validation (not in trusted whitelist) } if (MailChecker::isNotBlacklisted('user@example.com')) { // Email is not explicitly blocked } if (MailChecker::isNotDisposable('user@example.com')) { // Email is from a permanent email provider } if (MailChecker::isInvalidFormat('user@example.com')) { // Email format is invalid }
Exception Types
The package throws specific exceptions for different validation scenarios:
EmptyMailException- Email address is emptyInvalidMailException- Email format is invalidBlacklistedMailException- Domain is blacklistedDisposableMailException- Domain is from a disposable email providerInaccessibleMailException- Failed external validationExternalMailProviderException- External validation error
Command Line Interface
Manage domain lists using artisan commands:
# Update disposable domain list from configured URL php artisan mail-checker:update-disposable-domains # Whitelist operations php artisan mail-checker:update-domains --type=whitelist --add=kolaybi.com --add=newdomain.com php artisan mail-checker:update-domains --type=whitelist --remove=oldomain.com php artisan mail-checker:update-domains --type=whitelist --list php artisan mail-checker:update-domains --type=whitelist --add=kolaybi.com --add=newdomain.com --remove=oldomain.com --list # Blacklist operations php artisan mail-checker:update-domains --type=blacklist --add=spam.com php artisan mail-checker:update-domains --type=blacklist --remove=notspam.com php artisan mail-checker:update-domains --type=blacklist --list php artisan mail-checker:update-domains --type=blacklist --add=spam.com --add=fraud.com --remove=notspam.com --list # Cache management php artisan mail-checker:cache-clear # Clear all caches php artisan mail-checker:cache-clear --type=local # Clear only local validation cache php artisan mail-checker:cache-clear --type=external # Clear only external validation cache php artisan mail-checker:cache-clear --type=local --domain-type=whitelist # Clear only whitelist domain cache
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
License
Please see License File for more information.
kolaybi/mail-checker 适用场景与选型建议
kolaybi/mail-checker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 396 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mail」 「validation」 「laravel」 「kolaybi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kolaybi/mail-checker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kolaybi/mail-checker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kolaybi/mail-checker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.
Adds request-parameter validation to the SLIM 3.x PHP framework
Mail libraries used by Zimbra Api
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.
统计信息
- 总下载量: 396
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-22