unicodeveloper/laravel-email-validator

提供用于验证和验证电子邮件地址的 facade

1.0.1 2015-11-01 20:23 UTC

This package is auto-updated.

Last update: 2024-09-07 18:13:28 UTC


README

Latest Stable Version License Build Status Quality Score Total Downloads

Laravel 5 包,用于帮助验证和验证电子邮件地址。

注意:此软件依赖于来自 http://quickemailverification.com/ 的付费服务。

安装

PHP 5.5+ 或 HHVM 3.3+,以及 Composer 是必需的。

通过 Composer

$ composer require unicodeveloper/laravel-email-validator

另一种选择是将以下行添加到您的 composer.json 文件的 require 块中。

"unicodeveloper/laravel-email-validator": "1.0.*"

然后运行 composer installcomposer update 以下载它并更新自动加载器。

将此添加到您的 config/app.php 文件中的 providers 数组中

// Laravel 5: config/app.php

'providers' => [
    ...
    Unicodeveloper\EmailValidator\EmailValidatorServiceProvider::class,
    ...
];

此软件包还包含一个 facade

// Laravel 5: config/app.php

'aliases' => [
    ...
    'EmailValidator' => Unicodeveloper\EmailValidator\EmailValidatorFacade::class,
    ...
]

通过运行以下命令发布配置文件

php artisan vendor:publish

配置文件现在位于 config/emailValidator.php

配置

这是位于 config 目录下的 emailValidator.php 文件。前往 quickemailverification.com,注册,获取 API 密钥并将其插入此处

/**
 *  Config file that a user/developer can insert quickemailverficationservice api key
 */
return [
    'apiKey' => ''
];

用法

使用 facade,您在应用程序中只需执行类似以下操作即可

 print_r(EmailValidator::verify('kkkkk@example.com')->isValid());
 // returns Array ( [0] => [1] => Could not get MX records for domain )
 
 print_r(EmailValidator::verify('prosperotemuyiwa@gmail.com')->isValid());
 // returns Array ( [0] => 1 [1] => SMTP server accepted email address )

 var_dump( EmailValidator::verify('prosperotemuyiwa@gmail.com')->isValid()[0]); 
 // returns bool(true)
 
 var_dump( EmailValidator::verify('kkkkk@example.com')->isValid()[0]); 
 // returns bool(false)
 
 
 if( EmailValidator::verify('kkkkk@example.com')->isValid()[0] ){
   ......
 }

 // returns a true/false if the email address is valid or not

其他可用方法

/**
 * Returns true or false if the email address uses a disposable domain
 * @return boolean
 */
EmailValidator::verify('kkkkk@example.com')->isDisposable()
/**
 * Returns true or false if the API request was successful
 * @return boolean
 */
EmailValidator::verify('kkkkk@example.com')->apiRequestStatus()
/**
 * Get the domain of the provided email address
 * @return string
 */
EmailValidator::verify('kkkkk@example.com')->getDomainName()
/**
 * Get the local part of an email address
 * Example: kkkkk@example.com returns kkkkk
 * @return string
 */
EmailValidator::verify('kkkkk@example.com')->getUser()
/**
 * Gets a normalized version of the email address
 * Example: KkkKk@example.com returns kkkkk@gmail.com
 * @return string
 */
EmailValidator::verify('kkkkk@example.com')->getEmailAddress()
/**
 * Returns true if the domain appears to accept all emails delivered to that domain
 * @return boolean
 */
EmailValidator::verify('kkkkk@example.com')->acceptEmailsDeliveredToDomain()
/**
 * Returns true or false if email address is a role address
 * Example manager@example.com , ceo@example.com will return true
 * @return boolean
 */
EmailValidator::verify('kkkkk@example.com')->isRole()

变更日志

有关最近更改的详细信息,请参阅 CHANGELOG

待办事项:测试

待办事项:验证电子邮件列表

您可以使用以下命令运行测试

vendor/bin/phpunit run

或者,您也可以这样运行测试

composer test

贡献

有关详细信息,请参阅 CONTRIBUTING

如何感谢您?

为什么不给 GitHub 仓库加星标?我很乐意得到关注!为什么不分享这个仓库的链接到 Twitter 或 HackerNews?传播这个消息!

别忘了在 Twitter 上关注我

谢谢!Otemuyiwa Prosper。

许可协议

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