Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nojacko/email-validator
Small PHP library to valid email addresses using a number of methods.
https://github.com/nojacko/email-validator
Last synced: about 1 month ago
JSON representation
Small PHP library to valid email addresses using a number of methods.
- Host: GitHub
- URL: https://github.com/nojacko/email-validator
- Owner: nojacko
- License: mit
- Archived: true
- Created: 2014-10-20T17:14:03.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-07-21T12:53:48.000Z (over 6 years ago)
- Last Synced: 2024-09-30T20:37:40.548Z (2 months ago)
- Language: PHP
- Homepage: https://github.com/nojacko/email-validator
- Size: 36.1 KB
- Stars: 163
- Watchers: 9
- Forks: 22
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-php - Email Validator - A small email address validation library. (Table of Contents / Email)
- awesome-projects - Email Validator - A small email address validation library. (PHP / Email)
- awesome-php - Email Validator - A small email address validation library. (Table of Contents / Email)
- awesome-php-cn - Email Validator - 一个小的电子邮件地址验证库. (目录 / 电子邮件 Email)
README
# Email Validator
Small PHP library to valid email addresses using a number of methods.[![License](https://img.shields.io/github/license/nojacko/email-validator.svg)](https://github.com/nojacko/email-validator/blob/master/LICENSE)
[![Build Status](https://img.shields.io/travis/nojacko/email-validator.svg)](https://travis-ci.org/nojacko/email-validator)
[![Code Quality](https://img.shields.io/codacy/7b3a2c246622431abd1fc4e2750aae1b.svg)](https://www.codacy.com/app/nojacko/email-validator)
[![Downloads](https://img.shields.io/packagist/dm/nojacko/email-validator.svg)](https://packagist.org/packages/nojacko/email-validator)
[![Github Stars](https://img.shields.io/github/stars/nojacko/email-validator.svg)](https://github.com/nojacko/email-validator/stargazers)## Features
* Validates email address
* Checks for **example** domains (e.g. example.com)
* Checks for **disposable** email domains (e.g. mailinator.com)
* Checks for **role-based** addresses (e.g. abuse@)
* Checks for **MX records** (i.e. can receive email)## Install (using Composer)
```
composer require nojacko/email-validator:~1.0
```## Usage
### Generalised Functions
* ```isValid($email)``` Runs all the tests within this library. Returns true or false.
* ```isSendable($email)``` Checks isEmail, isExample and hasMx. Returns true or false.### Specific Functions
If you want more control, use these functions seperately.* ```isEmail($email)``` Note: returns true or false only.
* ```isExample($email)```
* ```isDisposable($email)```
* ```isRole($email)```
* ```hasMx($email)```These functions take a single argument (an email address) and return:
* true, when function name is satisfied.
* false, when function name is not satisfied.
* null, when check is not possible, i.e. an invalid email is given.## Examples
```
$validator = new \EmailValidator\Validator();$validator->isValid('[email protected]'); // true
$validator->isValid('[email protected]'); // false
$validator->isValid('[email protected]'); // false$validator->isSendable('[email protected]'); // true
$validator->isSendable('[email protected]'); // true
$validator->isSendable('[email protected]'); // false$validator->isEmail('[email protected]'); // true
$validator->isEmail('example@example'); // false$validator->isExample('[email protected]'); // true
$validator->isExample('[email protected]'); // false
$validator->isExample('example.com'); // null$validator->isDisposable('[email protected]'); // false
$validator->isDisposable('[email protected]'); // true
$validator->isDisposable('example.com'); // null$validator->isRole('[email protected]'); // false
$validator->isRole('[email protected]'); // true
$validator->isRole('example.com'); // null$validator->hasMx('[email protected]'); // false
$validator->hasMx('[email protected]'); // true
$validator->hasMx('example.com'); // null
```## Contribute
Contributions welcome!### Requirements
* [Test-driven development](http://en.wikipedia.org/wiki/Test-driven_development)
* Follow [PSR-2 Coding Style Guide](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
* One change per pull request### Add/Remove Disposable Domain
See the [email-data-disposable](https://github.com/nojacko/email-data-disposable) project.### New Feature
If you're planning a new feature, please raise an issue first to ensure it's in scope. The aim is to keep this library small and with one specific purpose.### Other Contributions
For anything that isn't a new feature (bug fix, tests, etc) just create a pull request.## Testing
Test are all located in ```tests``` folder.Run tests with phpunit. In root folder, execute ```phpunit``` in a CLI.
## Versioning
[Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html)## License
The MIT License (MIT). See LICENCE file.