1. Go to this page and download the library: Download sorciulus/email-checker 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/ */
sorciulus / email-checker example snippets
sorciulus\EmailChecker\EmailChecker;
use sorciulus\EmailChecker\Exception\EmailCheckerException;
try {
$check = new EmailChecker("[email protected]", "[email protected]");
$result = $check->validate()->isValid(); // instance of ResponseChecker
if ($result) {
echo "Email is valid";
} else {
echo "Email not valid";
}
} catch (EmailCheckerException $ex) {
echo $ex->getMessage();
}
sorciulus\EmailChecker\EmailChecker;
use sorciulus\EmailChecker\Exception\EmailCheckerException;
try {
$check = new EmailChecker();
$disponsibleService = $check->getDisponsableService();
// You can use email or domain
if ($disponsibleService->isDisponsable("[email protected]")) {
echo "Email is disponsable";
} else {
echo "Email not disponsable";
}
} catch (EmailCheckerException $ex) {
echo $ex->getMessage();
}
sorciulus\EmailChecker\EmailChecker;
use sorciulus\EmailChecker\Exception\EmailCheckerException;
$emails = ["[email protected]", "[email protected]", "[email protected]"];
$check = new EmailChecker("[email protected]");
// you can set Sender outside loop
// $check->setSender("[email protected]");
foreach($emails as $email) {
try {
// or you can set Sender inside loop
//$check->setSender("[email protected]");
$check->setEmail($email);
$result = $check->validate()->isValid(); // instance of ResponseChecker
if ($result) {
echo "Email is valid";
} else {
echo "Email not valid";
}
} catch (EmailCheckerException $ex) {
echo $ex->getMessage();
}
}
try {
$check = new EmailChecker("[email protected]");
$result = $check->validate(); // instance of ResponseChecker
$debug = $result->getDebug();
if ($result->isValid()) {
echo "Email is valid";
} else {
echo "Email not valid";
}
} catch (EmailCheckerException $ex) {
$debug = $ex->getDebug();
echo $ex->getMessage();
}