Skip to content
Snippets Groups Projects
Commit 9cb1a82d authored by Anton Sarukhanov's avatar Anton Sarukhanov
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
/*
Plugin Name: Contact Form 7 Email Validator
Plugin URI: https://wordpress.org/plugins/contact-form-7-email-validator
Description: Validate email addresses in Contact Form 7 submissions.
Version: 0.1
Author: Anton Sarukhanov
Author URI: https://ant.sr
License: MIT
*/
add_filter('wpcf7_validate_email*', 'wpcf7ev_validate_email', 20, 2);
function wpcf7ev_validate_email($result, $tag) {
$tag = new WPCF7_FormTag($tag);
$email = isset($_POST[$tag->name]) ? trim($_POST[$tag->name]) : '';
$mailboxlayer_access_key = 'YOUR_ACCESS_KEY';
$ch = curl_init('http://apilayer.net/api/check?access_key='.$mailboxlayer_access_key.'&email='.$email.'');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
curl_close($ch);
$validationResult = json_decode($json, true);
if (!$validationResult['smtp_check']) {
$result->invalidate($tag, "This email address could not be verified!");
}
return $result;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment