Perform email address validation/verification via SMTP.
The class retrieves MX records for the email domain and then connects to the domain's SMTP server to try figuring out if the address really exists.
- Not really sending a message, gracefully resetting the session when done
- Command-specific communication timeouts implemented per relevant RFCs
- Catch-all account detection
- Batch mode processing supported
- MX query support on Windows without requiring any PEAR packages
- Logging and debugging support
<?php
require('smtp-validate-email.php');
$from = '[email protected]'; // for SMTP FROM:<> command
$email = '[email protected]';
$validator = new SMTP_Validate_Email($email, $from);
$smtp_results = $validator->validate();
var_dump($smtp_results);
The class supports passing an array of addresses in the constructor or to the
validate()
method. Checking multiple addresses on the same server uses
a single connection.
<?php
require('smtp-validate-email.php');
$from = '[email protected]'; // for SMTP FROM:<> command
$emails = array(
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]'
);
$validator = new SMTP_Validate_Email($emails, $from);
$smtp_results = $validator->validate();
// or passing to the validate() method
// $validator = new SMTP_Validate_Email();
// $smtp_results = $validator->validate($emails, $from);
var_dump($smtp_results);