src/includes/classes/Core/Utils/Email.php
public function parseAddresses($value, bool $strict = false): array
    {
        $addresses = []; // Initialize.

        if (is_array($value) || is_object($value)) {
            foreach ($value as $_key => $_value) {
                $addresses = array_merge($addresses, $this->parseAddresses($_value, $strict));
            } // unset($_key, $_value); // Housekeeping.
            return $addresses;
        }
        $string                      = (string) $value;
        $delimiter                   = mb_strpos($string, ';') !== false ? ';' : ',';
        $regex_delimitation_splitter = '/'.$delimiter.'+/u'; // `$this->c::escRegex()` unnecessary.

        $possible_addresses = preg_split($regex_delimitation_splitter, $string, -1, PREG_SPLIT_NO_EMPTY);
        $possible_addresses = $this->c::mbTrim($possible_addresses);

        foreach ($possible_addresses as $_address) {
            if (!$_address || mb_strpos($_address, '@', 1) === false) {
                continue; // NOT an email address.
            }
            if (mb_strpos($_address, '<') !== false && preg_match('/(?:"(?<name>[^"]+?)"\s*)?\<(?<email>.+?)\>/u', $_address, $_m)) {
                if ($_m['email'] && mb_strpos($_m['email'], '@', 1) !== false && (!$strict || $this->isValid($_m['email']))) {
                    $_email             = mb_strtolower($_m['email']);
                    $_name              = !empty($_m['name']) ? $_m['name'] : '';
                    $_fname             = $_name ? $this->c::fnameIn($_name) : '';
                    $_lname             = $_name ? $this->c::lnameIn($_name) : '';
                    $addresses[$_email] = (object) ['name' => $_name, 'fname' => $_fname, 'lname' => $_lname, 'email' => $_email];
                }
            } elseif (!$strict || $this->isValid($_address)) {
                $_email             = mb_strtolower($_address);
                $addresses[$_email] = (object) ['name' => '', 'fname' => '', 'lname' => '', 'email' => $_email];
            }
        } // unset($_address, $_m, $_email, $_name, $_fname, $_lname); // Housekeeping.

        return $addresses;
    }
public function parseAddresses($value, bool $strict = false): array
    {
        $addresses = []; // Initialize.

        if (is_array($value) || is_object($value)) {
            foreach ($value as $_key => $_value) {
                $addresses = array_merge($addresses, $this->parseAddresses($_value, $strict));
            } // unset($_key, $_value); // Housekeeping.
            return $addresses;
        }
        $string                      = (string) $value;
        $delimiter                   = mb_strpos($string, ';') !== false ? ';' : ',';
        $regex_delimitation_splitter = '/'.$delimiter.'+/u'; // `$this->c::escRegex()` unnecessary.

        $possible_addresses = preg_split($regex_delimitation_splitter, $string, -1, PREG_SPLIT_NO_EMPTY);
        $possible_addresses = $this->c::mbTrim($possible_addresses);

        foreach ($possible_addresses as $_address) {
            if (!$_address || mb_strpos($_address, '@', 1) === false) {
                continue; // NOT an email address.
            }
            if (mb_strpos($_address, '<') !== false && preg_match('/(?:"(?<name>[^"]+?)"\s*)?\<(?<email>.+?)\>/u', $_address, $_m)) {
                if ($_m['email'] && mb_strpos($_m['email'], '@', 1) !== false && (!$strict || $this->isValid($_m['email']))) {
                    $_email             = mb_strtolower($_m['email']);
                    $_name              = !empty($_m['name']) ? $_m['name'] : '';
                    $_fname             = $_name ? $this->c::fnameIn($_name) : '';
                    $_lname             = $_name ? $this->c::lnameIn($_name) : '';
                    $addresses[$_email] = (object) ['name' => $_name, 'fname' => $_fname, 'lname' => $_lname, 'email' => $_email];
                }
            } elseif (!$strict || $this->isValid($_address)) {
                $_email             = mb_strtolower($_address);
                $addresses[$_email] = (object) ['name' => '', 'fname' => '', 'lname' => '', 'email' => $_email];
            }
        } // unset($_address, $_m, $_email, $_name, $_fname, $_lname); // Housekeeping.

        return $addresses;
    }
Parse addresses.

@since 151121 Email utilities.

@param mixed $value  Any input value w/ recipients.
@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 \StdClass[] Each object in the array contains 3 properties: `name`, `fname`, `lname`, `email`.