protected function SmtpMailSystem::_get_components in SMTP Authentication Support 7.2
Same name and namespace in other branches
- 7 smtp.mail.inc \SmtpMailSystem::_get_components()
Returns an array of name and email address from a string.
Parameters
$input: A string that contains different possible combinations of names and email address.
Return value
An array containing a name and an email address.
1 call to SmtpMailSystem::_get_components()
File
- ./
smtp.mail.inc, line 774 - The code processing mail in the smtp module.
Class
- SmtpMailSystem
- Modify the drupal mail system to use smtp when sending emails. Include the option to choose between plain text or HTML
Code
protected function _get_components($input) {
$components = array(
'input' => $input,
'name' => '',
'email' => '',
);
// If the input is a valid email address in its entirety, then there is
// nothing to do, just return that.
if (valid_email_address($input)) {
$components['email'] = trim($input);
return $components;
}
// Check if $input has one of the following formats, extract what we can:
// some name <address@example.com>
// "another name" <address@example.com>
// <address@example.com>
if (preg_match('/^"?([^"\\t\\n]*)"?\\s*<([^>\\t\\n]*)>$/', $input, $matches)) {
$components['name'] = trim($matches[1]);
$components['email'] = trim($matches[2]);
}
return $components;
}