Issues

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

Issue Type: Bug Created: 2009-12-09T01:31:18.000+0000 Last Updated: 2009-12-12T20:52:11.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Jonas W├╝ste (jwueste) Assignee: Satoru Yoshida (satoruyoshida) Tags: - Zend_Mail

Related issues: Attachments:

Description

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

This is because the name should be quoted.

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

<pre class="highlight">
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

Comments

Posted by Satoru Yoshida (satoruyoshida) on 2009-12-12T20:51:07.000+0000

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

SVN trunk r19608

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts