https://github.com/unicodeveloper/laravel-email-validator
:email: :package: Validate email addresses on the fly in Laravel 5
https://github.com/unicodeveloper/laravel-email-validator
Last synced: 5 months ago
JSON representation
:email: :package: Validate email addresses on the fly in Laravel 5
- Host: GitHub
- URL: https://github.com/unicodeveloper/laravel-email-validator
- Owner: unicodeveloper
- License: mit
- Created: 2015-11-01T11:16:26.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-12T04:40:26.000Z (about 10 years ago)
- Last Synced: 2025-05-02T11:38:02.012Z (9 months ago)
- Language: PHP
- Homepage:
- Size: 16.6 KB
- Stars: 23
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# laravel-email-validator
[](https://packagist.org/packages/unicodeveloper/laravel-email-validator)

[](LICENSE.md)
[](https://travis-ci.org/unicodeveloper/laravel-email-validator)
[](https://scrutinizer-ci.com/g/unicodeveloper/laravel-email-validator)
[](https://packagist.org/packages/unicodeveloper/laravel-email-validator)
> Laravel 5 Package to help validate and verify your email addresses.
**Note:** This depends on the paid service from http://quickemailverification.com/.
## Install
[PHP](https://php.net) 5.5+ or [HHVM](http://hhvm.com) 3.3+, and [Composer](https://getcomposer.org) are required.
Via Composer
``` bash
$ composer require unicodeveloper/laravel-email-validator
```
Another alternative is to simply add the following line to the require block of your `composer.json` file.
```
"unicodeveloper/laravel-email-validator": "1.0.*"
```
Then run `composer install` or `composer update` to download it and have the autoloader updated.
Add this to your providers array in `config/app.php`
```php
// Laravel 5: config/app.php
'providers' => [
...
Unicodeveloper\EmailValidator\EmailValidatorServiceProvider::class,
...
];
```
This package also comes with a facade
```php
// Laravel 5: config/app.php
'aliases' => [
...
'EmailValidator' => Unicodeveloper\EmailValidator\EmailValidatorFacade::class,
...
]
```
Publish the config file by running:
```bash
php artisan vendor:publish
```
The config file will now be located at `config/emailValidator.php`.
## Configuration
This is the `emailValidator.php` file in the `config` directory. Go to [quickemailverification.com](http://quickemailverification.com/), sign up, get an api Key and insert here
```php
/**
* Config file that a user/developer can insert quickemailverficationservice api key
*/
return [
'apiKey' => ''
];
```
## Usage
With the Facades, all you need to do in your application is something like so:
```php
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
```
### Other Methods Available
```php
/**
* Returns true or false if the email address uses a disposable domain
* @return boolean
*/
EmailValidator::verify('kkkkk@example.com')->isDisposable()
```
```php
/**
* Returns true or false if the API request was successful
* @return boolean
*/
EmailValidator::verify('kkkkk@example.com')->apiRequestStatus()
```
```php
/**
* Get the domain of the provided email address
* @return string
*/
EmailValidator::verify('kkkkk@example.com')->getDomainName()
```
```php
/**
* Get the local part of an email address
* Example: kkkkk@example.com returns kkkkk
* @return string
*/
EmailValidator::verify('kkkkk@example.com')->getUser()
```
```php
/**
* Gets a normalized version of the email address
* Example: KkkKk@example.com returns kkkkk@gmail.com
* @return string
*/
EmailValidator::verify('kkkkk@example.com')->getEmailAddress()
```
```php
/**
* Returns true if the domain appears to accept all emails delivered to that domain
* @return boolean
*/
EmailValidator::verify('kkkkk@example.com')->acceptEmailsDeliveredToDomain()
```
```php
/**
* 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()
```
## Change log
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Todo: Testing
## Todo: Verify a list of emails
You can run the tests with:
```bash
vendor/bin/phpunit run
```
Alternatively, you can run the tests like so:
```bash
composer test
```
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## How can I thank you?
Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or HackerNews? Spread the word!
Don't forget to [follow me on twitter](https://twitter.com/unicodeveloper)!
Thanks!
Prosper Otemuyiwa.
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.