Ver código fonte

ZF-6872 - Add setReplyTo() function, because the different parts (email and name) require different escaping behaviour, which can't be implemented easily in userland via addHeader().

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@16051 44c647ce-9c0f-0410-b52a-842ac1e357ba
beberlei 16 anos atrás
pai
commit
ba0a5ce230

+ 4 - 0
documentation/manual/en/module_specs/Zend_Mail-AdditionalHeaders.xml

@@ -16,6 +16,10 @@ $mail->addHeader('X-greetingsTo', 'Mom', true); // multiple values
 $mail->addHeader('X-greetingsTo', 'Dad', true);
 ]]></programlisting>
     </example>
+
+    <para>To set the Reply-To: header there exists the function <code>setReplyTo($email, $name=null)</code>,
+        because it requires additional special escaping of the different parts (email and name).</para>
+
 </sect1>
 <!--
 vim:se ts=4 sw=4 et:

+ 13 - 0
library/Zend/Mail.php

@@ -613,6 +613,19 @@ class Zend_Mail extends Zend_Mime_Message
     }
 
     /**
+     * Set Reply-To Header
+     *
+     * @param string $email
+     * @param string $name
+     * @return Zend_Mail
+     */
+    public function setReplyTo($email, $name=null)
+    {
+        $this->_addRecipientAndHeader('Reply-To', $email, $name);
+        return $this;
+    }
+
+    /**
      * Returns the sender of the mail
      *
      * @return string

+ 12 - 0
tests/Zend/Mail/MailTest.php

@@ -706,6 +706,18 @@ class Zend_Mail_MailTest extends PHPUnit_Framework_TestCase
     }
 
     /**
+     * @group ZF-6872
+     */
+    public function testSetReplyTo()
+    {
+        $mail = new Zend_Mail('UTF-8');
+        $mail->setReplyTo("foo@zend.com", "\xe2\x82\xa0!");
+        $headers = $mail->getHeaders();
+
+        $this->assertEquals("=?UTF-8?Q?=E2=82=A0!?= <foo@zend.com>", $headers["Reply-To"][0]);
+    }
+
+    /**
      * @group ZF-1688
      * @group ZF-2559
      */