}
$is_encoded = false;
$addr_structure->group = $group;
+ $grouplookup = false;
if ($at) {
$addr_structure->mailbox = substr($addr, 0, $at);
$addr_structure->host = substr($addr, $at+1);
if ($lookup) {
$aAddr = call_user_func_array($lookup,array($addr));
if (isset($aAddr['email'])) {
- $at = strpos($aAddr['email'], '@');
- $addr_structure->mailbox = substr($aAddr['email'], 0, $at);
- $addr_structure->host = substr($aAddr['email'], $at+1);
- if (isset($aAddr['name'])) {
- $addr_structure->personal = $aAddr['name'];
+ if (strpos($aAddr['email'],',')) {
+ $grouplookup = true;
+ $addr_ar = $this->parseAddress($aAddr['email'], $ar, $addr_ar, $group, $host,$lookup);
} else {
- $addr_structure->personal = encodeHeader($addr);
+ $at = strpos($aAddr['email'], '@');
+ $addr_structure->mailbox = substr($aAddr['email'], 0, $at);
+ $addr_structure->host = substr($aAddr['email'], $at+1);
+ if (isset($aAddr['name'])) {
+ $addr_structure->personal = $aAddr['name'];
+ } else {
+ $addr_structure->personal = encodeHeader($addr);
+ }
}
}
}
- if (!$addr_structure->mailbox) {
+ if (!$grouplookup && !$addr_structure->mailbox) {
$addr_structure->mailbox = trim($addr);
if ($host) {
$addr_structure->host = $host;
$pos = 0;
$name = '';
$addr = '';
- $addr_ar[] = $addr_structure;
+ if (!$grouplookup) {
+ $addr_ar[] = $addr_structure;
+ }
break;
case ':': /* process the group addresses */
/* group marker */
$group = substr($address, 0, $pos);
$address = substr($address, $pos+1);
- $result = $this->parseAddress($address, $ar, $addr_ar, $group);
+ $result = $this->parseAddress($address, $ar, $addr_ar, $group, $lookup);
$addr_ar = $result[0];
$pos = $result[1];
$address = substr($address, $pos++);
if ($lookup) {
$aAddr = call_user_func_array($lookup,array($addr));
if (isset($aAddr['email'])) {
- $at = strpos($aAddr['email'], '@');
- $addr_structure->mailbox = substr($aAddr['email'], 0, $at);
- $addr_structure->host = substr($aAddr['email'], $at+1);
- if (isset($aAddr['name']) && $aAddr['name']) {
- $name = $aAddr['name'];
+ if (strpos($aAddr['email'],',')) {
+ return $this->parseAddress($aAddr['email'], $ar, $addr_ar, $group, $host,$lookup);
} else {
- $name = $addr;
+ $at = strpos($aAddr['email'], '@');
+ $addr_structure->mailbox = substr($aAddr['email'], 0, $at);
+ $addr_structure->host = substr($aAddr['email'], $at+1);
+ if (isset($aAddr['name']) && $aAddr['name']) {
+ $name = $aAddr['name'];
+ } else {
+ $name = $addr;
+ }
}
}
}