A Library extending https://github.com/semplon/php-smtp-email-validation
Check if email address exists via SMTP.
- php >= 5.5
- composer require plumpboy/email-validate
...
use Plumpboy\EmailValidate\SMTPEmailValidator;
...
// the email to validate
$email = '[email protected]'; // $email can be array('[email protected]', '[email protected]')
// an optional sender
$sender = '[email protected]';
// instantiate the class
$SMTPValidator = new SMTPEmailValidator();
// turn on debugging if you want to view the SMTP transaction
$SMTPValidator->debug = true;
// do the validation
$results = $SMTPValidator->validate($email, $sender);
// view results
echo $email.' is '.($results ? 'valid' : 'invalid')."\n"; // $results[$email] when there are many emails
// send email?
if ($results) { // or $results['[email protected]'] if you pass many emails
//mail($email, 'Confirm Email', 'Please reply to this email to confirm', 'From:'.$sender."\r\n"); // send email
} else {
echo 'The email addresses you entered is not valid';
}
For projects use laravel version < 5.5, add below code into config/app.php.
...
'providers' => [
...
Plumpboy\EmailValidate\EmailValidateServiceProvider::class,
...
],
...
You also can use below syntax in laravel.
$result = email_exists($emails, $sender); // use helper
...
use Plumpboy\EmailValidate\EmailValidator;
...
$result = EmailValidator::validate($email, $sender); // use facade
$result = \EmailValidator::validate($email, $sender); // or alias
if you do not pass param $sender, library will use config('mail.from.address')
.
- Fork the repository and make changes on your fork in a feature branch.
- Commit messages must start with a capitalized and short summary.
- After every commit, make sure the test suite passes.
- Contributor sends pull request to release/develop branch, ask another contributor to check if possible.
- Don't push private keys, logs or any unnecessary files to git repository
- Merge when pull request got 2 OK from contributors and CI build is green.
- Merge develop to master to release final version.