Zend_Mail::setMessageId PHP Method

setMessageId() public method

Sets the Message-ID of the message
public setMessageId ( boolean | string $id = true ) : Zend_Mail
$id boolean | string true :Auto false :No set null :No set string:Sets given string (Angle brackets is not necessary)
return Zend_Mail Provides fluent interface
    public function setMessageId($id = true)
    {
        if ($id === null || $id === false) {
            return $this;
        } elseif ($id === true) {
            $id = $this->createMessageId();
        }
        if ($this->_messageId === null) {
            $id = $this->_filterOther($id);
            $this->_messageId = $id;
            $this->_storeHeader('Message-Id', '<' . $this->_messageId . '>');
        } else {
            /**
             * @see Zend_Mail_Exception
             */
            require_once 'Zend/Mail/Exception.php';
            throw new Zend_Mail_Exception('Message-ID set twice');
        }
        return $this;
    }

Usage Example

Example #1
0
 public function indexAction()
 {
     $req = $this->getRequest();
     $this->view->form = new Group_Form_Contact('contact');
     if ($req->isPost()) {
         if ($this->view->form->isValid($_POST)) {
             // we need the email settings from the registry
             $this->mailsettings = Zend_Registry::get('emailSettings');
             $values = $this->view->form->getValues();
             if (!$this->mailsettings->sendmail) {
                 $mtconf = array('auth' => 'login', 'username' => $this->mailsettings->smtp->user, 'password' => $this->mailsettings->smtp->password, 'port' => $this->mailsettings->smtp->port);
                 if ($this->mailsettings->smtp->ssl) {
                     $mtconf['ssl'] = 'tls';
                 }
                 $mtr = new Zend_Mail_Transport_Smtp($this->mailsettings->smtp->host, $mtconf);
             } else {
                 $mtr = new Zend_Mail_Sendmail();
             }
             $mailer = new Zend_Mail('UTF-8');
             $mailer->setFrom($values['email'], $values['author']);
             $mailer->addTo($this->mailsettings->email->admin, 'FansubCMS Administration');
             $mailer->setMessageId();
             $mailer->setSubject('FansubCMS Contact');
             $mailer->addHeader('X-MailGenerator', 'ContactForm on FansubCMS');
             $mailer->addHeader('X-Mailer', 'FansubCMS');
             $mailer->addHeader('X-Priority', '3');
             $message = $this->translate('contact_mail_text', array('name' => $values['author'], 'email' => $values['email'], 'text' => $values['content']));
             $mailer->setBodyText($message, 'UTF-8');
             if ($mailer->send($mtr)) {
                 $this->view->message = $this->translate('group_contact_mail_sent_successful');
                 $this->view->form = new Group_Form_Contact('contact');
             }
         }
     }
     $this->view->title = $this->translate('group_contact_title');
 }
All Usage Examples Of Zend_Mail::setMessageId