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


PHP Zend_Mime類代碼示例

本文整理匯總了PHP中Zend_Mime的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Mime類的具體用法?PHP Zend_Mime怎麽用?PHP Zend_Mime使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: _encodeHeader

 /**
  * Encode header fields
  *
  * Encodes header content according to RFC1522 if it contains non-printable
  * characters.
  *
  * @param  string $value
  * @return string
  */
 protected function _encodeHeader($value)
 {
     if (\Zend_Mime::isPrintable($value)) {
         return $value;
     } else {
         /**
          * Next strings fixes the problems
          * According to RFC 1522 (http://www.faqs.org/rfcs/rfc1522.html)
          */
         $quotedValue = '';
         $count = 1;
         for ($i = 0; strlen($value) > $i; $i++) {
             if ($value[$i] == '?' or $value[$i] == '_' or $value[$i] == ' ') {
                 $quotedValue .= str_replace(array('?', ' ', '_'), array('=3F', '=20', '=5F'), $value[$i]);
             } else {
                 $quotedValue .= $this->encodeQuotedPrintable($value[$i]);
             }
             if (strlen($quotedValue) > $count * \Zend_Mime::LINELENGTH) {
                 $count++;
                 $quotedValue .= "?=\n =?" . $this->_charset . '?Q?';
             }
         }
         return '=?' . $this->_charset . '?Q?' . $quotedValue . '?=';
     }
 }
開發者ID:sb15,項目名稱:utils,代碼行數:34,代碼來源:EmailFix.php

示例2: _encodeHeader

 /**
  * Encode header fields
  *
  * Encodes header content according to RFC1522 if it contains non-printable
  * characters.
  *
  * @param  string $value
  * @return string
  */
 protected function _encodeHeader($value)
 {
     if (Zend_Mime::isPrintable($value)) {
         return $value;
     } else {
         $base64Value = base64_encode($value);
         return "=?" . $this->_charset . "?B?" . $base64Value . "?=";
     }
 }
開發者ID:kangza,項目名稱:hagtag,代碼行數:18,代碼來源:Mail.php

示例3: getBodyHtml

 public function getBodyHtml($htmlOnly = false)
 {
     if ($htmlOnly) {
         return parent::getBodyHtml(true);
     }
     $mime = new Zend_Mime($this->getMimeBoundary());
     $boundaryLine = $mime->boundaryLine($this->EOL);
     $boundaryEnd = $mime->mimeEnd($this->EOL);
     $html = parent::getBodyHtml();
     $text = parent::getBodyText();
     $text->disposition = false;
     $html->disposition = false;
     $body = $boundaryLine . $text->getHeaders($this->EOL) . $this->EOL . $text->getContent($this->EOL) . $this->EOL . $boundaryLine . $html->getHeaders($this->EOL) . $this->EOL . $html->getContent($this->EOL) . $this->EOL . $boundaryEnd;
     $mp = new Zend_Mime_Part($body);
     $mp->type = Zend_Mime::MULTIPART_ALTERNATIVE;
     $mp->boundary = $mime->boundary();
     return $mp;
 }
開發者ID:jsiefer,項目名稱:emarketing,代碼行數:18,代碼來源:Mail.php

示例4: _encodeHeader

 /**
  * Encode header fields
  *
  * Encodes header content according to RFC1522 if it contains non-printable
  * characters.
  *
  * @param  string $value
  * @return string
  */
 protected function _encodeHeader($value)
 {
     if (Zend_Mime::isPrintable($value)) {
         return $value;
     } else {
         $quotedValue = Zend_Mime::encodeQuotedPrintable($value, 400);
         $quotedValue = str_replace(array('?', ' ', '_'), array('=3F', '=20', '=5F'), $quotedValue);
         return '=?' . $this->_charset . '?Q?' . $quotedValue . '?=';
     }
 }
開發者ID:BGCX261,項目名稱:zhongyycode-svn-to-git,代碼行數:19,代碼來源:Mail.php

