THIS PROJECT HAS BEEN ABANDONED PLEASE USE egulias/email-validator at https://github.com/egulias/EmailValidator INSTEAD. THANKS.
Email Horse is an email validation class to verify the presence of email. The Email_Horse class is used to check if an email address is valid and real using SMTP protocol in PHP. You need to use one function of Email_Horse class to verify the email address in PHP.
Email_Horse Does the followings
- Validate the format of the email address.
- Get MX records of the domain of the email address.
- Connect to the SMTP server by the MX records.
- Check if given recipient email address is valid.
- Check if the user of email's domain exists.
Use composer to install
composer require mitmelon/email_horse
require_once __DIR__."/vendor/autoload.php";
// Initialize library class
$mail = new Email_Horse();
// Set the timeout value on stream
$mail->setStreamTimeoutWait(20);
// Set debug output mode
$mail->Debug= TRUE;
$mail->Debugoutput= 'html';
// Set email address for SMTP request
$mail->setEmailFrom('from@email.com');
// Email to check/validate
$email = 'email@example.com';
// Check if email is valid and exist
if($mail->check($email)){
echo 'Email <'.$email.'> is exist!';
}elseif($mail::validate($email)){
echo 'Email <'.$email.'> is valid, but not exist!';
}else{
echo 'Email <'.$email.'> is not valid and not exist!';
}
Released under the MIT license