{"id":15025296,"url":"https://github.com/daveearley/email-validation-tool","last_synced_at":"2025-05-16T18:05:49.884Z","repository":{"id":22813136,"uuid":"97335940","full_name":"daveearley/Email-Validation-Tool","owner":"daveearley","description":"An easy to use, accurate-ish \u0026 extensible email validation library for PHP 7+ 📧","archived":false,"fork":false,"pushed_at":"2022-03-24T13:12:34.000Z","size":5359,"stargazers_count":276,"open_issues_count":7,"forks_count":45,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-03T17:13:06.605Z","etag":null,"topics":["email","email-validation","email-verification","php","php-7","php-email-validation"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daveearley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-15T18:52:24.000Z","updated_at":"2025-02-11T21:33:26.000Z","dependencies_parsed_at":"2022-08-07T10:16:14.752Z","dependency_job_id":null,"html_url":"https://github.com/daveearley/Email-Validation-Tool","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daveearley%2FEmail-Validation-Tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daveearley%2FEmail-Validation-Tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daveearley%2FEmail-Validation-Tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daveearley%2FEmail-Validation-Tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daveearley","download_url":"https://codeload.github.com/daveearley/Email-Validation-Tool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248598291,"owners_count":21131067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","email-validation","email-verification","php","php-7","php-email-validation"],"created_at":"2024-09-24T20:02:01.150Z","updated_at":"2025-04-12T16:39:56.301Z","avatar_url":"https://github.com/daveearley.png","language":"PHP","readme":"\u003cp align=\"center\"\u003e\n\u003cimg src='http://i.imgur.com/FEHjqbu.png' alt='PHP Email Validation Tool' /\u003e\n\u003c/p\u003e\n\n[![codecov](https://codecov.io/gh/daveearley/Email-Validation-Tool/branch/master/graph/badge.svg)](https://codecov.io/gh/daveearley/Email-Validation-Tool/) [![Build Status](https://travis-ci.org/daveearley/Email-Validation-Tool.svg?branch=master)](https://travis-ci.org/daveearley/Email-Validation-Tool) [![Code Climate](https://codeclimate.com/github/daveearley/Email-Validation-Tool/badges/gpa.svg)](https://codeclimate.com/github/daveearley/Email-Validation-Tool/)\n\n**An extensible email validation library for PHP 7+**\n\nThe 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.\n\nCurrently this tool checks the following:\n\n\n| Validation  | Description |\n| ------------- | ------------- |\n| MX records  | Checks if the email's domain has valid MX records  |\n| 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()](http://php.net/manual/en/function.filter-var.php)).  |\n| Email Host  | Checks if the email's host (e.g gmail.com) is reachable  |\n| Role/Business Email^  | Checks if the email is a role/business based email (e.g info@reddit.com).  |\n| Disposable email provider^  | Checks if the email is a [disposable email](https://en.wikipedia.org/wiki/Disposable_email_address) (e.g person@10minutemail.com).  |\n| Free email provider^  | Checks if the email is a free email (e.g person@yahoo.com).  |\n| Misspelled Email ^ | Checks the email for possible typos and returns a suggested correction (e.g hi@gmaol.con -\u003e hi@gmail.com).  |\n\n^ **Data used for these checks can be found [here](https://github.com/daveearley/Email-Validation-Tool/tree/master/src/data)**\n\n# Installation\n\n```bash\ncomposer require daveearley/daves-email-validation-tool\n```\n\n# Usage\n## Quick Start\n\n```php\n// Include the composer autoloader\nrequire __DIR__ . '/vendor/autoload.php';\n\n$validator = EmailValidation\\EmailValidatorFactory::create('dave@gmoil.con');\n\n$jsonResult = $validator-\u003egetValidationResults()-\u003easJson();\n$arrayResult = $validator-\u003egetValidationResults()-\u003easArray();\n\necho $jsonResult;\n\n```\n\nExpected output:\n\n```json\n{\n\"valid_format\": true,\n\"valid_mx_records\": false,\n\"possible_email_correction\": \"dave@gmail.com\",\n\"free_email_provider\": false,\n\"disposable_email_provider\": false,\n\"role_or_business_email\": false,\n\"valid_host\": false\n}\n```\n\n## Adding Custom Validations\n\nTo add a custom validation simply extend the [EmailValidation\\Validations\\Validator](https://github.com/daveearley/Email-Validation-Tool/blob/master/src/Validations/Validator.php) class and implement the **getResultResponse()** and **getValidatorName()** methods. You then register the validation using the **EmailValidation\\EmailValidator-\u003eregisterValidator()** method.\n\n\n### Example code\n\n// Validations/GmailValidator.php\n```php\n\u003c?php\n\nnamespace EmailValidation\\Validations;\n\nclass GmailValidator extends Validator\n{\n    public function getValidatorName(): string\n    {\n        return 'is_gmail';\n    }\n\n    public function getResultResponse(): bool\n    {\n        $hostName = $this-\u003egetEmailAddress()-\u003egetHostPart();\n        return strpos($hostName, 'gmail.com') !== false;\n    }\n}\n```\n\n// file-where-you-are-doing-your-validation.php\n```php\n\u003c?php\n\nuse EmailValidation\\Validations\\GmailValidator;\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$validator = EmailValidation\\EmailValidatorFactory::create('dave@gmail.com');\n\n$validator-\u003eregisterValidator(new GmailValidator());\n\necho $validator-\u003egetValidationResults()-\u003easJson();\n```\n\nThe expected output will be:\n\n```json\n{\n\"is_gmail\": true,\n\"valid_format\": true,\n\"valid_mx_records\": false,\n\"possible_email_correction\": \"\",\n\"free_email_provider\": true,\n\"disposable_email_provider\": false,\n\"role_or_business_email\": false,\n\"valid_host\": false\n}\n```\n\n## Running in Docker\n```bash\ndocker-compose up -d \n```\nYou can then validate an email by navigating to http://localhost:8880?email=email.to.validate@example.com. The result will be JSON string as per above.\n\n## Adding a custom data source\n\nYou can create your own data provider by creating a data provider class which implements the [EmailValidation\\EmailDataProviderInterface](https://github.com/daveearley/Email-Validation-Tool/blob/master/src/EmailDataProviderInterface.php).\n\nExample Code:\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace EmailValidation;\n\nclass CustomEmailDataProvider implements EmailDataProviderInterface\n{\n    public function getEmailProviders(): array\n    {\n        return ['custom.com'];\n    }\n\n    public function getTopLevelDomains(): array\n    {\n        return ['custom'];\n    }\n\n    public function getDisposableEmailProviders(): array\n    {\n        return ['custom.com', 'another.com'];\n    }\n\n    public function getRoleEmailPrefixes(): array\n    {\n        return ['custom'];\n    }\n}\n```\n\n# FAQ\n\n### Is this validation accurate?\nNo, none of these tests are 100% accurate. As with any email validation there will always be false positives \u0026 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.\n\n### Can I manually update the disposable email provider data?\nYes, this project relies on [this great]( https://github.com/ivolo/disposable-email-domains) repository for its list of disposable email providers. To fetch the latest list from that repo you can run\n\n```shell\n./scripts/update-dispsable-email-providers.php\n```\n\nfrom the command line. This will fetch the data and save it to *./src/data/disposable-email-providers.php*","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaveearley%2Femail-validation-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaveearley%2Femail-validation-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaveearley%2Femail-validation-tool/lists"}