示例5: _encodeHeader

 protected function _encodeHeader($value)
 {
     if (Zend_Mime::isPrintable($value)) {
         return $value;
     } else {
         $quotedValue = Zend_Mime::encodeQuotedPrintable($value);
         $quotedValue = str_replace(array('?', ' '), array('=3F', '=20'), $quotedValue);
         $quotedValue = rawurlencode($quotedValue);
         $quotedValue = str_replace('%3D%0A', '', $quotedValue);
         $quotedValue = rawurldecode($quotedValue);
         $quotedValue = '=?' . $this->_charset . '?Q?' . $quotedValue . '?=';
     }
     return $quotedValue;
 }
開發者ID:rdallasgray,項目名稱:bbx,代碼行數:14,代碼來源:Mail.php

示例6: indexAction

 public function indexAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     //$value = 'АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩъыьЭЮЯ';
     $value = 'いろはにほへとちりぬるをわかよたれそつねならむ';
     echo "<pre>B-1. Zend_Mime::encodeBase64Header:<br>\r\n";
     echo Zend_Mime::encodeBase64Header($value, $this->_charset, $this->_len, $this->_feed);
     echo "\r\n<br><br>";
     echo "Q-1. Zend_Mime::encodeQuotedPrintableHeader:<br>\r\n";
     echo Zend_Mime::encodeQuotedPrintableHeader($value, $this->_charset, $this->_len, $this->_feed);
     echo "\r\n<br><br>";
     mb_internal_encoding($this->_charset);
     echo "B-2. Base64 by mb_encode_mimeheader:<br>\r\n";
     echo mb_encode_mimeheader($value, $this->_charset, 'B', $this->_feed, $this->_len);
     echo "\r\n<br><br>";
     echo "Q-2. QuotedPrintable by mb_encode_mimeheader:<br>\r\n";
     echo mb_encode_mimeheader($value, $this->_charset, 'Q', $this->_feed, $this->_len);
     echo "</pre>\r\n";
 }
開發者ID:Tony133,項目名稱:zf-web,代碼行數:19,代碼來源:MimeController.php

示例7: setTypeAndDispositionForAttachment

 /**
  * set part type and disposition (with name if available)
  * 
  * @param string $type
  * @param string $name
  */
 public function setTypeAndDispositionForAttachment($type, $name = NULL)
 {
     $this->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
     $partTypeString = $type;
     if ($name) {
         $name = Zend_Mime::encodeQuotedPrintableHeader($name, 'utf-8');
         $partTypeString .= '; name="' . $name . '"';
         $this->disposition .= '; filename="' . $name . '"';
     }
     $this->type = $partTypeString;
 }
開發者ID:bitExpert,項目名稱:Tine-2.0-Open-Source-Groupware-and-CRM,代碼行數:17,代碼來源:Part.php

示例8: _encodeHeader

 /**
  * Encode header fields
  *
  * Encodes header content according to RFC1522 if it contains non-printable
  * characters.
  *
  * @param  string $value
  * @return string
  */
 protected function _encodeHeader($value)
 {
     if (Zend_Mime::isPrintable($value)) {
         return $value;
     } elseif ($this->_encodingOfHeaders === Zend_Mime::ENCODING_QUOTEDPRINTABLE) {
         $quotedValue = Zend_Mime::encodeQuotedPrintable($value);
         $quotedValue = str_replace(array('?', ' ', '_'), array('=3F', '=20', '=5F'), $quotedValue);
         return '=?' . $this->_charset . '?Q?' . $quotedValue . '?=';
     } elseif ($this->_encodingOfHeaders === Zend_Mime::ENCODING_BASE64) {
         return '=?' . $this->_charset . '?B?' . Zend_Mime::encodeBase64($value) . '?=';
     } else {
         /**
          * @todo 7Bit and 8Bit is currently handled the same way.
          */
         return $value;
     }
 }
