本文整理汇总了PHP中Zend_Mime类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Mime类的具体用法?PHP Zend_Mime怎么用?PHP Zend_Mime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Mime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:
示例16: assertDateInSubject
private function assertDateInSubject($period, $expectedDate)
{
$alerts = $this->getTriggeredAlerts();
Mail::setDefaultTransport(new \Zend_Mail_Transport_File());
$mail = new Mail();
$this->notifier->sendAlertsPerEmailToRecipient($alerts, $mail, '[email protected]', $period, 1);
$expected = 'New alert for website Piwik test [' . $expectedDate . ']';
$expecteds = array($expected, \Zend_Mime::encodeQuotedPrintableHeader($expected, 'utf-8'));
$isExpected = in_array($mail->getSubject(), $expecteds);
$this->assertTrue($isExpected, $mail->getSubject() . " not found in " . var_export($expecteds, true));
}
开发者ID:andrzejewsky,项目名称:plugin-CustomAlerts,代码行数:11,代码来源:NotifierTest.php
示例17: _addAttachments
/**
* add attachments to mail
*
* @param Expressomail_mail $_mail
* @param Expressomail_Model_Message $_message
*/
protected function _addAttachments(Expressomail_mail $_mail, Expressomail_Model_Message $_message)
{
if (!isset($_message->attachments) || empty($_message->attachments)) {
return;
}
$size = 0;
$tempFileBackend = Tinebase_TempFile::getInstance();
foreach ($_message->attachments as $attachment) {
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Adding attachment: ' . (is_object($attachment) ? print_r($attachment->toArray(), TRUE) : print_r($attachment, TRUE)));
}
if ($attachment['partId'] && $_message->original_id instanceof Expressomail_Model_Message) {
$originlPart = $this->getMessagePart($_message->original_id, $attachment['partId']);
switch ($originlPart->encoding) {
case Zend_Mime::ENCODING_BASE64:
$part = new Zend_Mime_Part(base64_decode(stream_get_contents($originlPart->getRawStream())));
$part->encoding = Zend_Mime::ENCODING_BASE64;
break;
case Zend_Mime::ENCODING_QUOTEDPRINTABLE:
$part = new Zend_Mime_Part(quoted_printable_decode(stream_get_contents($originlPart->getRawStream())));
$part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE;
break;
default:
$part = new Zend_Mime_Part(stream_get_contents($originlPart->getRawStream()));
$part->encoding = null;
break;
}
$name = $attachment['name'];
$type = $attachment['type'];
} else {
$tempFile = $attachment instanceof Tinebase_Model_TempFile ? $attachment : (array_key_exists('tempFile', $attachment) ? $tempFileBackend->get($attachment['tempFile']['id']) : NULL);
if ($tempFile === NULL) {
continue;
}
if (!$tempFile->path) {
Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Could not find attachment.');
continue;
}
// get contents from uploaded file
$stream = fopen($tempFile->path, 'r');
$part = new Zend_Mime_Part($stream);
// RFC822 attachments are not encoded, set all others to ENCODING_BASE64
$part->encoding = $tempFile->type == Expressomail_Model_Message::CONTENT_TYPE_MESSAGE_RFC822 ? null : Zend_Mime::ENCODING_BASE64;
$name = $tempFile->name;
$type = $tempFile->type;
// try to detect the correct file type, on error fallback to the default application/octet-stream
if ($tempFile->type == "undefined" || $tempFile->type == "unknown") {
try {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$type = finfo_file($finfo, $tempFile->path);
} catch (Exception $e) {
$type = "application/octet-stream";
}
try {
finfo_close($finfo);
} catch (Exception $e) {
}
}
}
$part->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
$name = Zend_Mime::encodeQuotedPrintableHeader(addslashes($name), 'utf-8');
$partTypeString = $type . '; name="' . $name . '"';
$part->type = $partTypeString;
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Adding attachment ' . $partTypeString);
}
$_mail->addAttachment($part);
}
}
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:75,代码来源:Send.php
示例18: _buildBody
/**
* Generate MIME compliant message from the current configuration
*
* If both a text and HTML body are present, generates a
* multipart/alternative Zend_Mime_Part containing the headers and contents
* of each. Otherwise, uses whichever of the text or HTML parts present.
*
* The content part is then prepended to the list of Zend_Mime_Parts for
* this message.
*
* @return void
*/
protected function _buildBody()
{
$text = $this->_mail->getBodyText();
$html = $this->_mail->getBodyHtml();
$htmlAttachments = $this->_mail->getHtmlRelatedAttachments();
$htmlAttachmentParts = $htmlAttachments->getParts();
$hasHtmlRelatedParts = count($htmlAttachmentParts);
if ($text && $html || $html && $hasHtmlRelatedParts && count($this->_parts)) {
// Generate unique boundary for multipart/alternative
$mime = new Zend_Mime(null);
$boundaryLine = $mime->boundaryLine($this->EOL);
$boundaryEnd = $mime->mimeEnd($this->EOL);
$html->disposition = false;
if ($hasHtmlRelatedParts) {
$message = new Zend_Mime_Message();
array_unshift($htmlAttachmentParts, $html);
$message->setParts($htmlAttachmentParts);
$htmlMime = $htmlAttachments->getMime();
$message->setMime($htmlMime);
$html = new Zend_Mime_Part($message->generateMessage($this->EOL, false));
$html->boundary = $htmlMime->boundary();
$html->type = Zend_Mime::MULTIPART_RELATED;
$html->encoding = null;
}
$body = $boundaryLine;
if ($text) {
$text->disposition = false;
$body .= $text->getHeaders($this->EOL) . $this->EOL . $text->getContent($this->EOL) . $this->EOL . $boundaryLine;
}
$body .= $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();
$this->_isMultipart = true;
// Ensure first part contains text alternatives
array_unshift($this->_parts, $mp);
// Get headers
$this->_headers = $this->_mail->getHeaders();
return;
}
// If not multipart, then get the body
if (false !== ($body = $this->_mail->getBodyHtml())) {
array_unshift($this->_parts, $body);
if ($hasHtmlRelatedParts) {
$this->_mail->setType(Zend_Mime::MULTIPART_RELATED);
foreach ($htmlAttachmentParts as $part) {
$this->_parts[] = $part;
}
}
} elseif (false !== ($body = $this->_mail->getBodyText())) {
array_unshift($this->_parts, $body);
}
if (!$body) {
/**
* @see Zend_Mail_Transport_Exception
*/
require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Transport_Exception('No body specified');
}
// Get headers
$this->_headers = $this->_mail->getHeaders();
$headers = $body->getHeadersArray($this->EOL);
foreach ($headers as $header) {
// Headers in Zend_Mime_Part are kept as arrays with two elements, a
// key and a value
$this->_headers[$header[0]] = array($header[1]);
}
}
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:80,代码来源:Transport.php
示例19: encodeXdfnVariable
/**
* @param mixed $variableName
* @param mixed $variableValue
* @return string
*/
protected function encodeXdfnVariable($variableName, $variableValue)
{
if ($this->isReservedVariable($variableName)) {
$variableName = '*' . $variableName;
//reserved variables are prefixed
}
if ($variableName == '*parts') {
$encoded = sprintf('%s=%s', $variableName, $variableValue);
} else {
$variableValue = addslashes($variableValue);
$variableValue = Zend_Mime::encodeQuotedPrintable($variableValue, 4096);
$variableValue = str_replace("\r", "", $variableValue);
$variableValue = str_replace("\n", " ", $variableValue);
$encoded = sprintf('%s="%s"', $variableName, $variableValue);
}
return $encoded;
}
开发者ID:Antevenio,项目名称:PowerMta,代码行数:22,代码来源:Transport.php
示例20: _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) === false) {
if ($this->getHeaderEncoding() === Zend_Mime::ENCODING_QUOTEDPRINTABLE) {
$value = Zend_Mime::encodeQuotedPrintableHeader($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND);
} else {
$value = Zend_Mime::encodeBase64Header($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND);
}
}
return $value;
}
开发者ID:kaseya-university,项目名称:efront,代码行数:20,代码来源:Mail.php
注:本文中的Zend_Mime类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论