function postmark_parse_address in Postmark 7
Same name and namespace in other branches
- 6 postmark.module \postmark_parse_address()
Extract address and optional display name of an e-mail address.
Parameters
$address: A string containing one or more valid e-mail address(es) separated with commas.
Return value
An array containing all found e-mail addresses split into mail and name.
See also
http://tools.ietf.org/html/rfc5322#section-3.4
1 call to postmark_parse_address()
- PostmarkMailSystem::mail in ./
postmark.mail.inc - Send the e-mail message.
File
- ./
postmark.module, line 84 - This module allows for the inclusion of Postmark as the native Drupal mail handler using the new Drupal mail system interface.
Code
function postmark_parse_address($address) {
$parsed = array();
$regexp = "/^(.*) <([a-z0-9]+(?:[_\\.-][a-z0-9]+)*@(?:[a-z0-9]+(?:[\\.-][a-z0-9]+)*)+\\.[a-z]{2,})>\$/i";
// Split multiple addresses and process each.
foreach (explode(',', $address) as $email) {
$email = trim($email);
if (preg_match($regexp, $email, $matches)) {
$parsed[] = array(
'mail' => $matches[2],
'name' => trim($matches[1], '"'),
);
}
else {
$parsed[] = array(
'mail' => $email,
'name' => '',
);
}
}
return $parsed;
}