ZF-8503: _formatAddress creates invalid format if Email and Name are both emailaddresses (different ones)


If both arguments of _formatAddress are emailadresses, this function creates an invalid Header. Called like this: _formatAddress('','') creates following return value: '' Using this value as a Headervalue like "From", the From-Field is displayed incorrect. In Outlook the header looks like 'From: "jonas@" <>'

This is because the name should be quoted.

The easiest way to fix it is to change the function like this:

protected function _formatAddress($email, $name)
        if ($name === '' || $name === null || $name === $email) {
            return $email;
        } else {
            $encodedName = $this->_encodeHeader($name);
            if ($encodedName === $name && (strpos($name, ',') !== false || strpos($name, '@') !== false)) {
                $format = '"%s" <%s>';
            } else {
                $format = '%s <%s>';
            return sprintf($format, $encodedName, $email);

Greetings, Jonas


I think it may be Outlook problem. but I added some logic that you can handle name including at mark ;-)

SVN trunk r19608