Skip to content

DaaN88/php-email-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Descriptions

This package allows you to validate an email before actually sending mail to that email. Checking MX records occurs, including with the help of google.

Getting started

Requirements

  • PHP 8.1.5+
  • Composer 2+

Installation

composer require ashvedov/email-validator

Usage

Anywhere in your code, just include the class EmailValidator in the use section and you're good to go. It is possible to receive the result of the check as JSON, array or string.

Example

use Src\EmailValidator;

$validator = new EmailValidator(
    emails: [
        '[email protected]',
        '[email protected]',
        '[email protected]',
        '[email protected]',
        '[email protected]',
        '[email protected]',
        '[email protected]',
        '[email protected]',
        23,
        '[email protected]'
    ]
);
var_dump($validator->validate()->toArray());
Result
  • array:
array(3) {
  [23]=>
  array(4) {
    [0]=>
    string(17) "filter_var_errors"
    [1]=>
    string(12) "regex_errors"
    [2]=>
    string(16) "mx_record_errors"
    [3]=>
    string(22) "world_mx_record_errors"
  }
  ["[email protected]"]=>
  array(2) {
    [0]=>
    string(16) "mx_record_errors"
    [1]=>
    string(22) "world_mx_record_errors"
  }
  ["[email protected]"]=>
  array(2) {
    [0]=>
    string(16) "mx_record_errors"
    [1]=>
    string(22) "world_mx_record_errors"
  }
}

About

Email validation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages