2 namespace TYPO3\CMS\Core\Mail;
180 $this->structure = array();
181 $this->addresses = array();
185 $this->address = preg_replace(
'/\\r?\\n/',
'
187 $this->address = preg_replace(
'/\\r\\n(\\t| )+/',
' ', $this->address);
190 if ($this->address ===
false || isset($this->error)) {
191 throw new \InvalidArgumentException($this->error, 1294681466);
195 foreach ($this->addresses as
$address) {
197 if ($valid ===
false || isset($this->error)) {
198 throw new \InvalidArgumentException($this->error, 1294681467);
200 $this->structure = array_merge($this->structure, $valid);
214 if (!empty($this->limit) && count($this->addresses) == $this->limit) {
220 }
elseif (!isset($this->error)) {
223 }
elseif (isset($this->error)) {
227 $parts = explode($split_char,
$address);
234 if (strpos($string,
':') ===
false) {
235 $this->error =
'Invalid address: ' . $string;
239 if (!$this->
_splitCheck(explode(
':', $string),
':')) {
247 $this->addresses[] = array(
248 'address' => trim($string),
257 if ($is_group &&
$address[0] ===
',') {
282 if (count(($parts = explode(
':', $string))) > 1) {
284 return $string2 !== $string;
301 $partsCounter = count($parts);
302 for ($i = 0; $i < $partsCounter; $i++) {
304 if (isset($parts[$i + 1])) {
305 $string = $string . $char . $parts[($i + 1)];
307 $this->error =
'Invalid address spec. Unclosed bracket or quotes';
327 $string = trim($string);
328 $iMax = strlen($string);
331 for (; $i < $iMax; ++$i) {
332 switch ($string[$i]) {
337 if ($slashes % 2 == 0) {
338 $in_quote = !$in_quote;
358 $num_angle_start = substr_count($string, $chars[0]);
359 $num_angle_end = substr_count($string, $chars[1]);
362 if ($num_angle_start < $num_angle_end) {
363 $this->error =
'Invalid address spec. Unmatched quote or bracket (' . $chars .
')';
366 return $num_angle_start > $num_angle_end;
381 $parts = explode($char, $string);
382 $partsCounter = count($parts);
383 for ($i = 0; $i < $partsCounter; $i++) {
387 if (isset($parts[$i + 1])) {
388 $parts[$i + 1] = $parts[$i] . $char . $parts[($i + 1)];
408 $parts = explode(
':',
$address[
'address']);
413 $this->error =
'Group name did not validate.';
416 $address[
'address'] = ltrim(substr(
$address[
'address'], strlen($groupname .
':')));
421 while (
$address[
'address'] !==
'') {
422 $parts = explode(
',',
$address[
'address']);
433 $this->error =
'Empty group.';
444 for ($i = 0; $i < $addressesCount; $i++) {
446 if (empty($this->error)) {
447 $this->error =
'Validation failed for: ' .
$addresses[$i];
470 $parts = preg_split(
'/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY);
471 $phrase_parts = array();
472 while (!empty($parts)) {
474 for ($i = 0; $i < $this->index + 1; $i++) {
478 foreach ($phrase_parts as $part) {
480 if ($part[0] ===
'"') {
509 if (!$this->validate) {
514 if (!preg_match(
'/^[\\x00-\\x7E]+$/i', $atom, $matches)) {
518 if (preg_match(
'/[][()<>@,;\\:". ]/', $atom)) {
522 if (preg_match(
'/[\\x00-\\x1F]+/', $atom)) {
539 $qstring = substr($qstring, 1, -1);
541 return !preg_match(
'/[\\x0D\\\\"]/', preg_replace(
'/\\\\./',
'', $qstring));
560 $_mailbox = $mailbox;
561 while (trim($_mailbox) !==
'') {
562 $parts = explode(
'(', $_mailbox);
564 if ($before_comment != $_mailbox) {
566 $comment = substr(str_replace($before_comment,
'', $_mailbox), 1);
567 $parts = explode(
')', $comment);
569 $comments[] = $comment;
571 $_mailbox = substr($_mailbox, strpos($_mailbox, (
'(' . $comment)) + strlen($comment) + 2);
576 foreach ($comments as $comment) {
577 $mailbox = str_replace(
'(' . $comment .
')',
'', $mailbox);
579 $mailbox = trim($mailbox);
581 if (substr($mailbox, -1) ===
'>' && $mailbox[0] !==
'<') {
582 $parts = explode(
'<', $mailbox);
584 $phrase = trim($name);
585 $route_addr = trim(substr($mailbox, strlen($name .
'<'), -1));
591 if ($mailbox[0] ===
'<' && substr($mailbox, -1) ===
'>') {
592 $addr_spec = substr($mailbox, 1, -1);
594 $addr_spec = $mailbox;
601 $mbox = new \stdClass();
603 $mbox->personal = $phrase;
604 $mbox->comment = isset($comments) ? $comments : array();
605 if (isset($route_addr)) {
606 $mbox->mailbox = $route_addr[
'local_part'];
607 $mbox->host = $route_addr[
'domain'];
608 $route_addr[
'adl'] !==
'' ? ($mbox->adl = $route_addr[
'adl']) :
'';
610 $mbox->mailbox = $addr_spec[
'local_part'];
611 $mbox->host = $addr_spec[
'domain'];
631 if (strpos($route_addr,
':') !==
false) {
632 $parts = explode(
':', $route_addr);
635 $route = $route_addr;
639 if ($route === $route_addr) {
641 $addr_spec = $route_addr;
650 $addr_spec = substr($route_addr, strlen($route .
':'));
657 $return[
'adl'] = $route;
661 $return = array_merge($return, $addr_spec);
676 $domains = explode(
',', trim($route));
677 foreach ($domains as $domain) {
678 $domain = str_replace(
'@',
'', trim($domain));
699 $subdomains = explode(
'.', $domain);
700 while (!empty($subdomains)) {
701 $sub_domains[] = $this->
_splitCheck($subdomains,
'.');
702 for ($i = 0; $i < $this->index + 1; $i++) {
703 array_shift($subdomains);
706 foreach ($sub_domains as $sub_domain) {
725 if (preg_match(
'|^\\[(.*)]$|', $subdomain, $arr)) {
748 return !preg_match(
'/(.)[][\\x0D\\\\]/', $dliteral, $matches) && $matches[1] !=
'\\';
762 $addr_spec = trim($addr_spec);
764 if (strpos($addr_spec,
'@') !==
false) {
765 $parts = explode(
'@', $addr_spec);
767 $domain = substr($addr_spec, strlen($local_part .
'@'));
769 $local_part = $addr_spec;
779 return array(
'local_part' => $local_part,
'domain' => $domain);
792 $parts = explode(
'.', $local_part);
795 while (!empty($parts)) {
797 for ($i = 0; $i < $this->index + 1; $i++) {
802 foreach ($words as $word) {
804 if (strpos($word,
' ') && $word[0] !==
'"') {