Check and make sure the header property value is actually set to something before...
[squirrelmail.git] / class / mime / Rfc822Header.class.php
CommitLineData
19d470aa 1<?php
2
3/**
4 * Rfc822Header.class.php
5 *
82d304a0 6 * Copyright (c) 2003-2004 The SquirrelMail Project Team
19d470aa 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This contains functions needed to handle mime messages.
10 *
883d9cd3 11 * @version $Id$
2b646597 12 * @package squirrelmail
19d470aa 13 */
14
2b646597 15/**
19d470aa 16 * input: header_string or array
2b646597 17 * @package squirrelmail
19d470aa 18 */
19class Rfc822Header {
2a9b0fad 20 var $date = -1,
19d470aa 21 $subject = '',
22 $from = array(),
23 $sender = '',
24 $reply_to = array(),
b268e66b 25 $mail_followup_to = array(),
19d470aa 26 $to = array(),
27 $cc = array(),
28 $bcc = array(),
29 $in_reply_to = '',
30 $message_id = '',
340d67c2 31 $references = '',
19d470aa 32 $mime = false,
33 $content_type = '',
34 $disposition = '',
35 $xmailer = '',
36 $priority = 3,
37 $dnt = '',
f1232547 38 $encoding = '',
cfebb724 39 $content_id = '',
40 $content_desc = '',
19d470aa 41 $mlist = array(),
42 $more_headers = array(); /* only needed for constructing headers
43 in smtp.php */
44 function parseHeader($hdr) {
45 if (is_array($hdr)) {
46 $hdr = implode('', $hdr);
47 }
2a9b0fad 48 /* First we replace \r\n by \n and unfold the header */
49 $hdr = trim(str_replace(array("\r\n", "\n\t", "\n "),array("\n", ' ', ' '), $hdr));
19d470aa 50
51 /* Now we can make a new header array with */
52 /* each element representing a headerline */
2a9b0fad 53 $hdr = explode("\n" , $hdr);
19d470aa 54 foreach ($hdr as $line) {
55 $pos = strpos($line, ':');
56 if ($pos > 0) {
57 $field = substr($line, 0, $pos);
340d67c2 58 if (!strstr($field,' ')) { /* valid field */
59 $value = trim(substr($line, $pos+1));
60 $this->parseField($field, $value);
61 }
19d470aa 62 }
63 }
64 if ($this->content_type == '') {
65 $this->parseContentType('text/plain; charset=us-ascii');
66 }
67 }
68
69 function stripComments($value) {
70 $result = '';
19d470aa 71 $cnt = strlen($value);
72 for ($i = 0; $i < $cnt; ++$i) {
73 switch ($value{$i}) {
74 case '"':
75 $result .= '"';
76 while ((++$i < $cnt) && ($value{$i} != '"')) {
77 if ($value{$i} == '\\') {
78 $result .= '\\';
79 ++$i;
80 }
81 $result .= $value{$i};
82 }
83 $result .= $value{$i};
84 break;
85 case '(':
86 $depth = 1;
87 while (($depth > 0) && (++$i < $cnt)) {
88 switch($value{$i}) {
89 case '\\':
90 ++$i;
91 break;
92 case '(':
93 ++$depth;
94 break;
95 case ')':
96 --$depth;
97 break;
98 default:
99 break;
100 }
101 }
102 break;
103 default:
104 $result .= $value{$i};
105 break;
106 }
107 }
108 return $result;
109 }
110
111 function parseField($field, $value) {
112 $field = strtolower($field);
113 switch($field) {
114 case 'date':
340d67c2 115 $value = $this->stripComments($value);
19d470aa 116 $d = strtr($value, array(' ' => ' '));
117 $d = explode(' ', $d);
118 $this->date = getTimeStamp($d);
119 break;
120 case 'subject':
121 $this->subject = $value;
122 break;
123 case 'from':
124 $this->from = $this->parseAddress($value,true);
125 break;
126 case 'sender':
127 $this->sender = $this->parseAddress($value);
128 break;
129 case 'reply-to':
130 $this->reply_to = $this->parseAddress($value, true);
131 break;
b268e66b 132 case 'mail-followup-to':
133 $this->mail_followup_to = $this->parseAddress($value, true);
134 break;
19d470aa 135 case 'to':
136 $this->to = $this->parseAddress($value, true);
137 break;
138 case 'cc':
139 $this->cc = $this->parseAddress($value, true);
140 break;
141 case 'bcc':
142 $this->bcc = $this->parseAddress($value, true);
143 break;
144 case 'in-reply-to':
145 $this->in_reply_to = $value;
146 break;
147 case 'message-id':
340d67c2 148 $value = $this->stripComments($value);
19d470aa 149 $this->message_id = $value;
150 break;
340d67c2 151 case 'references':
152 $value = $this->stripComments($value);
153 $this->references = $value;
154 break;
155 case 'x-confirm-reading-to':
156 case 'return-receipt-to':
19d470aa 157 case 'disposition-notification-to':
340d67c2 158 $value = $this->stripComments($value);
19d470aa 159 $this->dnt = $this->parseAddress($value);
160 break;
161 case 'mime-version':
340d67c2 162 $value = $this->stripComments($value);
19d470aa 163 $value = str_replace(' ', '', $value);
164 $this->mime = ($value == '1.0' ? true : $this->mime);
165 break;
166 case 'content-type':
340d67c2 167 $value = $this->stripComments($value);
19d470aa 168 $this->parseContentType($value);
169 break;
170 case 'content-disposition':
340d67c2 171 $value = $this->stripComments($value);
19d470aa 172 $this->parseDisposition($value);
173 break;
cfebb724 174 case 'content-transfer-encoding':
175 $this->encoding = $value;
176 break;
177 case 'content-description':
178 $this->content_desc = $value;
179 break;
180 case 'content-id':
181 $value = $this->stripComments($value);
182 $this->content_id = $value;
183 break;
19d470aa 184 case 'user-agent':
185 case 'x-mailer':
340d67c2 186 $this->xmailer = $value;
19d470aa 187 break;
188 case 'x-priority':
189 $this->priority = $value;
190 break;
191 case 'list-post':
340d67c2 192 $value = $this->stripComments($value);
19d470aa 193 $this->mlist('post', $value);
194 break;
195 case 'list-reply':
cfebb724 196 $value = $this->stripComments($value);
19d470aa 197 $this->mlist('reply', $value);
198 break;
199 case 'list-subscribe':
cfebb724 200 $value = $this->stripComments($value);
19d470aa 201 $this->mlist('subscribe', $value);
202 break;
203 case 'list-unsubscribe':
340d67c2 204 $value = $this->stripComments($value);
19d470aa 205 $this->mlist('unsubscribe', $value);
206 break;
207 case 'list-archive':
340d67c2 208 $value = $this->stripComments($value);
19d470aa 209 $this->mlist('archive', $value);
210 break;
211 case 'list-owner':
340d67c2 212 $value = $this->stripComments($value);
19d470aa 213 $this->mlist('owner', $value);
214 break;
215 case 'list-help':
340d67c2 216 $value = $this->stripComments($value);
19d470aa 217 $this->mlist('help', $value);
218 break;
ba4d5a32 219 case 'list-id':
220 $value = $this->stripComments($value);
221 $this->mlist('id', $value);
222 break;
19d470aa 223 default:
224 break;
225 }
226 }
14882b16 227
228 function getAddressTokens($address) {
229 $aTokens = array();
230 $aAddress = array();
14882b16 231 $aSpecials = array('(' ,'<' ,',' ,';' ,':');
232 $aReplace = array(' (',' <',' ,',' ;',' :');
233 $address = str_replace($aSpecials,$aReplace,$address);
55243181 234 $iCnt = strlen($address);
14882b16 235 $i = 0;
236 while ($i < $iCnt) {
237 $cChar = $address{$i};
238 switch($cChar)
239 {
240 case '<':
241 $iEnd = strpos($address,'>',$i+1);
242 if (!$iEnd) {
243 $sToken = substr($address,$i);
244 $i = $iCnt;
245 } else {
246 $sToken = substr($address,$i,$iEnd - $i +1);
247 $i = $iEnd;
248 }
249 $sToken = str_replace($aReplace, $aSpecials,$sToken);
cfebb724 250 if ($sToken) $aTokens[] = $sToken;
14882b16 251 break;
252 case '"':
253 $iEnd = strpos($address,$cChar,$i+1);
0b4d4be7 254 if ($iEnd) {
255 // skip escaped quotes
256 $prev_char = $address{$iEnd-1};
257 while ($prev_char === '\\' && substr($address,$iEnd-2,2) !== '\\\\') {
258 $iEnd = strpos($address,$cChar,$iEnd+1);
259 if ($iEnd) {
260 $prev_char = $address{$iEnd-1};
261 } else {
262 $prev_char = false;
263 }
264 }
265 }
14882b16 266 if (!$iEnd) {
267 $sToken = substr($address,$i);
268 $i = $iCnt;
269 } else {
270 // also remove the surrounding quotes
271 $sToken = substr($address,$i+1,$iEnd - $i -1);
272 $i = $iEnd;
273 }
274 $sToken = str_replace($aReplace, $aSpecials,$sToken);
72956ab6 275 if ($sToken) $aTokens[] = $sToken;
14882b16 276 break;
277 case '(':
0b4d4be7 278 array_pop($aTokens); //remove inserted space
14882b16 279 $iEnd = strpos($address,')',$i);
280 if (!$iEnd) {
281 $sToken = substr($address,$i);
282 $i = $iCnt;
283 } else {
55243181 284 $iDepth = 1;
285 $iComment = $i;
286 while (($iDepth > 0) && (++$iComment < $iCnt)) {
287 $cCharComment = $address{$iComment};
288 switch($cCharComment) {
289 case '\\':
290 ++$iComment;
291 break;
292 case '(':
293 ++$iDepth;
294 break;
295 case ')':
296 --$iDepth;
297 break;
298 default:
299 break;
300 }
301 }
302 if ($iDepth == 0) {
303 $sToken = substr($address,$i,$iComment - $i +1);
304 $i = $iComment;
305 } else {
306 $sToken = substr($address,$i,$iEnd - $i + 1);
307 $i = $iEnd;
308 }
14882b16 309 }
0b4d4be7 310 // check the next token in case comments appear in the middle of email addresses
311 $prevToken = end($aTokens);
312 if (!in_array($prevToken,$aSpecials,true)) {
43c0e295 313 if ($i+1<strlen($address) && !in_array($address{$i+1},$aSpecials,true)) {
0b4d4be7 314 $iEnd = strpos($address,' ',$i+1);
315 if ($iEnd) {
316 $sNextToken = trim(substr($address,$i+1,$iEnd - $i -1));
317 $i = $iEnd-1;
318 } else {
a5ae4bc8 319 $sNextToken = trim(substr($address,$i+1));
0b4d4be7 320 $i = $iCnt;
321 }
322 // remove the token
323 array_pop($aTokens);
324 // create token and add it again
325 $sNewToken = $prevToken . $sNextToken;
1f0269d6 326 if($sNewToken) $aTokens[] = $sNewToken;
0b4d4be7 327 }
328 }
14882b16 329 $sToken = str_replace($aReplace, $aSpecials,$sToken);
cfebb724 330 if ($sToken) $aTokens[] = $sToken;
14882b16 331 break;
332 case ',':
0b4d4be7 333 case ':':
14882b16 334 case ';':
335 case ' ':
336 $aTokens[] = $cChar;
337 break;
338 default:
339 $iEnd = strpos($address,' ',$i+1);
340 if ($iEnd) {
341 $sToken = trim(substr($address,$i,$iEnd - $i));
342 $i = $iEnd-1;
343 } else {
344 $sToken = trim(substr($address,$i));
345 $i = $iCnt;
346 }
347 if ($sToken) $aTokens[] = $sToken;
348 }
349 ++$i;
350 }
351 return $aTokens;
352 }
353 function createAddressObject(&$aStack,&$aComment,&$sEmail,$sGroup='') {
0b4d4be7 354 //$aStack=explode(' ',implode('',$aStack));
14882b16 355 if (!$sEmail) {
356 while (count($aStack) && !$sEmail) {
357 $sEmail = trim(array_pop($aStack));
358 }
359 }
360 if (count($aStack)) {
361 $sPersonal = trim(implode('',$aStack));
cfebb724 362 } else {
14882b16 363 $sPersonal = '';
364 }
365 if (!$sPersonal && count($aComment)) {
366 $sComment = trim(implode(' ',$aComment));
367 $sPersonal .= $sComment;
368 }
369 $oAddr =& new AddressStructure();
370 if ($sPersonal && substr($sPersonal,0,2) == '=?') {
371 $oAddr->personal = encodeHeader($sPersonal);
372 } else {
373 $oAddr->personal = $sPersonal;
374 }
0b4d4be7 375 // $oAddr->group = $sGroup;
14882b16 376 $iPosAt = strpos($sEmail,'@');
377 if ($iPosAt) {
378 $oAddr->mailbox = substr($sEmail, 0, $iPosAt);
379 $oAddr->host = substr($sEmail, $iPosAt+1);
380 } else {
381 $oAddr->mailbox = $sEmail;
382 $oAddr->host = false;
383 }
14882b16 384 $sEmail = '';
385 $aStack = $aComment = array();
386 return $oAddr;
387 }
388
e74ba378 389 /*
cfebb724 390 * parseAddress: recursive function for parsing address strings and store
e74ba378 391 * them in an address stucture object.
392 * input: $address = string
393 * $ar = boolean (return array instead of only the
394 * first element)
14882b16 395 * $addr_ar = array with parsed addresses // obsolete
396 * $group = string // obsolete
cfebb724 397 * $host = string (default domainname in case of
e74ba378 398 * addresses without a domainname)
399 * $lookup = callback function (for lookup address
400 * strings which are probably nicks
cfebb724 401 * (without @ ) )
e74ba378 402 * output: array with addressstructure objects or only one
403 * address_structure object.
340d67c2 404 * personal name: encoded: =?charset?Q|B?string?=
405 * quoted: "string"
406 * normal: string
407 * email : <mailbox@host>
408 * : mailbox@host
409 * This function is also used for validating addresses returned from compose
14882b16 410 * That's also the reason that the function became a little bit huge
e74ba378 411 */
340d67c2 412
14882b16 413 function parseAddress($address,$ar=false,$aAddress=array(),$sGroup='',$sHost='',$lookup=false) {
414 $aTokens = $this->getAddressTokens($address);
415 $sPersonal = $sEmail = $sComment = $sGroup = '';
416 $aStack = $aComment = array();
417 foreach ($aTokens as $sToken) {
418 $cChar = $sToken{0};
419 switch ($cChar)
340d67c2 420 {
421 case '=':
14882b16 422 case '"':
423 case ' ':
cfebb724 424 $aStack[] = $sToken;
340d67c2 425 break;
14882b16 426 case '(':
427 $aComment[] = substr($sToken,1,-1);
340d67c2 428 break;
3fcadedb 429 case ';':
14882b16 430 if ($sGroup) {
29f842a4 431 $aAddress[] = $this->createAddressObject($aStack,$aComment,$sEmail,$sGroup);
14882b16 432 $oAddr = end($aAddress);
0b4d4be7 433 if(!$oAddr || ((isset($oAddr)) && !$oAddr->mailbox && !$oAddr->personal)) {
434 $sEmail = $sGroup . ':;';
cfebb724 435 }
0b4d4be7 436 $aAddress[] = $this->createAddressObject($aStack,$aComment,$sEmail,$sGroup);
14882b16 437 $sGroup = '';
438 $aStack = $aComment = array();
439 break;
340d67c2 440 }
14882b16 441 case ',':
442 $aAddress[] = $this->createAddressObject($aStack,$aComment,$sEmail,$sGroup);
443 break;
cfebb724 444 case ':':
29f842a4 445 $sGroup = trim(implode(' ',$aStack));
0b4d4be7 446 $sGroup = preg_replace('/\s+/',' ',$sGroup);
14882b16 447 $aStack = array();
448 break;
449 case '<':
450 $sEmail = trim(substr($sToken,1,-1));
451 break;
452 case '>':
453 /* skip */
cfebb724 454 break;
14882b16 455 default: $aStack[] = $sToken; break;
19d470aa 456 }
457 }
14882b16 458 /* now do the action again for the last address */
459 $aAddress[] = $this->createAddressObject($aStack,$aComment,$sEmail);
460 /* try to lookup the addresses in case of invalid email addresses */
461 $aProcessedAddress = array();
462 foreach ($aAddress as $oAddr) {
463 $aAddrBookAddress = array();
464 if (!$oAddr->host) {
465 $grouplookup = false;
340d67c2 466 if ($lookup) {
14882b16 467 $aAddr = call_user_func_array($lookup,array($oAddr->mailbox));
468 if (isset($aAddr['email'])) {
469 if (strpos($aAddr['email'],',')) {
470 $grouplookup = true;
471 $aAddrBookAddress = $this->parseAddress($aAddr['email'],true);
472 } else {
473 $iPosAt = strpos($aAddr['email'], '@');
474 $oAddr->mailbox = substr($aAddr['email'], 0, $iPosAt);
475 $oAddr->host = substr($aAddr['email'], $iPosAt+1);
476 if (isset($aAddr['name'])) {
477 $oAddr->personal = $aAddr['name'];
478 } else {
479 $oAddr->personal = encodeHeader($sPersonal);
480 }
481 }
482 }
340d67c2 483 }
14882b16 484 if (!$grouplookup && !$oAddr->mailbox) {
485 $oAddr->mailbox = trim($sEmail);
486 if ($sHost && $oAddr->mailbox) {
487 $oAddr->host = $sHost;
340d67c2 488 }
8b53b4ba 489 } else if (!$grouplookup && !$oAddr->host) {
490 if ($sHost && $oAddr->mailbox) {
491 $oAddr->host = $sHost;
492 }
cfebb724 493 }
14882b16 494 }
495 if (!$aAddrBookAddress && $oAddr->mailbox) {
496 $aProcessedAddress[] = $oAddr;
497 } else {
cfebb724 498 $aProcessedAddress = array_merge($aProcessedAddress,$aAddrBookAddress);
14882b16 499 }
340d67c2 500 }
cfebb724 501 if ($ar) {
14882b16 502 return $aProcessedAddress;
19d470aa 503 } else {
14882b16 504 return $aProcessedAddress[0];
19d470aa 505 }
cfebb724 506 }
19d470aa 507
508 function parseContentType($value) {
509 $pos = strpos($value, ';');
510 $props = '';
511 if ($pos > 0) {
512 $type = trim(substr($value, 0, $pos));
38d6fba7 513 $props = trim(substr($value, $pos+1));
19d470aa 514 } else {
515 $type = $value;
516 }
517 $content_type = new ContentType($type);
518 if ($props) {
519 $properties = $this->parseProperties($props);
520 if (!isset($properties['charset'])) {
521 $properties['charset'] = 'us-ascii';
522 }
523 $content_type->properties = $this->parseProperties($props);
524 }
525 $this->content_type = $content_type;
526 }
cfebb724 527
2ddf00ae 528 /* RFC2184 */
cfebb724 529 function processParameters($aParameters) {
2ddf00ae 530 $aResults = array();
cfebb724 531 $aCharset = array();
532 // handle multiline parameters
2ddf00ae 533 foreach($aParameters as $key => $value) {
cfebb724 534 if ($iPos = strpos($key,'*')) {
535 $sKey = substr($key,0,$iPos);
536 if (!isset($aResults[$sKey])) {
537 $aResults[$sKey] = $value;
538 if (substr($key,-1) == '*') { // parameter contains language/charset info
539 $aCharset[] = $sKey;
540 }
541 } else {
542 $aResults[$sKey] .= $value;
543 }
544 } else {
545 $aResults[$key] = $value;
546 }
547 }
548 foreach ($aCharset as $key) {
549 $value = $aResults[$key];
550 // extract the charset & language
551 $charset = substr($value,0,strpos($value,"'"));
552 $value = substr($value,strlen($charset)+1);
553 $language = substr($value,0,strpos($value,"'"));
554 $value = substr($value,strlen($charset)+1);
555 // FIX ME What's the status of charset decode with language information ????
556 $value = charset_decode($charset,$value);
557 $aResults[$key] = $value;
2ddf00ae 558 }
cfebb724 559 return $aResults;
2ddf00ae 560 }
19d470aa 561
562 function parseProperties($value) {
563 $propArray = explode(';', $value);
564 $propResultArray = array();
565 foreach ($propArray as $prop) {
566 $prop = trim($prop);
567 $pos = strpos($prop, '=');
568 if ($pos > 0) {
569 $key = trim(substr($prop, 0, $pos));
570 $val = trim(substr($prop, $pos+1));
bbb92b4c 571 if (strlen($val) > 0 && $val{0} == '"') {
19d470aa 572 $val = substr($val, 1, -1);
573 }
574 $propResultArray[$key] = $val;
575 }
576 }
2ddf00ae 577 return $this->processParameters($propResultArray);
19d470aa 578 }
579
580 function parseDisposition($value) {
581 $pos = strpos($value, ';');
582 $props = '';
583 if ($pos > 0) {
584 $name = trim(substr($value, 0, $pos));
fc9269ec 585 $props = trim(substr($value, $pos+1));
19d470aa 586 } else {
587 $name = $value;
588 }
589 $props_a = $this->parseProperties($props);
590 $disp = new Disposition($name);
591 $disp->properties = $props_a;
592 $this->disposition = $disp;
593 }
594
595 function mlist($field, $value) {
596 $res_a = array();
597 $value_a = explode(',', $value);
598 foreach ($value_a as $val) {
599 $val = trim($val);
600 if ($val{0} == '<') {
601 $val = substr($val, 1, -1);
602 }
603 if (substr($val, 0, 7) == 'mailto:') {
604 $res_a['mailto'] = substr($val, 7);
605 } else {
606 $res_a['href'] = $val;
607 }
608 }
609 $this->mlist[$field] = $res_a;
610 }
611
612 /*
613 * function to get the addres strings out of the header.
614 * Arguments: string or array of strings !
615 * example1: header->getAddr_s('to').
616 * example2: header->getAddr_s(array('to', 'cc', 'bcc'))
617 */
2c9ecd11 618 function getAddr_s($arr, $separator = ',',$encoded=false) {
19d470aa 619 $s = '';
620
621 if (is_array($arr)) {
622 foreach($arr as $arg) {
2c9ecd11 623 if ($this->getAddr_s($arg, $separator, $encoded)) {
19d470aa 624 $s .= $separator . $result;
625 }
626 }
627 $s = ($s ? substr($s, 2) : $s);
628 } else {
2c9ecd11 629 $addr = $this->{$arr};
19d470aa 630 if (is_array($addr)) {
631 foreach ($addr as $addr_o) {
632 if (is_object($addr_o)) {
2c9ecd11 633 if ($encoded) {
634 $s .= $addr_o->getEncodedAddress() . $separator;
635 } else {
636 $s .= $addr_o->getAddress() . $separator;
637 }
19d470aa 638 }
639 }
640 $s = substr($s, 0, -strlen($separator));
641 } else {
642 if (is_object($addr)) {
2c9ecd11 643 if ($encoded) {
644 $s .= $addr->getEncodedAddress();
645 } else {
646 $s .= $addr->getAddress();
647 }
19d470aa 648 }
649 }
650 }
651 return $s;
652 }
653
654 function getAddr_a($arg, $excl_arr = array(), $arr = array()) {
655 if (is_array($arg)) {
656 foreach($arg as $argument) {
657 $arr = $this->getAddr_a($argument, $excl_arr, $arr);
658 }
659 } else {
340d67c2 660 $addr = $this->{$arg};
19d470aa 661 if (is_array($addr)) {
662 foreach ($addr as $next_addr) {
663 if (is_object($next_addr)) {
664 if (isset($next_addr->host) && ($next_addr->host != '')) {
665 $email = $next_addr->mailbox . '@' . $next_addr->host;
666 } else {
667 $email = $next_addr->mailbox;
668 }
669 $email = strtolower($email);
670 if ($email && !isset($arr[$email]) && !isset($excl_arr[$email])) {
671 $arr[$email] = $next_addr->personal;
672 }
673 }
674 }
675 } else {
676 if (is_object($addr)) {
677 $email = $addr->mailbox;
678 $email .= (isset($addr->host) ? '@' . $addr->host : '');
679 $email = strtolower($email);
680 if ($email && !isset($arr[$email]) && !isset($excl_arr[$email])) {
681 $arr[$email] = $addr->personal;
682 }
683 }
684 }
685 }
686 return $arr;
687 }
cfebb724 688
d0719411 689 function findAddress($address, $recurs = false) {
340d67c2 690 $result = false;
d0719411 691 if (is_array($address)) {
340d67c2 692 $i=0;
d0719411 693 foreach($address as $argument) {
694 $match = $this->findAddress($argument, true);
340d67c2 695 $last = end($match);
696 if ($match[1]) {
697 return $i;
698 } else {
699 if (count($match[0]) && !$result) {
700 $result = $i;
701 }
702 }
cfebb724 703 ++$i;
340d67c2 704 }
705 } else {
706 if (!is_array($this->cc)) $this->cc = array();
707 $srch_addr = $this->parseAddress($address);
708 $results = array();
709 foreach ($this->to as $to) {
710 if ($to->host == $srch_addr->host) {
711 if ($to->mailbox == $srch_addr->mailbox) {
712 $results[] = $srch_addr;
713 if ($to->personal == $srch_addr->personal) {
714 if ($recurs) {
715 return array($results, true);
716 } else {
717 return true;
718 }
719 }
720 }
721 }
d0719411 722 }
340d67c2 723 foreach ($this->cc as $cc) {
724 if ($cc->host == $srch_addr->host) {
725 if ($cc->mailbox == $srch_addr->mailbox) {
726 $results[] = $srch_addr;
727 if ($cc->personal == $srch_addr->personal) {
728 if ($recurs) {
729 return array($results, true);
730 } else {
731 return true;
732 }
733 }
734 }
735 }
736 }
737 if ($recurs) {
738 return array($results, false);
739 } elseif (count($result)) {
740 return true;
741 } else {
742 return false;
cfebb724 743 }
340d67c2 744 }
1465f80c 745 //exit;
340d67c2 746 return $result;
d0719411 747 }
19d470aa 748
749 function getContentType($type0, $type1) {
750 $type0 = $this->content_type->type0;
751 $type1 = $this->content_type->type1;
752 return $this->content_type->properties;
753 }
754}
755
bbb92b4c 756?>