kouz/laravel-mailgun-email-validation
Composer 安装命令:
composer require kouz/laravel-mailgun-email-validation
包简介
Laravel email validation that uses the Mailgun API for a three-step validation check.
README 文档
README
Laravel email validation that uses the Mailgun API for a three-step validation check.
To find examples of how validation rules can be applied in the Laravel framework, please view the validation docs
Install
Require via composer.
composer require kouz/laravel-mailgun-email-validation
For Laravel >=5.5 the package will be discoverd. For Laravel <=5.4 add package to list of service providers in config/app.php
<?php
//config/app.php
'providers' => [
Kouz\LaravelMailgunValidation\ServiceProvider::class,
],
Publish and fill out the config/mailgun-email-validation.php file with your Mailgun API key.
php artisan vendor:publish --provider="Kouz\LaravelMailgunValidation\ServiceProvider"
Basic Usage
Use the following rule to validate your email fields. The rule will first check the address against PHP's FILTER_VALIDATE_EMAIL and then will call the Mailgun API.
$request->validate([
'email' => ['required', 'mailgun_email'],
]);
Further flags can added to the rule to make the validation more strict.
$request->validate([
'email' => ['required', 'mailgun_email:role,disposable,mailbox,strict'],
]);
Each flag if present, will add the following validation rules:
- role Don't allow role-based addresses such as ‘admin’, ‘sales’, ‘webmaster’...
- disposable Don't allow disposable email domains.
- mailbox A call is made to the ESP to verify the mailboxes existence. Add strict flag to ensure that Mailgun was able to verify a mailbox and didn't return "Unknown".
- strict Always require a response from Mailgun to validate. By default if a API request fails, the validation will pass. The strict flag ensures that a Mailgun response was recieved.
Recommended Usage
The following configuration will try to check if the email addresses mailbox exists and is not a disposable email address. If Mailgun is not contactable or Mailgun can't perform the mailbox check, the validation will fall back on PHP's FILTER_VALIDATE_EMAIL.
$request->validate([
'email' => ['required', 'mailgun_email:disposable,mailbox'],
]);
License
This project is licensed under a MIT License which you can find in this LICENSE.
Feedback
If you have any feedback, comments or suggestions, please feel free to open an issue within this repository.
Laravel Validation Rules
This package is part of the Laravel Validation Rules collection. If you're after more useful validation rules, head to the Laravel Validation Rules website.
kouz/laravel-mailgun-email-validation 适用场景与选型建议
kouz/laravel-mailgun-email-validation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 145.13k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2018 年 03 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「validation」 「laravel」 「mailgun」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kouz/laravel-mailgun-email-validation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kouz/laravel-mailgun-email-validation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kouz/laravel-mailgun-email-validation 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
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.
A CakePHP behavior to validate foreign keys
统计信息
- 总下载量: 145.13k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 25
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-04