本文整理汇总了PHP中Mail_mimeDecode::_decodeHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP Mail_mimeDecode::_decodeHeader方法的具体用法?PHP Mail_mimeDecode::_decodeHeader怎么用?PHP Mail_mimeDecode::_decodeHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mail_mimeDecode
的用法示例。
在下文中一共展示了Mail_mimeDecode::_decodeHeader方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SendMail
function SendMail($rfc822, $forward = false, $reply = false, $parent = false)
{
$mimeParams = array('decode_headers' => false, 'decode_bodies' => true, 'include_bodies' => true, 'input' => $rfc822, 'crlf' => "\r\n", 'charset' => 'utf-8');
$mimeObject = new Mail_mimeDecode($mimeParams['input'], $mimeParams['crlf']);
$message = $mimeObject->decode($mimeParams);
// Open the outbox and create the message there
$storeprops = mapi_getprops($this->_defaultstore, array(PR_IPM_OUTBOX_ENTRYID, PR_IPM_SENTMAIL_ENTRYID));
if (!isset($storeprops[PR_IPM_OUTBOX_ENTRYID])) {
debugLog("Outbox not found to create message");
return false;
}
$outbox = mapi_msgstore_openentry($this->_defaultstore, $storeprops[PR_IPM_OUTBOX_ENTRYID]);
if (!$outbox) {
debugLog("Unable to open outbox");
return false;
}
$mapimessage = mapi_folder_createmessage($outbox);
mapi_setprops($mapimessage, array(PR_SUBJECT => u2w($mimeObject->_decodeHeader($message->headers["subject"])), PR_SENTMAIL_ENTRYID => $storeprops[PR_IPM_SENTMAIL_ENTRYID], PR_MESSAGE_CLASS => "IPM.Note", PR_MESSAGE_DELIVERY_TIME => time()));
if (isset($message->headers["x-priority"])) {
switch ($message->headers["x-priority"]) {
case 1:
case 2:
$priority = PRIO_URGENT;
$importance = IMPORTANCE_HIGH;
break;
case 4:
case 5:
$priority = PRIO_NONURGENT;
$importance = IMPORTANCE_LOW;
break;
case 3:
default:
$priority = PRIO_NORMAL;
$importance = IMPORTANCE_NORMAL;
break;
}
mapi_setprops($mapimessage, array(PR_IMPORTANCE => $importance, PR_PRIORITY => $priority));
}
$addresses = array();
$toaddr = $ccaddr = $bccaddr = array();
if (isset($message->headers["to"])) {
$toaddr = Mail_RFC822::parseAddressList($message->headers["to"]);
}
if (isset($message->headers["cc"])) {
$ccaddr = Mail_RFC822::parseAddressList($message->headers["cc"]);
}
if (isset($message->headers["bcc"])) {
$bccaddr = Mail_RFC822::parseAddressList($message->headers["bcc"]);
}
// Add recipients
$recips = array();
if (isset($toaddr)) {
foreach (array(MAPI_TO => $toaddr, MAPI_CC => $ccaddr, MAPI_BCC => $bccaddr) as $type => $addrlist) {
foreach ($addrlist as $addr) {
$mapirecip[PR_ADDRTYPE] = "SMTP";
$mapirecip[PR_EMAIL_ADDRESS] = $addr->mailbox . "@" . $addr->host;
if (isset($addr->personal) && strlen($addr->personal) > 0) {
$mapirecip[PR_DISPLAY_NAME] = u2w($mimeObject->_decodeHeader($addr->personal));
} else {
$mapirecip[PR_DISPLAY_NAME] = $mapirecip[PR_EMAIL_ADDRESS];
}
$mapirecip[PR_RECIPIENT_TYPE] = $type;
$mapirecip[PR_ENTRYID] = mapi_createoneoff($mapirecip[PR_DISPLAY_NAME], $mapirecip[PR_ADDRTYPE], $mapirecip[PR_EMAIL_ADDRESS]);
array_push($recips, $mapirecip);
}
}
}
mapi_message_modifyrecipients($mapimessage, 0, $recips);
// Loop through subparts. We currently only support real single-level
// multiparts and partly multipart/related/mixed for attachments.
// The PDA currently only does this because you are adding
// an attachment and the type will be multipart/mixed or multipart/alternative.
$body = "";
if ($message->ctype_primary == "multipart" && ($message->ctype_secondary == "mixed" || $message->ctype_secondary == "alternative")) {
foreach ($message->parts as $part) {
if ($part->ctype_primary == "text" && $part->ctype_secondary == "plain" && isset($part->body)) {
// discard any other kind of text, like html
$body .= u2w($part->body);
// assume only one text body
} elseif ($part->ctype_primary == "ms-tnef" || $part->ctype_secondary == "ms-tnef") {
$zptnef = new ZPush_tnef($this->_defaultstore);
$mapiprops = array();
$zptnef->extractProps($part->body, $mapiprops);
if (is_array($mapiprops) && !empty($mapiprops)) {
//check if it is a recurring item
$tnefrecurr = GetPropIDFromString($this->_defaultstore, "PT_BOOLEAN:{6ED8DA90-450B-101B-98DA-00AA003F1305}:0x5");
if (isset($mapiprops[$tnefrecurr])) {
$this->_handleRecurringItem($mapimessage, $mapiprops);
}
mapi_setprops($mapimessage, $mapiprops);
} else {
debugLog("TNEF: Mapi props array was empty");
}
} elseif ($part->ctype_primary == "multipart" && ($part->ctype_secondary == "mixed" || $part->ctype_secondary == "related")) {
if (is_array($part->parts)) {
foreach ($part->parts as $part2) {
if (isset($part2->disposition) && ($part2->disposition == "inline" || $part2->disposition == "attachment")) {
$this->_storeAttachment($mapimessage, $part2);
}
}
//.........这里部分代码省略.........
示例2: SendMail
function SendMail($rfc822, $smartdata = array(), $protocolversion = false)
{
if (WBXML_DEBUG === true && $protocolversion <= 14.0) {
debugLog("SendMail: task " . $smartdata['task'] . " itemid: " . (isset($smartdata['itemid']) ? $smartdata['itemid'] : "") . " parent: " . (isset($smartdata['folderid']) ? $smartdata['folderid'] : "") . "\n" . $rfc822);
}
$mimeParams = array('decode_headers' => false, 'decode_bodies' => true, 'include_bodies' => true, 'charset' => 'utf-8');
$mimeObject = new Mail_mimeDecode($rfc822);
$message = $mimeObject->decode($mimeParams);
// Open the outbox and create the message there
$storeprops = mapi_getprops($this->_defaultstore, array(PR_IPM_OUTBOX_ENTRYID, PR_IPM_SENTMAIL_ENTRYID));
if (!isset($storeprops[PR_IPM_OUTBOX_ENTRYID])) {
debugLog("Outbox not found to create message");
return false;
}
$outbox = mapi_msgstore_openentry($this->_defaultstore, $storeprops[PR_IPM_OUTBOX_ENTRYID]);
if (!$outbox) {
debugLog("Unable to open outbox");
return false;
}
$mapimessage = mapi_folder_createmessage($outbox);
mapi_setprops($mapimessage, array(PR_SUBJECT => u2w($mimeObject->_decodeHeader(isset($message->headers["subject"]) ? $message->headers["subject"] : "")), PR_SENTMAIL_ENTRYID => $storeprops[PR_IPM_SENTMAIL_ENTRYID], PR_MESSAGE_CLASS => 'IPM.Note', PR_MESSAGE_DELIVERY_TIME => time()));
if (isset($message->headers["x-priority"])) {
switch ($message->headers["x-priority"]) {
case 1:
case 2:
$priority = PRIO_URGENT;
$importance = IMPORTANCE_HIGH;
break;
case 4:
case 5:
$priority = PRIO_NONURGENT;
$importance = IMPORTANCE_LOW;
break;
case 3:
default:
$priority = PRIO_NORMAL;
$importance = IMPORTANCE_NORMAL;
break;
}
mapi_setprops($mapimessage, array(PR_IMPORTANCE => $importance, PR_PRIORITY => $priority));
}
$addresses = array();
$toaddr = $ccaddr = $bccaddr = array();
$Mail_RFC822 = new Mail_RFC822();
if (isset($message->headers["to"])) {
$toaddr = $Mail_RFC822->parseAddressList($message->headers["to"]);
}
if (isset($message->headers["cc"])) {
$ccaddr = $Mail_RFC822->parseAddressList($message->headers["cc"]);
}
if (isset($message->headers["bcc"])) {
$bccaddr = $Mail_RFC822->parseAddressList($message->headers["bcc"]);
}
if (count($toaddr) == 0 && count($ccaddr) == 0 && count($bccaddr) == 0) {
debugLog("Sendmail: Message has got no recipients (no to, no cc and no bcc!)");
return 119;
}
// Add recipients
$recips = array();
if (isset($toaddr)) {
foreach (array(MAPI_TO => $toaddr, MAPI_CC => $ccaddr, MAPI_BCC => $bccaddr) as $type => $addrlist) {
foreach ($addrlist as $addr) {
$mapirecip[PR_ADDRTYPE] = "SMTP";
$mapirecip[PR_EMAIL_ADDRESS] = $addr->mailbox . "@" . $addr->host;
if (isset($addr->personal) && strlen($addr->personal) > 0) {
$mapirecip[PR_DISPLAY_NAME] = u2w($mimeObject->_decodeHeader($addr->personal));
} else {
$mapirecip[PR_DISPLAY_NAME] = $mapirecip[PR_EMAIL_ADDRESS];
}
$mapirecip[PR_RECIPIENT_TYPE] = $type;
$mapirecip[PR_ENTRYID] = mapi_createoneoff($mapirecip[PR_DISPLAY_NAME], $mapirecip[PR_ADDRTYPE], $mapirecip[PR_EMAIL_ADDRESS]);
array_push($recips, $mapirecip);
}
}
}
mapi_message_modifyrecipients($mapimessage, 0, $recips);
// Loop through message subparts.
$body = "";
$body_html = "";
if ($message->ctype_primary == "multipart" && ($message->ctype_secondary == "signed" || $message->ctype_secondary == "mixed" || $message->ctype_secondary == "alternative")) {
$mparts = $message->parts;
for ($i = 0; $i < count($mparts); $i++) {
$part = $mparts[$i];
// palm pre & iPhone send forwarded messages in another subpart which are also parsed
if ($part->ctype_primary == "multipart" && ($part->ctype_secondary == "mixed" || $part->ctype_secondary == "alternative" || $part->ctype_secondary == "related")) {
foreach ($part->parts as $spart) {
$mparts[] = $spart;
}
continue;
}
// standard body
if ($part->ctype_primary == "text" && $part->ctype_secondary == "plain" && isset($part->body) && (!isset($part->disposition) || $part->disposition != "attachment")) {
$body .= u2w($part->body);
// assume only one text body
} elseif ($part->ctype_primary == "text" && $part->ctype_secondary == "html") {
$body_html .= u2w($part->body);
} elseif ($part->ctype_primary == "ms-tnef" || $part->ctype_secondary == "ms-tnef") {
$zptnef = new ZPush_tnef($this->_defaultstore);
$mapiprops = array();
$zptnef->extractProps($part->body, $mapiprops);
//.........这里部分代码省略.........
示例3: process_header_encoding
private function process_header_encoding($encode)
{
$use_fallback = FALSE;
if (extension_loaded('mbstring')) {
$t_encode = $encode;
// Code based on mimedecode function _decodeHeader
$encoded_words_regex = "/(=\\?([^?]+)\\?(q|b)\\?([^?]*)\\?=)/i";
while (preg_match($encoded_words_regex, $t_encode, $matches)) {
$encoded = $matches[1];
$charset = $matches[2];
$encoding = $matches[3];
$text = $matches[4];
// Process unsupported fallback charsets
if (isset($this->_mb_list_encodings[strtolower($charset)]) && isset($this->_mbstring_unsupportedcharsets[strtolower($charset)]) && $this->_mb_list_encodings[strtolower($charset)] === $this->_mbstring_unsupportedcharsets[strtolower($charset)]) {
$charset = $this->_mb_list_encodings[strtolower($charset)];
}
// Process unsupported charsets
if (!isset($this->_mb_list_encodings[strtolower($charset)])) {
echo "\n" . 'Message: Charset not supported: ' . $charset . "\n";
$charset = $this->_fallback_charset;
}
// mb_decode_mimeheader leaves underscores where there should be spaces incase of quoted-printable mimeheaders. Applying workaround.
if (strtolower($encoding) === 'q') {
$text = str_replace('_', ' ', $text);
}
$encode_part = mb_decode_mimeheader('=?' . $charset . '?' . $encoding . '?' . $text . '?=');
$t_encode = str_replace($encoded, $encode_part, $t_encode);
}
// If any encoded-words are left then mb_decode_mimeheader did not work as intended. Performing fallback
if (preg_match($encoded_words_regex, $t_encode)) {
$use_fallback = TRUE;
}
}
if (!extension_loaded('mbstring') || $use_fallback === TRUE) {
$decoder = new Mail_mimeDecode(NULL);
$t_encode = $decoder->_decodeHeader($encode);
if (extension_loaded('mbstring') && $use_fallback === TRUE) {
// Destroying invalid characters and possibly valid utf8 characters incase of a fallback situation
$t_encode = $this->process_body_encoding($t_encode, $this->_fallback_charset);
}
}
return $t_encode;
}
示例4:
<?php
include_once 'lib/utils/utils.php';
include_once 'lib/core/zpushdefs.php';
include_once 'lib/core/zlog.php';
include_once 'include/z_RFC822.php';
include_once 'include/mimeDecode.php';
define('LOGLEVEL', LOGLEVEL_DEBUG);
define('LOGUSERLEVEL', LOGLEVEL_DEVICEID);
$encoded_from = '=?utf-8?Q?"Jo=C3=ABl_P."?= <joel@a.domain.fr>';
printf("Encoded from [%s]\n", $encoded_from);
$mimeDecode = new Mail_mimeDecode();
$decoded_from = $mimeDecode->_decodeHeader($encoded_from);
printf("Decoded from [%s]\n", $decoded_from);
$Mail_RFC822 = new Mail_RFC822();
$parsed = $Mail_RFC822->parseAddressList($decoded_from);
printf("Empty if wrong email address\n");
print_r($parsed);
示例5: embedICal
/**
* Clean up iCal messages from Outlook.
*
* @param string $fqhostname The name of this host.
* @param string $sender The mail address of the sender.
* @param array $recipients The recipients of the message.
* @param string $origfrom The mail address of the original sender.
* @param string $subject The mail subject.
* @param string $tmpfname Path to the temporary message store.
*
* @return boolena|PEAR_Error True if the message was successfully rewritten.
*/
function embedICal($fqhostname, $sender, $recipients, $origfrom, $subject, $tmpfname, $transport)
{
Horde::log(sprintf("Encapsulating iCal message forwarded by %s", $sender), 'DEBUG');
$forwardtext = "This is an invitation forwarded by outlook and\n" . "was rectified by the Kolab server.\n" . "The invitation was originally sent by\n%s.\n\n" . "Diese Einladung wurde von Outlook weitergeleitet\n" . "und vom Kolab-Server in gute Form gebracht.\n" . "Die Einladung wurde ursprünglich von\n%s geschickt.\n";
// Read in message text
$requestText = '';
$handle = @fopen($tmpfname, "r");
if ($handle === false) {
$msg = $php_errormsg;
return PEAR::raiseError(sprintf("Error: Could not open %s for writing: %s", $tmpfname, $msg), OUT_LOG | EX_IOERR);
}
while (!feof($handle)) {
$requestText .= fread($handle, 8192);
}
fclose($handle);
// Parse existing message
list($headers, $mime) = Kolab_Filter_Outlook::_mimeParse($requestText);
$parts = $mime->contentTypeMap();
if (count($parts) != 1 || $parts[1] != 'text/calendar') {
Horde::log("Message does not contain exactly one toplevel text/calendar part, passing through.", 'DEBUG');
return false;
}
$basepart = $mime->getBasePart();
// Construct new MIME message with original message attached
$toppart = new MIME_Message();
$dorigfrom = Mail_mimeDecode::_decodeHeader($origfrom);
$textpart = new MIME_Part('text/plain', sprintf($forwardtext, $dorigfrom, $dorigfrom), 'UTF-8');
$ical_txt = $basepart->transferDecode();
Kolab_Filter_Outlook::_addOrganizer($ical_txt, $dorigfrom);
$msgpart = new MIME_Part($basepart->getType(), Kolab_Filter_Outlook::_recodeToAscii($ical_txt), $basepart->getCharset());
$toppart->addPart($textpart);
$toppart->addPart($msgpart);
// Build the reply headers.
$msg_headers = new MIME_Headers();
Kolab_Filter_Outlook::_copyHeader('Received', $msg_headers, $headers);
//$msg_headers->addReceivedHeader();
$msg_headers->addMessageIdHeader();
Kolab_Filter_Outlook::_copyHeader('Date', $msg_headers, $headers);
Kolab_Filter_Outlook::_copyHeader('Resent-Date', $msg_headers, $headers);
Kolab_Filter_Outlook::_copyHeader('Subject', $msg_headers, $headers);
$msg_headers->addHeader('From', $sender);
$msg_headers->addHeader('To', join(', ', $recipients));
$msg_headers->addHeader('X-Kolab-Forwarded', 'TRUE');
$msg_headers->addMIMEHeaders($toppart);
Kolab_Filter_Outlook::_copyHeader('Content-Transfer-Encoding', $msg_headers, $headers);
if (is_object($msg_headers)) {
$headerArray = $toppart->encode($msg_headers->toArray(), $toppart->getCharset());
} else {
$headerArray = $toppart->encode($msg_headers, $toppart->getCharset());
}
return Kolab_Filter_Outlook::_inject($toppart, $recipients, $msg_headers, $sender, $transport);
}