定制 khanhicetea/fast-email-validator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

khanhicetea/fast-email-validator

Composer 安装命令:

composer require khanhicetea/fast-email-validator

包简介

A fast email validation library for PHP 7+

README 文档

README

Fast email validation library for PHP 7+

Build Status

Inspired by daveearley's Email-Validation-Tool

The aim of this library is to offer a more detailed email validation report than simply checking if an email is the valid format, and also to make it possible to easily add custom validations.

Currently this tool checks the following:

Validation Description
MX records Checks if the email's domain has valid MX records
Valid format Validates e-mail addresses against the syntax in RFC 822, with the exceptions that comments and whitespace folding and dotless domain names are not supported (as it uses PHP's filter_var().
Email Host Checks if the email's host (e.g gmail.com) is reachable
Role/Business Email^ Checks if the email is a role/business based email (e.g info@reddit.com).
Disposable email provider^ Checks if the email is a disposable email (e.g person@10minutemail.com).
Free email provider^ Checks if the email is a free email (e.g person@yahoo.com).

^ Data used for these checks can be found here

Why is it fast ?

Because we compile the text database to real PHP object, and use isset function to check if a key existed.

Installation

composer require khanhicetea/fast-email-validator

Usage

Quick Start

// Include the composer autoloader
require __DIR__ . '/vendor/autoload.php';

use FastEmailValidator\EmailAddress;
use FastEmailValidator\EmailValidatorProvider;
use FastEmailValidator\EmailValidator;

$fastEmailValidator = new EmailValidator();

$provider = new EmailValidatorProvider();
$provider->registerValidator(new ValidFormatValidator());
$provider->registerValidator(new DisposableEmailValidator());
$provider->registerValidator(new EmailHostValidator());
$provider->registerValidator(new FreeEmailServiceValidator());
$provider->registerValidator(new MxRecordsValidator());
$provider->registerValidator(new RoleBasedEmailValidator());

$fastEmailValidator->registerEmailValidatorProvider($provider);

$result = $fastEmailValidator->validate(new EmailAddress('hi@khanhicetea.com'));

echo(json_encode($result));

Expected output:

{
  "valid_format": true,
  "disposable_email_provider": false,
  "valid_host": true,
  "free_email_provider": false,
  "valid_mx_records": true,
  "role_or_business_email": true
}

FAQ

Is this validation accurate?

No, none of these tests are 100% accurate. As with any email validation there will always be false positives & negatives. The only way to guarantee an email is valid is to send an email and solicit a response. However, this library is still useful for detecting disposable emails etc., and also acts as a good first line of defence.

统计信息

  • 总下载量: 939
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-07-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固