PHP code example of justinwang / mailgun-email-validation
1. Go to this page and download the library: Download justinwang/mailgun-email-validation 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/ */
justinwang / mailgun-email-validation example snippets
use Yue\MailGunEmailValidation\EmailValidator;
// Init the configurations
$config = [
// Required: Public validation key, in your Mailgun settings.
'public_key' =>'your_public_validation_key',
// Required: Private API key, in your Mailgun settings.
'private_key' =>'your_private_api_key',
// Optional: By default, we will use V4 version API
'version' =>EmailValidator::V3,
];
// Get validator instance
$validator = EmailValidator::GetInstance($config);
// Validate an email
$email = 'example@your_domain.com';
try{
$result = $validator->validate($email);
$valid = $result->success(); // true for the valid email
}catch (\Exception $exception){
var_dump($exception->getMessage());
}
// Todo: next ...