laravel-validation-rules/email-validation-mailgun
Composer 安装命令:
composer require laravel-validation-rules/email-validation-mailgun
包简介
Metapackage for https://github.com/TheoKouzelis/laravel-mailgun-email-validation
README 文档
README
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 laravel-validation-rules/email-validation-mailgun
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.
laravel-validation-rules/email-validation-mailgun 适用场景与选型建议
laravel-validation-rules/email-validation-mailgun 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 32 次下载、GitHub Stars 达 3, 最近一次更新时间为 2018 年 07 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 laravel-validation-rules/email-validation-mailgun 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laravel-validation-rules/email-validation-mailgun 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 32
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-07-30