Zend_Mail::setReplyTo PHP Method

setReplyTo() public method

Set Reply-To Header
public setReplyTo ( string $email, string $name = null ) : Zend_Mail
$email string
$name string
return Zend_Mail
    public function setReplyTo($email, $name = null)
    {
        if (null !== $this->_replyTo) {
            /**
             * @see Zend_Mail_Exception
             */
            require_once 'Zend/Mail/Exception.php';
            throw new Zend_Mail_Exception('Reply-To Header set twice');
        }
        $email = $this->_filterEmail($email);
        $name = $this->_filterName($name);
        $this->_replyTo = $email;
        $this->_storeHeader('Reply-To', $this->_formatAddress($email, $name), true);
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Send an email.
  *
  * @param array $params Config object.
  *  Required keys: to, subject, message
  *  Optional keys: replyTo
  * @param array $viewParams Any values you wish to send to the HTML mail template
  * @param array $attachments
  * @return bool
  */
 public function send(array $params, array $viewParams = array(), $attachments = array())
 {
     $this->_validateParams($params);
     $mail = new Zend_Mail($this->getCharacterEncoding());
     $mail->setSubject($params['subject']);
     $mail->setBodyText($this->_getPlainBodyText($params));
     $mail->setFrom($this->getFromAddress(), $this->getFromName());
     $mail->addTo($params['to']);
     $viewParams['subject'] = $params['subject'];
     if ($this->getHtmlTemplate()) {
         $viewParams['message'] = isset($params['message']) ? $params['message'] : '';
         $viewParams['htmlMessage'] = isset($params['htmlMessage']) ? $params['htmlMessage'] : '';
         $mail->setBodyHtml($this->_renderView($viewParams));
     } elseif (isset($params['htmlMessage'])) {
         $mail->setBodyHtml($params['htmlMessage']);
     }
     if (!empty($params['replyTo'])) {
         $mail->setReplyTo($params['replyTo']);
     }
     if (!empty($params['cc'])) {
         $mail->addCc($params['cc']);
     }
     if (!empty($params['bcc'])) {
         $mail->addBcc($params['bcc']);
     }
     $this->addAttachments($attachments);
     $mimeParts = array_map(array($this, '_attachmentToMimePart'), $this->_attachments);
     array_walk($mimeParts, array($mail, 'addAttachment'));
     return $mail->send($this->getTransport());
 }
All Usage Examples Of Zend_Mail::setReplyTo