PHP code example of myamwso / smtp-validate-email

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

    

myamwso / smtp-validate-email example snippets




use SMTPValidateEmail\Validator as SmtpEmailValidator;

/**
 * Simple example
 */
$email     = '[email protected]';
$sender    = '[email protected]';
$validator = new SmtpEmailValidator($email, $sender);

// If debug mode is turned on, logged data is printed as it happens:
// $validator->debug = true;
$results   = $validator->validate();

var_dump($results);

// Get log data (log data is always collected)
$log = $validator->getLog();
var_dump($log);



use SMTPValidateEmail\Validator as SmtpEmailValidator;

/**
 * Validating multiple addresses/recipients at once:
 * (checking multiple addresses belonging to the same server
 * uses a single connection)
 */
$emails    = [
    '[email protected]',
    '[email protected]'
];
$sender    = '[email protected]';
$validator = new SmtpEmailValidator($email, $sender):
$results   = $validator->validate();

var_dump($results);

/**
 * The `validate()` method accepts the same parameters
 * as the constructor, so this is equivalent to the above:
 */
$emails    = [
    '[email protected]',
    '[email protected]'
];
$sender    = '[email protected]';
$validator = new SmtpEmailValidator():
$results   = $validator->validate($emails, $sender);

var_dump($results);



use SMTPValidateEmail\Validator as SMTP_Validate_Email;

// Now any old code referencing `SMTP_Validate_Email` should still work as it did earlier