function webform_valid_email_address in Webform 7.4
Validates email address(es) with optional name(s).
Parameters
string $emails: An email address, a list of comma-separated email addresses. If all the addresses are valid, the list of trimmed, non-empty emails is returned by reference.
bool $allow_tokens: TRUE if any token should be assumed to contain a valid e-mail address.
string $format: 'short', 'long', or NULL (for default) format. Long format has a name and the address in angle brackets.
Return value
bool|int Returns FALSE if an invalid e-mail address was found, 0 if no email address(es) were found, or the number of valid e-mail addresses found.
2 calls to webform_valid_email_address()
- webform_email_validate in ./
webform.module - Validates an email form element.
- webform_valid_email_address_filter in ./
webform.module - Wrapper for webform_valid_email_address(). Counts valid email addresses.
1 string reference to 'webform_valid_email_address'
- webform_submission_resend in includes/
webform.submissions.inc - Form to resend specific e-mails associated with a submission.
File
- ./
webform.module, line 4719 - This module provides a simple way to create forms and questionnaires.
Code
function webform_valid_email_address(&$emails, $allow_tokens = FALSE, $format = NULL) {
$email_array = array_filter(array_map('trim', explode(',', $emails)));
$count = 0;
foreach ($email_array as $email) {
if ($allow_tokens && webform_variable_get('webform_token_access')) {
foreach (token_scan($email) as $tokens) {
foreach ($tokens as $token) {
$email = str_replace($token, 'admin@example.com', $email);
}
}
}
$matches = webform_parse_email_address($email, $format);
if (!valid_email_address($matches['address'])) {
return FALSE;
}
$count++;
}
$emails = implode(', ', $email_array);
return $count;
}