+ }
+ $is_encoded = false;
+ $addr_structure->group = $group;
+ if ($at) {
+ $addr_structure->mailbox = substr($addr, 0, $at);
+ $addr_structure->host = substr($addr, $at+1);
+ } else {
+ /* if lookup function */
+ 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'];
+ } else {
+ $addr_structure->personal = encodeHeader($addr);
+ }
+ }
+ }
+ if (!$addr_structure->mailbox) {
+ $addr_structure->mailbox = trim($addr);
+ if ($host) {
+ $addr_structure->host = $host;
+ }
+ }
+ }
+ $address = trim(substr($address, $pos+1));
+ $j = strlen($address);
+ $pos = 0;
+ $name = '';
+ $addr = '';
+ $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);
+ $addr_ar = $result[0];
+ $pos = $result[1];
+ $address = substr($address, $pos++);
+ $j = strlen($address);
+ $group = '';
+ break;
+ case ';':
+ if ($group) {
+ $address = substr($address, 0, $pos - 1);
+ }
+ ++$pos;
+ break;
+ case ' ':
+ ++$pos;
+ break;
+ default:
+ /*
+ * this happens in the folowing situations :
+ * 1: unquoted personal name
+ * 2: emailaddress without < and >
+ * 3: unquoted personal name from compose that should be encoded.
+ * if it's a personal name then an emailaddress should follow
+ * the personal name may not have ',' inside it
+ * If it's a emailaddress then the personal name is not set.
+ * we should look for the delimiter ',' or a SPACE
+ */
+ /* check for emailaddress */
+ $i_space = strpos($address,' ',$pos);
+ $i_del = strpos($address,',',$pos);
+ if ($i_space || $i_del) {
+ if ($i_del) {
+ $address_part = substr($address,$pos,$i_del-$pos);