当前位置: 首页>>代码示例>>PHP>>正文


PHP Mail_mimeDecode::getSendArray方法代码示例

本文整理汇总了PHP中Mail_mimeDecode::getSendArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Mail_mimeDecode::getSendArray方法的具体用法?PHP Mail_mimeDecode::getSendArray怎么用?PHP Mail_mimeDecode::getSendArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mail_mimeDecode的用法示例。


在下文中一共展示了Mail_mimeDecode::getSendArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateOrCreateEmail

 function updateOrCreateEmail($part = '', $opts, $cm = false)
 {
     // DB_DataObject::debugLevel(1);
     $template_name = preg_replace('/\\.[a-z]+$/i', '', basename($opts['file']));
     if (!file_exists($opts['file'])) {
         $this->jerr("file does not exist : " . $opts['file']);
     }
     if (!empty($opts['master']) && !file_exists($opts['master'])) {
         $this->jerr("master file does not exist : " . $opts['master']);
     }
     if (empty($cm)) {
         $cm = DB_dataObject::factory('core_email');
         $ret = $cm->get('name', $template_name);
         if ($ret && empty($opts['update'])) {
             $this->jerr("use --update 1 to update the template..");
         }
     }
     $mailtext = file_get_contents($opts['file']);
     if (!empty($opts['master'])) {
         $body = $mailtext;
         $mailtext = file_get_contents($opts['master']);
         $mailtext = str_replace('{outputBody():h}', $body, $mailtext);
     }
     require_once 'Mail/mimeDecode.php';
     require_once 'Mail/RFC822.php';
     $decoder = new Mail_mimeDecode($mailtext);
     $parts = $decoder->getSendArray();
     if (is_a($parts, 'PEAR_Error')) {
         echo $parts->toString() . "\n";
         exit;
     }
     $headers = $parts[1];
     $from = new Mail_RFC822();
     $from_str = $from->parseAddressList($headers['From']);
     $from_name = trim($from_str[0]->personal, '"');
     $from_email = $from_str[0]->mailbox . '@' . $from_str[0]->host;
     if ($cm->id) {
         $cc = clone $cm;
         $cm->setFrom(array('bodytext' => $parts[2], 'updated_dt' => date('Y-m-d H:i:s')));
         $cm->update($cc);
     } else {
         $cm->setFrom(array('from_name' => $from_name, 'from_email' => $from_email, 'subject' => $headers['Subject'], 'name' => $template_name, 'bodytext' => $parts[2], 'updated_dt' => date('Y-m-d H:i:s'), 'created_dt' => date('Y-m-d H:i:s')));
         $cm->insert();
     }
     return $cm;
 }
开发者ID:roojs,项目名称:Pman.Core,代码行数:46,代码来源:Core_email.php

