function postmark_parse_address in Postmark 6
Same name and namespace in other branches
- 7 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()
- postmark_send in includes/
postmark.drupal.inc - Send out an e-mail.
File
- ./
postmark.module, line 78 - This module allows for the inclusion of Postmark as the native Drupal mail handler, and uses drupal_mail_wrapper to send emails from Drupal using Postmark
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;
}