當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Message::setMime方法代碼示例

本文整理匯總了PHP中Zend\Mime\Message::setMime方法的典型用法代碼示例。如果您正苦於以下問題:PHP Message::setMime方法的具體用法?PHP Message::setMime怎麽用?PHP Message::setMime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Mime\Message的用法示例。


在下文中一共展示了Message::setMime方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetMime

    public function testGetMime()
    {
        $msg = new Mime\Message();  // No Parts
        $m = $msg->getMime();
        $this->assertType('\Zend\Mime\Mime', $m);

        $msg = new Mime\Message();  // No Parts
        $mime = new Mime\Mime('1234');
        $msg->setMime($mime);
        $m2 = $msg->getMime();
        $this->assertType('\Zend\Mime\Mime', $m2);
        $this->assertEquals('1234', $m2->boundary());
    }
開發者ID:niallmccrudden,項目名稱:zf2,代碼行數:13,代碼來源:MessageTest.php

示例2: send

 /**
  * Send a mail using this transport
  *
  * @param  \Zend\Mail\Mail $mail
  * @access public
  * @return void
  * @throws \Zend\Mail\Transport\Exception if mail is empty
  */
 public function send(\Zend\Mail\Mail $mail)
 {
     $this->_isMultipart = false;
     $this->_mail = $mail;
     $this->_parts = $mail->getParts();
     $mime = $mail->getMime();
     // Build body content
     $this->_buildBody();
     // Determine number of parts and boundary
     $count = count($this->_parts);
     $boundary = null;
     if ($count < 1) {
         throw new Exception('Empty mail cannot be sent');
     }
     if ($count > 1) {
         // Multipart message; create new MIME object and boundary
         $mime = new Mime\Mime($this->_mail->getMimeBoundary());
         $boundary = $mime->boundary();
     } elseif ($this->_isMultipart) {
         // multipart/alternative -- grab boundary
         $boundary = $this->_parts[0]->boundary;
     }
     // Determine recipients, and prepare headers
     $this->recipients = implode(',', $mail->getRecipients());
     $this->_prepareHeaders($this->_getHeaders($boundary));
     // Create message body
     // This is done so that the same \Zend\Mail\Mail object can be used in
     // multiple transports
     $message = new Mime\Message();
     $message->setParts($this->_parts);
     $message->setMime($mime);
     $this->body = $message->generateMessage($this->EOL);
     // Send to transport!
     $this->_sendMail();
 }
開發者ID:alab1001101,項目名稱:zf2,代碼行數:43,代碼來源:AbstractTransport.php

示例3: testRetrievingBodyTextFromMessageWithMultiPartMimeBodyReturnsMimeSerialization

 public function testRetrievingBodyTextFromMessageWithMultiPartMimeBodyReturnsMimeSerialization()
 {
     $mime = new Mime('foo-bar');
     $text = new MimePart('foo');
     $text->type = 'text/plain';
     $html = new MimePart('<b>foo</b>');
     $html->type = 'text/html';
     $body = new MimeMessage();
     $body->setMime($mime);
     $body->addPart($text);
     $body->addPart($html);
     $this->message->setBody($body);
     $text = $this->message->getBodyText();
     $this->assertEquals($body->generateMessage(), $text);
     $this->assertContains('--foo-bar', $text);
     $this->assertContains('--foo-bar--', $text);
     $this->assertContains('Content-Type: text/plain', $text);
     $this->assertContains('Content-Type: text/html', $text);
 }
開發者ID:nevvermind,項目名稱:zf2,代碼行數:19,代碼來源:MessageTest.php


注:本文中的Zend\Mime\Message::setMime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。