src/includes/classes/Core/Utils/Email.php
protected function parseHeaders($value, array $refs = [], bool $strict = false): array
    {
        $headers = []; // Initialize parsed headers.

        foreach ($this->c::parseHeaders($value) as $_header => $_value) {
            switch ($_header) { // Maybe populate refs.

                case 'from':
                    if (array_key_exists('from_name', $refs) && array_key_exists('from_email', $refs)) {
                        if (($_from_addresses = $this->parseAddresses($_value, $strict))) {
                            $_from              = array_shift($_from_addresses);
                            $refs['from_name']  = $this->c::mbTrim($_from->fname.' '.$_from->lname);
                            $refs['from_email'] = $_from->email; // By reference.
                        } // unset($_from_addresses, $_from);
                    } else {
                        $headers[$_header] = $_value;
                    }
                    break; // Break switch.

                case 'reply-to':
                    if (array_key_exists('reply_to_name', $refs) && array_key_exists('reply_to_email', $refs)) {
                        if (($_reply_to_addresses = $this->parseAddresses($_value, $strict))) {
                            $_reply_to              = array_shift($_reply_to_addresses);
                            $refs['reply_to_name']  = $this->c::mbTrim($_reply_to->fname.' '.$_reply_to->lname);
                            $refs['reply_to_email'] = $_reply_to->email; // By reference.
                        } // unset($_reply_to_addresses, $_reply_to);
                    } else {
                        $headers[$_header] = $_value;
                    }
                    break; // Break switch.

                case 'cc':
                case 'bcc':
                    if (array_key_exists('recipients', $refs)) {
                        if (($_recipient_addresses = $this->parseAddresses($_value, $strict))) {
                            $refs['recipients'] = array_merge($refs['recipients'], $_recipient_addresses);
                            $refs['recipients'] = array_unique($refs['recipients']);
                        } // unset($_recipient_addresses);
                    } else {
                        $headers[$_header] = $_value;
                    }
                    break; // Break switch.

                default: // Everything else (default).
                    $headers[$_header] = $_value;
                    break; // Break switch.
            }
        }
        return $headers;
    }
protected function parseHeaders($value, array $refs = [], bool $strict = false): array
    {
        $headers = []; // Initialize parsed headers.

        foreach ($this->c::parseHeaders($value) as $_header => $_value) {
            switch ($_header) { // Maybe populate refs.

                case 'from':
                    if (array_key_exists('from_name', $refs) && array_key_exists('from_email', $refs)) {
                        if (($_from_addresses = $this->parseAddresses($_value, $strict))) {
                            $_from              = array_shift($_from_addresses);
                            $refs['from_name']  = $this->c::mbTrim($_from->fname.' '.$_from->lname);
                            $refs['from_email'] = $_from->email; // By reference.
                        } // unset($_from_addresses, $_from);
                    } else {
                        $headers[$_header] = $_value;
                    }
                    break; // Break switch.

                case 'reply-to':
                    if (array_key_exists('reply_to_name', $refs) && array_key_exists('reply_to_email', $refs)) {
                        if (($_reply_to_addresses = $this->parseAddresses($_value, $strict))) {
                            $_reply_to              = array_shift($_reply_to_addresses);
                            $refs['reply_to_name']  = $this->c::mbTrim($_reply_to->fname.' '.$_reply_to->lname);
                            $refs['reply_to_email'] = $_reply_to->email; // By reference.
                        } // unset($_reply_to_addresses, $_reply_to);
                    } else {
                        $headers[$_header] = $_value;
                    }
                    break; // Break switch.

                case 'cc':
                case 'bcc':
                    if (array_key_exists('recipients', $refs)) {
                        if (($_recipient_addresses = $this->parseAddresses($_value, $strict))) {
                            $refs['recipients'] = array_merge($refs['recipients'], $_recipient_addresses);
                            $refs['recipients'] = array_unique($refs['recipients']);
                        } // unset($_recipient_addresses);
                    } else {
                        $headers[$_header] = $_value;
                    }
                    break; // Break switch.

                default: // Everything else (default).
                    $headers[$_header] = $_value;
                    break; // Break switch.
            }
        }
        return $headers;
    }
Parse headers.

@since 151121 Email utilities.

@param mixed $value  Any input value w/ headers.
@param array $refs   An input array of references to fill; for special headers.
@param bool  $strict Optional. Defaults to `false` (faster). Parses all strings w/ `@` signs.
If `true`, validate each address, and only return 100% valid email addresses.

@return array Unique/associative array of all parsed headers.