PHP code example of ezeanyimhenry / email-validator
1. Go to this page and download the library: Download ezeanyimhenry/email-validator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ezeanyimhenry / email-validator example snippets
zeanyimHenry\EmailValidator\EmailValidator;
// Create a new instance of the EmailValidator
$emailValidator = new EmailValidator();
// Validate a single email address
$result = $emailValidator->validate('[email protected]');
if ($result['isValid']) {
echo "The email is valid.";
} else {
echo "Error: " . $result['message'];
}
zeanyimHenry\EmailValidator\EmailValidator;
// Create a new instance of the EmailValidator
$emailValidator = new EmailValidator();
// Validate multiple email addresses
$emails = [
'[email protected]',
'invalid-email',
'[email protected]',
];
$results = $emailValidator->validate($emails);
foreach ($results as $email => $result) {
echo "$email: " . ($result['isValid'] ? "Valid" : "Invalid - " . $result['message']) . "\n";
}
zeanyimHenry\EmailValidator\EmailValidator;
// Create a new instance with custom configuration
$emailValidator = new EmailValidator([
'checkMxRecords' => true,
'checkBannedListedEmail' => true,
'checkDisposableEmail' => true,
'checkFreeEmail' => false,
]);
// Validate an email
$result = $emailValidator->validate('[email protected]');
if (!$result['isValid']) {
echo "Validation failed: " . $result['message'];
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.