funnydevjsc/laravel-email-filter

Laravel 包用于过滤不良电子邮件

1.1.0 2024-09-10 06:55 UTC

This package is auto-updated.

Last update: 2024-09-10 06:56:32 UTC


README

免费 Laravel 包,帮助您使用多个服务过滤用户电子邮件

使用场景

  • 在批准注册或制作发票之前,对用户电子邮件进行强大的检查。
  • 解析验证器结果
  • 示例使用场景

特性

  • 检查来自 poste.io、site24x7.com 的黑名单
  • 检查来自 maxmind.com、apivoid.com、ipqualityscore.com 的质量
  • 使用简单一行代码轻松验证

要求

  • PHP:8.1 或更高版本
  • Laravel 9.0 或更高版本

快速入门

如果您想将此包安装到自己的 Laravel 应用程序中,请按照以下安装步骤操作

安装

步骤 1. 如果您还没有,请安装一个 Laravel 项目

https://laravel.net.cn/docs/installation

步骤 2. 使用 composer 需要当前包

composer require funnydevjsc/laravel-email-filter

步骤 3. 发布控制器文件和配置文件

php artisan vendor:publish --provider="FunnyDev\EmailFilter\EmailFilterServiceProvider" --tag="email-filter"

如果发布文件失败,请在此包的路径下创建相应的文件 config/email-filter.phpapp\Http\Controllers\EmailFilterControllers.php。您还可以进一步自定义 EmailFilterControllers.php 文件以适应您的项目。

步骤 4. 更新已发布配置文件中的各种配置设置

发布包资源后,配置文件将位于 config/email-filter.php

测试

<?php

namespace App\Console\Commands;

use FunnyDev\EmailFilter\EmailFilterSdk;
use Illuminate\Console\Command;

class EmailFilterTestCommand extends Command
{
    protected $signature = 'email-filter:test';

    protected $description = 'Test EmailFilter SDK';

    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        $instance = new EmailFilterSdk();
        
        // Perform checking with fast mode turned on and only use $result['recommended'] as signal (true/false)
        $result = $instance->validate('testing@example.comB3Kin7YM', true);
        
        // Perform a full checking
        $result = $instance->validate('f*cking@example.comB3Kin7YM', false);
        
        // Explanation of results
        $result = [
            'query' => $email,
            'recommend' => true, // Recommended value of whether to accept this email or not
            'trustable' => [
                'exist' => true, // Does the email exist
                'disposable' => false, // Is the email spam
                'blacklist' => 0, // Percentage of blacklists as a float
                'fraud_score' => 0, // Fraud score on a 100-point scale
                'suspicious' => false, // Is the email suspicious of maliciousness
                'high_risk' => false, // Is the email considered high risk of payment
                'domain_type' => 'popular',
                'domain_trust' => true, // Is the domain name trustworthy?
                'domain_age' => '',
                'dns_valid' => false, // Does DNS match between domain name and SMTP server?
                'username' => true // Is the email address username trustworthy?
            ]
        ];
    }
}

反馈

Laravel Việt Nam 中尊重我们

贡献

有关详细信息,请参阅 CONTRIBUTING

安全

如果您发现任何与安全相关的问题,请发送电子邮件至 contact@funnydev.vn 或使用问题跟踪器。

鸣谢

许可

MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件