src/Email.php
public static function addressParse($addressString)
    {
        // $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
        // $this->debug->log('addressString', $addressString);
        $pattern = '/^(?:"?((?:[^"\\\\]|\\\\.)+)"?\s)?'             // name
            .'<?([a-z0-9._%-]+@[a-z0-9.-]+\\.[a-z]{2,4})>?$/i';     // email
        $addresses = str_getcsv($addressString);
        // $this->debug->log('addresses', $addresses);
        $result = array();
        foreach ($addresses as $address) {
            $address = trim($address);
            if (preg_match($pattern, $address, $matches)) {
                $item = array();
                if ($matches[1] != '') {
                    $item['name'] = stripcslashes($matches[1]);
                }
                $item['email'] =  $matches[2];
                $result[] = $item;
            }
        }
        // $this->debug->groupEnd();
        return $result;
    }
public static function addressParse($addressString)
    {
        // $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
        // $this->debug->log('addressString', $addressString);
        $pattern = '/^(?:"?((?:[^"\\\\]|\\\\.)+)"?\s)?'             // name
            .'<?([a-z0-9._%-]+@[a-z0-9.-]+\\.[a-z]{2,4})>?$/i';     // email
        $addresses = str_getcsv($addressString);
        // $this->debug->log('addresses', $addresses);
        $result = array();
        foreach ($addresses as $address) {
            $address = trim($address);
            if (preg_match($pattern, $address, $matches)) {
                $item = array();
                if ($matches[1] != '') {
                    $item['name'] = stripcslashes($matches[1]);
                }
                $item['email'] =  $matches[2];
                $result[] = $item;
            }
        }
        // $this->debug->groupEnd();
        return $result;
    }
public static function addressParse ( $ addressString ) { // $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__); // $this->debug->log('addressString', $addressString); $ pattern = '/^(?:"?((?:[^"\\\\]|\\\\.)+)"?\s)?' // name . '<?([a-z0-9._%-]+@[a-z0-9.-]+\\.[a-z]{2,4})>?$/i' ; // email $ addresses = str_getcsv ( $ addressString ) ; // $this->debug->log('addresses', $addresses); $ result = array ( ) ; foreach ( $ addresses as $ address ) { $ address = trim ( $ address ) ; if ( preg_match ( $ pattern , $ address , $ matches ) ) { $ item = array ( ) ; if ( $ matches [ 1 ] != '' ) { $ item [ 'name' ] = stripcslashes ( $ matches [ 1 ] ) ; } $ item [ 'email' ] = $ matches [ 2 ] ; $ result [ ] = $ item ; } } // $this->debug->groupEnd(); return $ result ; }
parse address string

@param string $addressString rfc-822 address list

@return array (name & email)
@see    http://stackoverflow.com/questions/6609195/parse-rfc-822-compliant-addresses-in-a-to-header
parse address string