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


PHP Zend_Mail::getMimeBoundary方法代碼示例

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


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

示例1: send

 /**
  * Send a mail using this transport
  * 
  * @param Zend_Mail $mail 
  * @access public
  * @return void
  * @throws Zend_Mail_Transport_Exception if mail is empty
  */
 public function send(Zend_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 Zend_Mail_Transport_Exception('Empty mail cannot be sent');
     }
     if ($count > 1) {
         // Multipart message; create new MIME object and boundary
         $mime = new Zend_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 object can be used in
     // multiple transports
     $message = new Zend_Mime_Message();
     $message->setParts($this->_parts);
     $message->setMime($mime);
     $this->body = $message->generateMessage($this->EOL);
     // Send to transport!
     $this->_sendMail();
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:43,代碼來源:Abstract.php

示例2: send

 /**
  * Send a mail using this transport
  *
  * @param  OpenPGP_Zend_Mail $mail
  * @access public
  * @return void
  * @throws Zend_Mail_Transport_Exception if mail is empty
  */
 public function send(OpenPGP_Zend_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 Zend_Mail_Transport_Exception('Empty mail cannot be sent');
     }
     if ($count > 1) {
         // Multipart message; create new MIME object and boundary
         $mime = new Zend_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 OpenPGP_Zend_Mail object can be used in
     // multiple transports
     $message = new Zend_Mime_Message();
     $message->setParts($this->_parts);
     $message->setMime($mime);
     $this->body = $message->generateMessage($this->EOL);
     ////////////////////////////////////////////////////////
     //                                                    //
     // ALPHAFIELDS 2012-11-03: ADDED PGP/MIME ENCRYPTION  //
     // USING lib/openpgp/opepgplib.php                    //
     //                                                    //
     ////////////////////////////////////////////////////////
     // get from globals (set in tiki-setup.php)
     global $openpgplib;
     $pgpmime_msg = $openpgplib->prepareEncryptWithZendMail($this->header, $this->body, $mail->getRecipients());
     $this->header = $pgpmime_msg[0];
     // set pgp/mime headers from result array
     $this->body = $pgpmime_msg[1];
     // set pgp/mime encrypted message body from result array
     ////////////////////////////////////////////////////////
     //                                                    //
     // ALPHAFIELDS 2012-11-03: ..END PGP/MIME ENCRYPTION  //
     //                                                    //
     ////////////////////////////////////////////////////////
     // Send to transport!
     $this->_sendMail();
 }
開發者ID:jkimdon,項目名稱:cohomeals,代碼行數:61,代碼來源:OpenPGP_Zend_Mail_Transport_Abstract.php

示例3: testAttachment

 /**
  * check if attachment handling works
  *
  */
 public function testAttachment()
 {
     $mail = new Zend_Mail();
     $mail->setBodyText('My Nice Test Text');
     $mail->addTo('testmail@example.com', 'Test Recipient');
     $mail->setFrom('mymail@example.com', 'Test Sender');
     $mail->setSubject('Test: Attachment Test with Zend_Mail');
     $at = $mail->addAttachment('abcdefghijklmnopqrstuvexyz');
     $at->type = 'image/gif';
     $at->id = 12;
     $at->filename = 'test.gif';
     $mock = new Zend_Mail_Transport_Mock();
     $mail->send($mock);
     // now check what was generated by Zend_Mail.
     // first the mail headers:
     $this->assertContains('Content-Type: multipart/mixed', $mock->header);
     $boundary = $mail->getMimeBoundary();
     $this->assertContains('boundary="' . $boundary . '"', $mock->header);
     $this->assertContains('MIME-Version: 1.0', $mock->header);
     // check body
     // search for first boundary
     $p1 = strpos($mock->body, "--{$boundary}\n");
     $this->assertNotEquals(null, $p1);
     // cut out first (Text) part
     $start1 = $p1 + 3 + strlen($boundary);
     $p2 = strpos($mock->body, "--{$boundary}\n", $start1);
     $this->assertNotEquals(null, $p2);
     $partBody1 = substr($mock->body, $start1, $p2 - $start1);
     $this->assertContains('Content-Type: text/plain', $partBody1);
     $this->assertContains('My Nice Test Text', $partBody1);
     // check second (HTML) part
     // search for end boundary
     $start2 = $p2 + 3 + strlen($boundary);
     $p3 = strpos($mock->body, "--{$boundary}--");
     $this->assertNotEquals(null, $p3);
     $partBody2 = substr($mock->body, $start2, $p3 - $start2);
     $this->assertContains('Content-Type: image/gif', $partBody2);
     $this->assertContains('Content-Transfer-Encoding: base64', $partBody2);
     $this->assertContains('Content-ID: <12>', $partBody2);
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:44,代碼來源:MailTest.php


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