romanzipp/laravel-validator-pizza

此包已被弃用且不再维护。作者建议使用romanzipp/laravel-mailcheck包。

Laravel 对 laravel.pizza 一次性电子邮件 API 的封装

1.3.2 2023-09-25 14:17 UTC

This package is auto-updated.

Last update: 2023-09-25 14:17:13 UTC


README

⚠️ 此包已重命名

您可以在 romanzipp/Laravel-MailCheck 找到新项目。此仓库将不再更新。

Laravel Validator.Pizza

Latest Stable Version Total Downloads License GitHub Build Status

Laravel 对 Validator.pizza 一次性电子邮件 API 的封装,由 @tompec 开发。

功能

  • 查询 Validator.Pizza API 中的一次性电子邮件和域名
  • 缓存响应
  • 将请求的域名存储在数据库中

安装

composer require romanzipp/laravel-validator-pizza

配置

将配置复制到您的项目中

php artisan vendor:publish --provider="romanzipp\ValidatorPizza\Providers\ValidatorPizzaProvider"

运行迁移

php artisan migrate

更改配置以符合您想要的设置

return [

    // Database storage enabled
    'store_checks' => true,

    // Database table name
    'checks_table' => 'validator_pizza',

    // Cache enabled (recommended)
    'cache_checks' => true,

    // Duration in minutes to keep the query in cache
    'cache_duration' => 30,

    // Determine which decision should be given if the rate limit is exceeded [allow / deny]
    'decision_rate_limit' => 'allow',

    // Determine which decision should be given if the domain has no MX DNS record [allow / deny]
    'decision_no_mx' => 'allow',

    // Makes use of the API key
    'key' => env('VALIDATOR_PIZZA_KEY'),
];

使用方法

控制器验证

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    public function handleEmail(Request $request)
    {
        $request->validate([
            'email' => 'required|email|disposable_pizza',
        ]);

        // ...
    }
}

独立使用

$checker = new \romanzipp\ValidatorPizza\Checker;

// Validate Email
$validEmail = $checker->allowedEmail('ich@ich.wtf');

// Validate Domain
$validDomain = $checker->allowedDomain('ich.wtf');