ILIAS  trunk Revision v11.0_alpha-1731-gff9cd7e2bd3
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
RFC822.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
75 {
80  public string $address = '';
81 
86  public string $default_domain = 'localhost';
87 
92  public bool $nestGroups = true;
93 
98  public bool $validate = true;
99 
104  public array $addresses = [];
105 
110  public array $structure = [];
111 
116  public ?string $error = null;
117 
122  public ?int $index = null;
123 
129  public int $num_groups = 0;
130 
136  public bool $mailRFC822 = true;
137 
142  public ?int $limit = null;
143 
154  public function __construct(
155  ?string $address = null,
156  ?string $default_domain = null,
157  ?bool $nest_groups = null,
158  ?bool $validate = null,
159  ?int $limit = null
160  ) {
161  if (isset($address)) {
162  $this->address = $address;
163  }
164  if (isset($default_domain)) {
165  $this->default_domain = $default_domain;
166  }
167  if (isset($nest_groups)) {
168  $this->nestGroups = $nest_groups;
169  }
170  if (isset($validate)) {
171  $this->validate = $validate;
172  }
173  if (isset($limit)) {
174  $this->limit = $limit;
175  }
176  }
177 
189  public function parseAddressList(
190  ?string $address = null,
191  ?string $default_domain = null,
192  ?bool $nest_groups = null,
193  ?bool $validate = null,
194  ?int $limit = null
195  ): array {
196  if (!isset($this, $this->mailRFC822)) {
197  $obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
198  return $obj->parseAddressList();
199  }
200 
201  if (isset($address)) {
202  $this->address = $address;
203  }
204  if (isset($default_domain)) {
205  $this->default_domain = $default_domain;
206  }
207  if (isset($nest_groups)) {
208  $this->nestGroups = $nest_groups;
209  }
210  if (isset($validate)) {
211  $this->validate = $validate;
212  }
213  if (isset($limit)) {
214  $this->limit = $limit;
215  }
216 
217  $this->structure = [];
218  $this->addresses = [];
219  $this->error = null;
220  $this->index = null;
221 
222  // Unfold any long lines in $this->address.
223  $this->address = preg_replace('/\r?\n/', "\r\n", $this->address);
224  $this->address = preg_replace('/\r\n(\t| )+/', ' ', $this->address);
225 
226  $tmp_address = false;
227  while ($tmp_address = $this->_splitAddresses($this->address)) {
228  $this->address = $tmp_address;
229  }
230 
231  if ($tmp_address === false || isset($this->error)) {
232  // mjansen patch 14 Ap 2016 start
233  throw new ilMailException($this->error);
234  // mjansen patch 14 Ap 2016 end
235  }
236 
237  // Validate each address individually. If we encounter an invalid
238  // address, stop iterating and return an error immediately.
239  foreach ($this->addresses as $address) {
240  $valid = $this->_validateAddress($address);
241 
242  if ($valid === false || isset($this->error)) {
243  // mjansen patch 14 Ap 2016 start
244  throw new ilMailException($this->error);
245  // mjansen patch 14 Ap 2016 end
246  }
247 
248  if (!$this->nestGroups) {
249  $this->structure = array_merge($this->structure, $valid);
250  } else {
251  $this->structure[] = $valid;
252  }
253  }
254 
255  return $this->structure;
256  }
257 
264  protected function _splitAddresses(string $address)
265  {
266  if (!empty($this->limit) && count($this->addresses) === $this->limit) {
267  return false;
268  }
269 
270  if (!isset($this->error) && $this->_isGroup($address)) {
271  $split_char = ';';
272  $is_group = true;
273  } elseif (!isset($this->error)) {
274  $split_char = ',';
275  $is_group = false;
276  } elseif (isset($this->error)) {
277  return false;
278  }
279 
280  // Split the string based on the above ten or so lines.
281  $parts = explode($split_char, $address);
282  $string = $this->_splitCheck($parts, $split_char);
283 
284  // If a group...
285  if ($is_group) {
286  // If $string does not contain a colon outside of
287  // brackets/quotes etc then something's fubar.
288 
289  // First check there's a colon at all:
290  if (strpos($string, ':') === false) {
291  $this->error = 'Invalid address: ' . $string;
292  return false;
293  }
294 
295  // Now check it's outside of brackets/quotes:
296  if (!$this->_splitCheck(explode(':', $string), ':')) {
297  return false;
298  }
299 
300  // We must have a group at this point, so increase the counter:
301  $this->num_groups++;
302  }
303 
304  // $string now contains the first full address/group.
305  // Add to the addresses array.
306  $this->addresses[] = [
307  'address' => trim($string),
308  'group' => $is_group,
309  ];
310 
311  // Remove the now stored address from the initial line, the +1
312  // is to account for the explode character.
313  $address = trim((string) substr($address, strlen($string) + 1));
314 
315  // If the next char is a comma and this was a group, then
316  // there are more addresses, otherwise, if there are any more
317  // chars, then there is another address.
318  if ($is_group && $address[0] === ',') {
319  $address = trim(substr($address, 1));
320  return $address;
321  }
322 
323  return $address;
324  }
325 
332  protected function _isGroup(string $address): bool
333  {
334  // First comma not in quotes, angles or escaped:
335  $parts = explode(',', $address);
336  $string = $this->_splitCheck($parts, ',');
337 
338  // Now we have the first address, we can reliably check for a
339  // group by searching for a colon that's not escaped or in
340  // quotes or angle brackets.
341  if (count($parts = explode(':', $string)) > 1) {
342  $string2 = $this->_splitCheck($parts, ':');
343  return ($string2 !== $string);
344  }
345 
346  return false;
347  }
348 
356  protected function _splitCheck(array $parts, string $char): string
357  {
358  $string = $parts[0];
359 
360  for ($i = 0, $iMax = count($parts); $i < $iMax; $i++) {
361  if ($this->_hasUnclosedQuotes($string)
362  || $this->_hasUnclosedBrackets($string, '<>')
363  || $this->_hasUnclosedBrackets($string, '[]')
364  || $this->_hasUnclosedBrackets($string, '()')
365  || substr($string, -1) === '\\') {
366  if (isset($parts[$i + 1])) {
367  $string .= $char . $parts[$i + 1];
368  } else {
369  $this->error = 'Invalid address spec. Unclosed bracket or quotes';
370  return '';
371  }
372  } else {
373  $this->index = $i;
374  break;
375  }
376  }
377 
378  return $string;
379  }
380 
387  protected function _hasUnclosedQuotes(string $string): bool
388  {
389  $string = trim($string);
390  $iMax = strlen($string);
391  $in_quote = false;
392  $i = $slashes = 0;
393 
394  for (; $i < $iMax; ++$i) {
395  switch ($string[$i]) {
396  case '\\':
397  ++$slashes;
398  break;
399 
400  case '"':
401  if ($slashes % 2 === 0) {
402  $in_quote = !$in_quote;
403  }
404  // Fall through to default action below.
405 
406  // no break
407  default:
408  $slashes = 0;
409  break;
410  }
411  }
412 
413  return $in_quote;
414  }
415 
424  protected function _hasUnclosedBrackets(string $string, string $chars): bool
425  {
426  $num_angle_start = substr_count($string, $chars[0]);
427  $num_angle_end = substr_count($string, $chars[1]);
428 
429  $this->_hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]);
430  $this->_hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]);
431 
432  if ($num_angle_start < $num_angle_end) {
433  $this->error = 'Invalid address spec. Unmatched quote or bracket (' . $chars . ')';
434  return false;
435  }
436 
437  return ($num_angle_start > $num_angle_end);
438  }
439 
448  protected function _hasUnclosedBracketsSub(string $string, int &$num, string $char): int
449  {
450  $parts = explode($char, $string);
451  for ($i = 0, $iMax = count($parts); $i < $iMax; $i++) {
452  if (substr($parts[$i], -1) === '\\' || $this->_hasUnclosedQuotes($parts[$i])) {
453  $num--;
454  }
455  if (isset($parts[$i + 1])) {
456  $parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1];
457  }
458  }
459 
460  return $num;
461  }
462 
469  protected function _validateAddress(array $address)
470  {
471  $is_group = false;
472  $addresses = [];
473 
474  if ($address['group']) {
475  $is_group = true;
476 
477  // Get the group part of the name
478  $parts = explode(':', $address['address']);
479  $groupname = $this->_splitCheck($parts, ':');
480  $structure = [];
481 
482  // And validate the group part of the name.
483  if (!$this->_validatePhrase($groupname)) {
484  $this->error = 'Group name did not validate.';
485  return false;
486  }
487 
488  if ($this->nestGroups) {
489  // Don't include groups if we are not nesting
490  // them. This avoids returning invalid addresses.
491  $structure = new stdClass();
492  $structure->groupname = $groupname;
493  }
494 
495  $address['address'] = ltrim(substr($address['address'], strlen($groupname . ':')));
496  }
497 
498  // If a group then split on comma and put into an array.
499  // Otherwise, Just put the whole address in an array.
500  if ($is_group) {
501  while (strlen($address['address']) > 0) {
502  $parts = explode(',', $address['address']);
503  $addresses[] = $this->_splitCheck($parts, ',');
504  $address['address'] = trim(substr($address['address'], strlen(end($addresses) . ',')));
505  }
506  } else {
507  $addresses[] = $address['address'];
508  }
509 
510  // Trim the whitespace from all of the address strings.
511  array_map('trim', $addresses);
512 
513  // Validate each mailbox.
514  // Format could be one of: name <geezer@domain.com>
515  // geezer@domain.com
516  // geezer
517  // ... or any other format valid by RFC 822.
518  for ($i = 0, $iMax = count($addresses); $i < $iMax; $i++) {
519  if (!$this->validateMailbox($addresses[$i])) {
520  if (empty($this->error)) {
521  $this->error = 'Validation failed for: ' . $addresses[$i];
522  }
523  return false;
524  }
525  }
526 
527  // Nested format
528  if ($this->nestGroups) {
529  if ($is_group) {
530  $structure->addresses = $addresses;
531  } else {
532  $structure = $addresses[0];
533  }
534 
535  // Flat format
536  } elseif ($is_group) {
537  $structure = array_merge($structure, $addresses);
538  } else {
539  $structure = $addresses;
540  }
541 
542  return $structure;
543  }
544 
551  protected function _validatePhrase(string $phrase): bool
552  {
553  // Splits on one or more Tab or space.
554  $parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY);
555 
556  $phrase_parts = [];
557  while (count($parts) > 0) {
558  $phrase_parts[] = $this->_splitCheck($parts, ' ');
559  for ($i = 0; $i < $this->index + 1; $i++) {
560  array_shift($parts);
561  }
562  }
563 
564  foreach ($phrase_parts as $part) {
565  // If quoted string:
566  if (strpos($part, '"') === 0) {
567  if (!$this->_validateQuotedString($part)) {
568  return false;
569  }
570  continue;
571  }
572 
573  // Otherwise it's an atom:
574  if (!$this->_validateAtom($part)) {
575  return false;
576  }
577  }
578 
579  return true;
580  }
581 
594  protected function _validateAtom(string $atom): bool
595  {
596  if (!$this->validate) {
597  // Validation has been turned off; assume the atom is okay.
598  return true;
599  }
600 
601  // Check for any char from ASCII 0 - ASCII 127
602  // mjansen patch 16 Sep 2015 start
603  // Check for specials:
604  if (preg_match('/[][()<>@,;\\:". ]/', $atom)) {
605  return false;
606  }
607 
608  // Check for control characters (ASCII 0-31):
609  if (preg_match('/[\\x00-\\x1F]+/', $atom)) {
610  return false;
611  }
612  #16291
613  #17618
614  if (!(bool) preg_match('//u', $atom)) {
615  return false;
616  }
617  // mjansen patch 16 Sep 2015 end
618 
619  return true;
620  }
621 
629  protected function _validateQuotedString(string $qstring): bool
630  {
631  // Leading and trailing "
632  $qstring = substr($qstring, 1, -1);
633 
634  // Perform check, removing quoted characters first.
635  return !preg_match('/[\x0D\\\\"]/', preg_replace('/\\\\./', '', $qstring));
636  }
637 
646  public function validateMailbox(string &$mailbox): bool
647  {
648  // A couple of defaults.
649  $phrase = '';
650  $comment = '';
651  $comments = [];
652 
653  // Catch any RFC822 comments and store them separately.
654  $_mailbox = $mailbox;
655  while (trim($_mailbox) !== '') {
656  $parts = explode('(', $_mailbox);
657  $before_comment = $this->_splitCheck($parts, '(');
658  if ($before_comment !== $_mailbox) {
659  // First char should be a (.
660  $comment = substr(str_replace($before_comment, '', $_mailbox), 1);
661  $parts = explode(')', $comment);
662  $comment = $this->_splitCheck($parts, ')');
663  $comments[] = $comment;
664 
665  // +2 is for the brackets
666  $_mailbox = substr($_mailbox, strpos($_mailbox, '(' . $comment) + strlen($comment) + 2);
667  } else {
668  break;
669  }
670  }
671 
672  foreach ($comments as $comment) {
673  $mailbox = str_replace("($comment)", '', $mailbox);
674  }
675 
676  $mailbox = trim($mailbox);
677 
678  // Check for name + route-addr
679  if (substr($mailbox, -1) === '>' && $mailbox[0] !== '<') {
680  $parts = explode('<', $mailbox);
681  $name = $this->_splitCheck($parts, '<');
682 
683  $phrase = trim($name);
684  $route_addr = trim(substr($mailbox, strlen($name . '<'), -1));
685 
686  if ($this->_validatePhrase($phrase) === false ||
687  ($route_addr = $this->_validateRouteAddr($route_addr)) === false) {
688  return false;
689  }
690 
691  // Only got addr-spec
692  } else {
693  // First snip angle brackets if present.
694  if ($mailbox[0] === '<' && substr($mailbox, -1) === '>') {
695  $addr_spec = substr($mailbox, 1, -1);
696  } else {
697  $addr_spec = $mailbox;
698  }
699 
700  if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
701  return false;
702  }
703  }
704 
705  // Construct the object that will be returned.
706  $mbox = new stdClass();
707 
708  // Add the phrase (even if empty) and comments
709  $mbox->personal = $phrase;
710  $mbox->comment = $comments ?? [];
711 
712  if (isset($route_addr)) {
713  $mbox->mailbox = $route_addr['local_part'];
714  $mbox->host = $route_addr['domain'];
715  if ($route_addr['adl'] !== '') {
716  $mbox->adl = $route_addr['adl'];
717  }
718  } else {
719  $mbox->mailbox = $addr_spec['local_part'];
720  $mbox->host = $addr_spec['domain'];
721  }
722 
723  $mailbox = $mbox;
724  return true;
725  }
726 
737  protected function _validateRouteAddr(string $route_addr)
738  {
739  // Check for colon.
740  if (strpos($route_addr, ':') !== false) {
741  $parts = explode(':', $route_addr);
742  $route = $this->_splitCheck($parts, ':');
743  } else {
744  $route = $route_addr;
745  }
746 
747  // If $route is same as $route_addr then the colon was in
748  // quotes or brackets or, of course, non existent.
749  if ($route === $route_addr) {
750  unset($route);
751  $addr_spec = $route_addr;
752  if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
753  return false;
754  }
755  } else {
756  // Validate route part.
757  if (($route = $this->_validateRoute($route)) === false) {
758  return false;
759  }
760 
761  $addr_spec = substr($route_addr, strlen($route . ':'));
762 
763  // Validate addr-spec part.
764  if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
765  return false;
766  }
767  }
768 
769  if (isset($route)) {
770  $return['adl'] = $route;
771  } else {
772  $return['adl'] = '';
773  }
774 
775  $return = array_merge($return, $addr_spec);
776  return $return;
777  }
778 
786  protected function _validateRoute(string $route)
787  {
788  // Split on comma.
789  $domains = explode(',', trim($route));
790 
791  foreach ($domains as $domain) {
792  $domain = str_replace('@', '', trim($domain));
793  if (!$this->_validateDomain($domain)) {
794  return false;
795  }
796  }
797 
798  return $route;
799  }
800 
810  protected function _validateDomain(string $domain)
811  {
812  // Note the different use of $subdomains and $sub_domains
813  $subdomains = explode('.', $domain);
814 
815  $sub_domains = [];
816  while (count($subdomains) > 0) {
817  $sub_domains[] = $this->_splitCheck($subdomains, '.');
818  for ($i = 0; $i < $this->index + 1; $i++) {
819  array_shift($subdomains);
820  }
821  }
822 
823  foreach ($sub_domains as $sub_domain) {
824  if (!$this->_validateSubdomain(trim($sub_domain))) {
825  return false;
826  }
827  }
828 
829  // Managed to get here, so return input.
830  return $domain;
831  }
832 
840  protected function _validateSubdomain(string $subdomain): bool
841  {
842  if (preg_match('|^\[(.*)]$|', $subdomain, $arr)) {
843  if (!$this->_validateDliteral($arr[1])) {
844  return false;
845  }
846  } elseif (!$this->_validateAtom($subdomain)) {
847  return false;
848  }
849 
850  // Got here, so return successful.
851  return true;
852  }
853 
861  protected function _validateDliteral(string $dliteral): bool
862  {
863  return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) &&
864  ((!isset($matches[1])) || $matches[1] != '\\');
865  }
866 
875  protected function _validateAddrSpec(string $addr_spec)
876  {
877  $addr_spec = trim($addr_spec);
878 
879  // mjansen patch 16 Sep 2016 start
880  $validateState = $this->validate;
881  // mjansen patch 16 Sep 2016 end
882  // Split on @ sign if there is one.
883  if (strpos($addr_spec, '@') !== false) {
884  $parts = explode('@', $addr_spec);
885  $local_part = $this->_splitCheck($parts, '@');
886  $domain = substr($addr_spec, strlen($local_part . '@'));
887  // mjansen patch 16 Sep 2016 start
888  if (substr_count($addr_spec, '@') !== 1 && $local_part === '') {
889  $this->validate = false;
890  $local_part = $addr_spec;
891  $domain = $this->default_domain;
892  }
893  // mjansen patch 16 Sep 2016 end
894  // No @ sign so assume the default domain.
895  } else {
896  $local_part = $addr_spec;
897  $domain = $this->default_domain;
898  }
899 
900  if (($local_part = $this->_validateLocalPart($local_part)) === false) {
901  return false;
902  }
903  // mjansen patch 16 Sep 2016 start
904  if ($validateState !== $this->validate) {
905  $this->validate = $validateState;
906  }
907  // mjansen patch 16 Sep 2016 end
908  if (($domain = $this->_validateDomain($domain)) === false) {
909  return false;
910  }
911 
912  // Got here so return successful.
913  return ['local_part' => $local_part, 'domain' => $domain];
914  }
915 
924  protected function _validateLocalPart(string $local_part)
925  {
926  $parts = explode('.', $local_part);
927  $words = [];
928 
929  // Split the local_part into words.
930  while (count($parts) > 0) {
931  $words[] = $this->_splitCheck($parts, '.');
932  for ($i = 0; $i < $this->index + 1; $i++) {
933  array_shift($parts);
934  }
935  }
936 
937  // Validate each word.
938  foreach ($words as $word) {
939  // iszmais patch 19 May 2020 start
940  // word cannot be empty (#17317)
941  //if ($word === '') {
942  // return false;
943  //}
944  // iszmais patch 19 May 2020 end
945  // If this word contains an unquoted space, it is invalid. (6.2.4)
946  if (strpos($word, ' ') && $word[0] !== '"') {
947  // mjansen patch 24 Feb 2016 start
948  // Mantis issue #18018
949  // # http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx/
950  //return false;
951  // mjansen patch 24 Feb 2016 end
952  }
953 
954  if ($this->_validatePhrase(trim($word)) === false) {
955  return false;
956  }
957  }
958 
959  // Managed to get here, so return the input.
960  return $local_part;
961  }
962 
973  public function approximateCount(string $data): int
974  {
975  return count(preg_split('/(?<!\\\\),/', $data));
976  }
977 
991  public function isValidInetAddress(string $data, bool $strict = false)
992  {
993  $regex =
994  $strict ?
995  '/^([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i' :
996  '/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i';
997  if (preg_match($regex, trim($data), $matches)) {
998  return [$matches[1], $matches[2]];
999  }
1000 
1001  return false;
1002  }
1003 }
_validateQuotedString(string $qstring)
Function to validate quoted string, which is: quoted-string = <"> *(qtext/quoted-pair) <"> ...
Definition: RFC822.php:629
_validateAddrSpec(string $addr_spec)
Function to validate an addr-spec.
Definition: RFC822.php:875
int $num_groups
The number of groups that have been found in the address list.
Definition: RFC822.php:129
_isGroup(string $address)
Checks for a group at the start of the string.
Definition: RFC822.php:332
bool $nestGroups
Should we return a nested array showing groups, or flatten everything?
Definition: RFC822.php:92
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
_hasUnclosedBrackets(string $string, string $chars)
Checks if a string has an unclosed brackets or not.
Definition: RFC822.php:424
_validateLocalPart(string $local_part)
Function to validate the local part of an address: local-part = word *("." word)
Definition: RFC822.php:924
_validateAddress(array $address)
Function to begin checking the address.
Definition: RFC822.php:469
$valid
string $default_domain
The default domain to use for unqualified addresses.
Definition: RFC822.php:86
_validateDomain(string $domain)
Function to validate a domain, though this is not quite what you expect of a strict internet domain...
Definition: RFC822.php:810
_hasUnclosedQuotes(string $string)
Checks if a string has unclosed quotes or not.
Definition: RFC822.php:387
_validateRoute(string $route)
Function to validate a route, which is: route = 1#("@" domain) ":".
Definition: RFC822.php:786
__construct(?string $address=null, ?string $default_domain=null, ?bool $nest_groups=null, ?bool $validate=null, ?int $limit=null)
Sets up the object.
Definition: RFC822.php:154
bool $validate
Whether or not to validate atoms for non-ascii characters.
Definition: RFC822.php:98
_validateAtom(string $atom)
Function to validate an atom which from rfc822 is: atom = 1*<any CHAR except specials, SPACE and CTLs>
Definition: RFC822.php:594
_validateRouteAddr(string $route_addr)
This function validates a route-addr which is: route-addr = "<" [route] addr-spec ">"...
Definition: RFC822.php:737
array $structure
The final array of parsed address information that we build up.
Definition: RFC822.php:110
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
isValidInetAddress(string $data, bool $strict=false)
This is a email validating function separate to the rest of the class.
Definition: RFC822.php:991
_validateSubdomain(string $subdomain)
Function to validate a subdomain: subdomain = domain-ref / domain-literal.
Definition: RFC822.php:840
_hasUnclosedBracketsSub(string $string, int &$num, string $char)
Sub function that is used only by hasUnclosedBrackets().
Definition: RFC822.php:448
bool $mailRFC822
A variable so that we can tell whether or not we&#39;re inside a Mail_RFC822 object.
Definition: RFC822.php:136
int $limit
A limit after which processing stops.
Definition: RFC822.php:142
string $error
The current error message, if any.
Definition: RFC822.php:116
$comments
approximateCount(string $data)
Returns an approximate count of how many addresses are in the given string.
Definition: RFC822.php:973
$comment
Definition: buildRTE.php:72
parseAddressList(?string $address=null, ?string $default_domain=null, ?bool $nest_groups=null, ?bool $validate=null, ?int $limit=null)
Starts the whole process.
Definition: RFC822.php:189
validateMailbox(string &$mailbox)
Function to validate a mailbox, which is: mailbox = addr-spec ; simple address / phrase route-addr ; ...
Definition: RFC822.php:646
_splitCheck(array $parts, string $char)
A common function that will check an exploded string.
Definition: RFC822.php:356
string $address
The address being parsed by the RFC822 object.
Definition: RFC822.php:80
_validateDliteral(string $dliteral)
Function to validate a domain literal: domain-literal = "[" *(dtext / quoted-pair) "]"...
Definition: RFC822.php:861
_splitAddresses(string $address)
Splits an address into separate addresses.
Definition: RFC822.php:264
array $addresses
The array of raw addresses built up as we parse.
Definition: RFC822.php:104
_validatePhrase(string $phrase)
Function to validate a phrase.
Definition: RFC822.php:551
int $index
An internal counter/pointer.
Definition: RFC822.php:122