PHP code example of zytzagoo / smtp-validate-email
1. Go to this page and download the library: Download zytzagoo/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/ */
zytzagoo / smtp-validate-email example snippets
MTPValidateEmail\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);
MTPValidateEmail\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($emails, $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);
MTPValidateEmail\Validator as SMTP_Validate_Email;
// Now any old code referencing `SMTP_Validate_Email` should still work as it did earlier
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.