開發者ID:ankuradhey,項目名稱:dealtrip,代碼行數:26,代碼來源:Mail.php

示例9: getContent

 /**
  * Get the Content of the current Mail Part in the given encoding.
  *
  * @return String
  */
 public function getContent()
 {
     return Zend_Mime::encode($this->_content, $this->encoding);
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:9,代碼來源:Part.php

示例10: getRawMessage

 /**
  * get raw message as string
  * 
  * @param Zend_Mail $mail
  * @param array $_additionalHeaders
  * @return string
  */
 public function getRawMessage(Zend_Mail $mail = NULL, $_additionalHeaders = array())
 {
     if ($mail !== NULL) {
         // this part is from Zend_Mail_Transport_Abstract::send()
         $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) {
             /**
              * @see Zend_Mail_Transport_Exception
              */
             require_once 'Zend/Mail/Transport/Exception.php';
             throw new Zend_Mail_Transport_Exception('Mail is empty');
         }
         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);
     }
     $mailAsString = $this->getHeaders($_additionalHeaders) . $this->EOL . $this->getBody();
     // convert \n to \r\n
     $mailAsString = preg_replace("/(?<!\\r)\\n(?!\\r)/", "\r\n", $mailAsString);
     return $mailAsString;
 }
開發者ID:rodrigofns,項目名稱:ExpressoLivre3,代碼行數:51,代碼來源:Transport.php

示例11: getContent

 /**
  * Get the Content of the current Mime Part in the given encoding.
  *
  * @return String
  */
 public function getContent($EOL = Zend_Mime::LINEEND)
 {
     if ($this->_isStream) {
         return stream_get_contents($this->getEncodedStream());
     } else {
         return Zend_Mime::encode($this->_content, $this->encoding, $EOL);
     }
 }
開發者ID:jglaine,項目名稱:sugar761-ent,代碼行數:13,代碼來源:Part.php

示例12: testBase64

 public function testBase64()
 {
     $content = str_repeat("И™ѓњ)И™ѓњ)И™ѓ", 4);
     $encoded = Zend_Mime::encodeBase64($content);
     $this->assertEquals($content, base64_decode($encoded));
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:6,代碼來源:MimeTest.php

示例13: 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

示例14: testLineLengthInQuotedPrintableHeaderEncoding

 /**
  * @group ZF-1688
  */
 public function testLineLengthInQuotedPrintableHeaderEncoding()
 {
     $subject = "Alle meine Entchen schwimmen in dem See, schwimmen in dem See, Köpfchen in das Wasser, Schwänzchen in die Höh!";
     $encoded = Zend_Mime::encodeQuotedPrintableHeader($subject, "UTF-8", 100);
     foreach (explode(Zend_Mime::LINEEND, $encoded) as $line) {
         if (strlen($line) > 100) {
             $this->fail("Line '" . $line . "' is " . strlen($line) . " chars long, only 100 allowed.");
         }
     }
     $encoded = Zend_Mime::encodeQuotedPrintableHeader($subject, "UTF-8", 40);
     foreach (explode(Zend_Mime::LINEEND, $encoded) as $line) {
         if (strlen($line) > 40) {
             $this->fail("Line '" . $line . "' is " . strlen($line) . " chars long, only 40 allowed.");
         }
     }
 }
開發者ID:netvlies,項目名稱:zf,代碼行數:19,代碼來源:MimeTest.php

示例15: getDecodedContent

 /**
  * Get the Content of the current Mime Part in the given decoding.
  *
  * @return String
  */
 public function getDecodedContent()
 {
     if ($this->_isStream) {
         $result = stream_get_contents($this->getDecodedStream());
     } else {
         // Zend_Mime::decode not yet implemented
         $result = Zend_Mime::decode($this->_content, $this->encoding);
     }
     return $result;
 }
開發者ID:,項目名稱:,代碼行數:15,代碼來源:


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