function _email_verify_check in Email Verify 7.2
Same name and namespace in other branches
- 6 email_verify.inc.php \_email_verify_check()
- 7 email_verify.inc.php \_email_verify_check()
Manage cache before calling internal verification function.
1 call to _email_verify_check()
- email_verify_check in ./
email_verify.module - Verifies whether the given mail address exists.
File
- ./
email_verify.inc, line 11 - Checks the email address for validity.
Code
function _email_verify_check($mail, $use_caching = FALSE) {
// Check to see if debugging is enables, and if it is, start collectiong
// debugging information.
$debugging_mode = variable_get('email_verify_debug_mode', FALSE);
$date_time_format = variable_get('email_verify_debug_mode_date_format', 'long');
$debugging_text = array();
if ($debugging_mode) {
$debugging_text[] = t('Beginning the verification of email address "%mail" (!date_time).', array(
'%mail' => $mail,
'!date_time' => format_date(time(), $date_time_format),
));
}
$results = array();
// SMTP servers will eventually block the IP address used to verify email
// addresses, so it is better to try and cache them.
$cache_key = 'email_block_' . $mail;
if ($debugging_mode) {
$debugging_text[] = t('Checking to see if the results will be returned from the cache (!date_time).', array(
'!date_time' => format_date(time(), $date_time_format),
));
}
if ($use_caching && ($cache = cache_get($cache_key, 'cache_email_verify'))) {
if ($debugging_mode) {
$debugging_text[] = t('Caching has been selected, so the results will be returned from the cache (!date_time).', array(
'!date_time' => format_date(time(), $date_time_format),
));
}
// An empty data property means the email verification had some issue
// (rejected, etc.).
if (!empty($cache->data)) {
watchdog('email_verify', 'Cached verification for [@mail]: @result', array(
'@mail' => $mail,
'@result' => $cache->data,
));
}
$results = $cache->data;
}
else {
if ($debugging_mode) {
$debugging_text[] = t('Caching was not selected, so the results will be returned from a fresh verification (!date_time).', array(
'!date_time' => format_date(time(), $date_time_format),
));
}
$results = _email_verify_check_internal($mail, $debugging_mode, $debugging_text, $date_time_format);
cache_set($cache_key, $results, 'cache_email_verify', CACHE_TEMPORARY);
}
if ($debugging_mode) {
$results['debugging_text'][] = t('Ending the verification of email address "%mail". It %verification_results verification (!date_time).', array(
'%mail' => $mail,
'%verification_results' => empty($results['verification_message']) ? 'passed' : 'failed',
'!date_time' => format_date(time(), $date_time_format),
));
}
return $results;
}