PHP code example of plumpboy / email-validate

1. Go to this page and download the library: Download plumpboy/email-validate 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/ */

    

plumpboy / email-validate example snippets


...
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';
	}

...
'providers' => [
	...
    Plumpboy\EmailValidate\EmailValidateServiceProvider::class,
    ...
],
...

$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