示例2: SendMail

 /**
  * Sends an e-mail
  * This messages needs to be saved into the 'sent items' folder
  *
  * @param SyncSendMail  $sm     SyncSendMail object
  *
  * @access public
  * @return boolean
  * @throws StatusException
  */
 public function SendMail($sm)
 {
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->SendMail(): RFC822: %d bytes  forward-id: '%s' reply-id: '%s' parent-id: '%s' SaveInSent: '%s' ReplaceMIME: '%s'", strlen($sm->mime), Utils::PrintAsString($sm->forwardflag ? isset($sm->source->itemid) ? $sm->source->itemid : "error no itemid" : false), Utils::PrintAsString($sm->replyflag ? isset($sm->source->itemid) ? $sm->source->itemid : "error no itemid" : false), Utils::PrintAsString(isset($sm->source->folderid) ? $sm->source->folderid : false), Utils::PrintAsString($sm->saveinsent), Utils::PrintAsString(isset($sm->replacemime))));
     // by splitting the message in several lines we can easily grep later
     foreach (preg_split("/((\r)?\n)/", $sm->mime) as $rfc822line) {
         ZLog::Write(LOGLEVEL_WBXML, "RFC822: " . $rfc822line);
     }
     $sourceMessage = $sourceMail = false;
     // If we have a reference to a source message and we are not replacing mime (since we wouldn't use it)
     if (isset($sm->source->folderid) && isset($sm->source->itemid) && (!isset($sm->replacemime) || $sm->replacemime === false)) {
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->SendMail(): We have a source message and we try to fetch it"));
         $parent = $this->getImapIdFromFolderId($sm->source->folderid);
         if ($parent === false) {
             throw new StatusException(sprintf("BackendIMAP->SendMail(): Could not get imapid from source folderid '%'", $sm->source->folderid), SYNC_COMMONSTATUS_ITEMNOTFOUND);
         } else {
             $this->imap_reopen_folder($parent);
             $sourceMail = @imap_fetchheader($this->mbox, $sm->source->itemid, FT_UID) . @imap_body($this->mbox, $sm->source->itemid, FT_PEEK | FT_UID);
             $mobj = new Mail_mimeDecode($sourceMail);
             $sourceMessage = $mobj->decode(array('decode_headers' => false, 'decode_bodies' => true, 'include_bodies' => true, 'rfc_822bodies' => true, 'charset' => 'utf-8'));
             unset($mobj);
             //We will need $sourceMail if the message is forwarded and not inlined
             // If it's a reply, we mark the original message as answered
             if ($sm->replyflag) {
                 if (!@imap_setflag_full($this->mbox, $sm->source->itemid, "\\Answered", ST_UID)) {
                     ZLog::Write(LOGLEVEL_WARN, sprintf("BackendIMAP->SendMail(): Unable to mark the message as Answered"));
                 }
             }
             // If it's a forward, we mark the original message as forwarded
             if ($sm->forwardflag) {
                 if (!@imap_setflag_full($this->mbox, $sm->source->itemid, "\\Forwarded", ST_UID)) {
                     ZLog::Write(LOGLEVEL_WARN, sprintf("BackendIMAP->SendMail(): Unable to mark the message as Forwarded"));
                 }
             }
         }
     }
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->SendMail(): We get the new message"));
     $mobj = new Mail_mimeDecode($sm->mime);
     $message = $mobj->decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'rfc_822bodies' => true, 'charset' => 'utf-8'));
     unset($mobj);
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->SendMail(): We get the From and To"));
     $Mail_RFC822 = new Mail_RFC822();
     $toaddr = "";
     $this->setFromHeaderValue($message->headers);
     $fromaddr = $this->parseAddr($Mail_RFC822->parseAddressList($message->headers["from"]));
     if (isset($message->headers["to"])) {
         $toaddr = $this->parseAddr($Mail_RFC822->parseAddressList($message->headers["to"]));
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->SendMail(): To defined: %s", $toaddr));
     }
     unset($Mail_RFC822);
     // overwrite CC and BCC with the decoded versions, because we will parse/validate the address in the sending method
     if (isset($message->headers["cc"])) {
         $message->headers["cc"] = $message->headers["cc"];
     }
     if (isset($message->headers["bcc"])) {
         $message->headers["bcc"] = $message->headers["bcc"];
     }
     $this->setReturnPathValue($message->headers, $fromaddr);
     $finalBody = "";
     $finalHeaders = array();
     // if it's a S/MIME message I don't do anything with it
     if (is_smime($message)) {
         $mobj = new Mail_mimeDecode($sm->mime);
         $parts = $mobj->getSendArray();
         unset($mobj);
         if ($parts === false) {
             throw new StatusException(sprintf("BackendIMAP->SendMail(): Could not getSendArray for SMIME messages"), SYNC_COMMONSTATUS_MAILSUBMISSIONFAILED);
         } else {
             list($recipients, $finalHeaders, $finalBody) = $parts;
             $this->setFromHeaderValue($finalHeaders);
             $this->setReturnPathValue($finalHeaders, $fromaddr);
         }
     } else {
         //http://pear.php.net/manual/en/package.mail.mail-mime.example.php
         //http://pear.php.net/manual/en/package.mail.mail-mimedecode.decode.php
         //http://pear.php.net/manual/en/package.mail.mail-mimepart.addsubpart.php
         // I don't mind if the new message is multipart or not, I always will create a multipart. It's simpler
         $finalEmail = new Mail_mimePart('', array('content_type' => 'multipart/mixed'));
         if ($sm->replyflag && (!isset($sm->replacemime) || $sm->replacemime === false)) {
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->SendMail(): Replying message"));
             $this->addTextParts($finalEmail, $message, $sourceMessage, true);
             if (isset($message->parts)) {
                 // We add extra parts from the replying message
                 add_extra_sub_parts($finalEmail, $message->parts);
             }
             // A replied message doesn't include the original attachments
         } else {
             if ($sm->forwardflag && (!isset($sm->replacemime) || $sm->replacemime === false)) {
                 if (!defined('IMAP_INLINE_FORWARD') || IMAP_INLINE_FORWARD === false) {
                     ZLog::Write(LOGLEVEL_DEBUG, "BackendIMAP->SendMail(): Forwarding message as attached file - eml");
                     $finalEmail->addSubPart($sourceMail, array('content_type' => 'message/rfc822', 'encoding' => 'base64', 'disposition' => 'attachment', 'dfilename' => 'forwarded_message.eml'));
//.........这里部分代码省略.........
开发者ID:peterbeck,项目名称:Z-Push-contrib,代码行数:101,代码来源:imap.php

示例3: buildMail

 /**
  *
  *
  *
  *
  *  FIXME !!!! -- USE Pman_Core_Mailer !!!!!
  *
  *
  *
  *  
  */
 function buildMail($templateFile, $args)
 {
     $args = (array) $args;
     $content = clone $this;
     foreach ((array) $args as $k => $v) {
         $content->{$k} = $v;
     }
     $ff = HTML_FlexyFramework::get();
     //?? is this really the place for this???
     if (!$ff->cli && empty($args['no_auth']) && !in_array($templateFile, array('password_reset', 'password_welcome'))) {
         $content->authUser = $this->getAuthUser();
         if (!$content->authUser) {
             return PEAR::raiseError("Not authenticated");
         }
     }
     // should handle x-forwarded...
     $content->HTTP_HOST = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : (isset($ff->HTTP_HOST) ? $ff->HTTP_HOST : 'localhost');
     /* use the regex compiler, as it doesnt parse <tags */
     $tops = array('compiler' => 'Flexy', 'nonHTML' => true, 'filters' => array('SimpleTags', 'Mail'));
     if (!empty($args['templateDir'])) {
         $tops['templateDir'] = $args['templateDir'];
     }
     require_once 'HTML/Template/Flexy.php';
     $template = new HTML_Template_Flexy($tops);
     $template->compile("mail/{$templateFile}.txt");
     /* use variables from this object to ouput data. */
     $mailtext = $template->bufferedOutputObject($content);
     $htmlbody = false;
     // if a html file with the same name exists, use that as the body
     // I've no idea where this code went, it was here before..
     if (false !== $template->resolvePath("mail/{$templateFile}.html")) {
         $tops['nonHTML'] = false;
         $template = new HTML_Template_Flexy($tops);
         $template->compile("mail/{$templateFile}.html");
         $htmlbody = $template->bufferedOutputObject($content);
     }
     //echo "<PRE>";print_R($mailtext);
     //print_R($mailtext);exit;
     /* With the output try and send an email, using a few tricks in Mail_MimeDecode. */
     require_once 'Mail/mimeDecode.php';
     require_once 'Mail.php';
     $decoder = new Mail_mimeDecode($mailtext);
     $parts = $decoder->getSendArray();
     if (PEAR::isError($parts)) {
         return $parts;
         //echo "PROBLEM: {$parts->message}";
         //exit;
     }
     list($recipents, $headers, $body) = $parts;
     $recipents = array($this->email);
     if (!empty($content->bcc) && is_array($content->bcc)) {
         $recipents = array_merge($recipents, $content->bcc);
     }
     $headers['Date'] = date('r');
     if ($htmlbody !== false) {
         require_once 'Mail/mime.php';
         $mime = new Mail_mime(array('eol' => "\n"));
         $mime->setTXTBody($body);
         $mime->setHTMLBody($htmlbody);
         // I think there might be code in mediaoutreach toEmail somewhere
         // h embeds images here..
         $body = $mime->get();
         $headers = $mime->headers($headers);
     }
     return array('recipients' => $recipents, 'headers' => $headers, 'body' => $body);
 }
开发者ID:roojs,项目名称:Pman.Core,代码行数:77,代码来源:Core_person.php

示例4: toData

 /**
  * ---------------- Global Tools ---------------   
  */
 function toData()
 {
     $templateFile = $this->template;
     $args = (array) $this->contents;
     $content = clone $this->page;
     foreach ($args as $k => $v) {
         $content->{$k} = $v;
     }
     $content->msgid = empty($content->msgid) ? md5(time() . rand()) : $content->msgid;
     $ff = HTML_FlexyFramework::get();
     $http_host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : 'pman.HTTP_HOST.not.set';
     if (isset($ff->Pman['HTTP_HOST'])) {
         $http_host = $ff->Pman['HTTP_HOST'];
     }
     $content->HTTP_HOST = $http_host;
     // this should be done by having multiple template sources...!!!
     require_once 'HTML/Template/Flexy.php';
     $tmp_opts = array('site_prefix' => false);
     if (!empty($this->templateDir)) {
         $tmp_opts['templateDir'] = $this->templateDir;
     }
     $fopts = HTML_FlexyFramework::get()->HTML_Template_Flexy;
     if (!empty($fopts['DB_DataObject_translator'])) {
         $tmp_opts['DB_DataObject_translator'] = $fopts['DB_DataObject_translator'];
     }
     if (!empty($fopts['locale'])) {
         $tmp_opts['locale'] = $fopts['locale'];
     }
     // local opt's overwrite
     if (!empty($this->locale)) {
         $tmp_opts['locale'] = $this->locale;
     }
     $htmlbody = false;
     $html_tmp_opts = $tmp_opts;
     $htmltemplate = new HTML_Template_Flexy($html_tmp_opts);
     if (is_string($htmltemplate->resolvePath('mail/' . $templateFile . '.body.html'))) {
         // then we have a multi-part email...
         if (!empty($this->html_locale)) {
             $html_tmp_opts['locale'] = $this->html_locale;
         }
         $htmltemplate = new HTML_Template_Flexy($html_tmp_opts);
         $htmltemplate->compile('mail/' . $templateFile . '.body.html');
         $htmlbody = $htmltemplate->bufferedOutputObject($content);
         $this->htmlbody = $htmlbody;
         // for the html body, we may want to convert the attachments to images.
         //            var_dump($htmlbody);exit;
         if ($this->replaceImages) {
             $htmlbody = $this->htmlbodytoCID($htmlbody);
         }
         if ($this->css_embed) {
             $htmlbody = $this->htmlbodyCssEmbed($htmlbody);
         }
     }
     $tmp_opts['nonHTML'] = true;
     //print_R($tmp_opts);
     // $tmp_opts['force'] = true;
     $template = new HTML_Template_Flexy($tmp_opts);
     $template->compile('mail/' . $templateFile . '.txt');
     /* use variables from this object to ouput data. */
     $mailtext = $template->bufferedOutputObject($content);
     //print_r($mailtext);exit;
     //echo "<PRE>";print_R($mailtext);
     /* With the output try and send an email, using a few tricks in Mail_MimeDecode. */
     require_once 'Mail/mimeDecode.php';
     require_once 'Mail.php';
     $decoder = new Mail_mimeDecode($mailtext);
     $parts = $decoder->getSendArray();
     if (PEAR::isError($parts)) {
         return $parts;
         //echo "PROBLEM: {$parts->message}";
         //exit;
     }
     $isMime = false;
     require_once 'Mail/mime.php';
     $mime = new Mail_mime(array('eol' => "\n", 'html_charset' => 'utf-8', 'text_charset' => 'utf-8', 'head_charset' => 'utf-8'));
     // clean up the headers...
     $parts[1]['Message-Id'] = '<' . $content->msgid . '@' . $content->HTTP_HOST . '>';
     if ($htmlbody !== false) {
         // got a html headers...
         if (isset($parts[1]['Content-Type'])) {
             unset($parts[1]['Content-Type']);
         }
         $mime->setTXTBody($parts[2]);
         $mime->setHTMLBody($htmlbody);
         //            var_dump($mime);exit;
         foreach ($this->images as $cid => $cdata) {
             $mime->addHTMLImage($cdata['file'], $cdata['mimetype'], $cid . '.' . $cdata['ext'], true, $cdata['contentid']);
         }
         $isMime = true;
     }
     if (!empty($this->attachments)) {
         //if got a attachments
         $header = $mime->headers($parts[1]);
         if (isset($parts[1]['Content-Type'])) {
             unset($parts[1]['Content-Type']);
         }
         if (!$isMime) {
//.........这里部分代码省略.........
开发者ID:roojs,项目名称:Pman.Core,代码行数:101,代码来源:Mailer.php

示例5: printf

<?php

require_once 'include/mimeDecode.php';
$mailtext = file_get_contents("testing/samples/messages/smime001.txt");
$decoder = new Mail_mimeDecode($mailtext);
$parts = $decoder->getSendArray();
if ($parts === false) {
    printf("ERROR splitting message\n");
} else {
    list($recipents, $headers, $body) = $parts;
    printf("RECIPIENTS\n");
    print_r($recipents);
    printf("\nHEADERS\n");
    print_r($headers);
    printf("\nBODY\n");
    print_r($body);
    printf("\n");
    //$mail = Mail::factory('smtp');
    //$mail->send($recipents,$headers,$body);
}
开发者ID:alanturing1,项目名称:Z-Push-contrib,代码行数:20,代码来源:testing-mime-split.php


注:本文中的Mail_mimeDecode::getSendArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。