Index: Mail.php =================================================================== --- Mail.php (revision 18017) +++ Mail.php (working copy) @@ -98,6 +98,12 @@ protected $_recipients = array(); /** + * Reply-To header + * @var string + */ + protected $_replyTo = null; + + /** * Return-Path header * @var string */ @@ -613,37 +619,78 @@ } /** - * Set Reply-To Header + * Returns the sender of the mail * - * @param string $email - * @param string $name - * @return Zend_Mail + * @return string */ - public function setReplyTo($email, $name=null) + public function getFrom() { - $this->_addRecipientAndHeader('Reply-To', $email, $name); + return $this->_from; + } + + /** + * Clears the sender from the mail + * + * @return Zend_Mail Provides fluent interface + */ + public function clearFrom() + { + $this->_from = null; + $this->_clearHeader('From'); + return $this; } /** - * Returns the sender of the mail + * Sets Reply-To header of the message * + * @param string $email + * @param string $name + * @return Zend_Mail Provides fluent interface + * @throws Zend_Mail_Exception if called subsequent times + */ + public function setReplyTo($email, $name = null) + { + if ($this->_replyTo === null) { + $email = $this->_filterEmail($email); + $name = $this->_filterName($name); + $this->_replyTo = $email; + $this->_storeHeader('Reply-To', $this->_formatAddress($email, $name), true); + } else { + /** + * @see Zend_Mail_Exception + */ + require_once 'Zend/Mail/Exception.php'; + throw new Zend_Mail_Exception('Reply-To Header set twice'); + } + return $this; + } + + /** + * Returns the current Reply-To address of the message + * + * If no Reply-To header is set, returns the value of {@link $_from}. + * * @return string */ - public function getFrom() + public function getReplyTo() { + if (null !== $this->_replyTo) { + return $this->_replyTo; + } + return $this->_from; } /** - * Clears the sender from the mail + * Clears the current Reply-To address from the message * * @return Zend_Mail Provides fluent interface */ - public function clearFrom() + public function clearReplyTo() { - $this->_from = null; - $this->_clearHeader('From'); + $this->_replyTo = null; + $this->_clearHeader('Reply-To'); return $this; }