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


PHP Mail_mimeDecode类代码示例

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


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

示例1: GetMessage

 function GetMessage($message_id, $external_id = 0)
 {
     if (!isset($this->_messageCash[$message_id])) {
         $raw_message = $this->_pop3->getMsg($message_id);
         require_once SYS . '/system/class/email/mime/mimeDecode.php';
         $params['include_bodies'] = true;
         $params['decode_bodies'] = true;
         $params['decode_headers'] = true;
         $decoder = new Mail_mimeDecode($raw_message);
         $msg = $decoder->decode($params);
         //				Dump($msg, true);
         $msg->external_id = $external_id;
         if (isset($msg->headers['date'])) {
             $msg->Moment = strtotime($msg->headers['date']);
         } else {
             $msg->Moment = 0;
         }
         $msg = $this->ProcessMessageBody($msg);
         if (strtoupper($msg->charset) == 'KOI8-R') {
             $msg->body = convert_cyr_string($msg->body, 'koi8-r', 'Windows-1251');
             $msg->headers['subject'] = convert_cyr_string($msg->headers['subject'], 'koi8-r', 'Windows-1251');
             $msg->charset = 'Windows-1251';
         }
         $this->_messageCash[$message_id] = $msg;
         $this->got_inner_body = null;
     }
     return $this->_messageCash[$message_id];
 }
开发者ID:juliogallardo1326,项目名称:proc,代码行数:28,代码来源:nsemail.class.php

示例2: testMimeDecode

function testMimeDecode($file, $new_file)
{
    if (!defined('LOGLEVEL')) {
        define('LOGLEVEL', LOGLEVEL_DEBUG);
    }
    if (!defined('LOGUSERLEVEL')) {
        define('LOGUSERLEVEL', LOGLEVEL_DEVICEID);
    }
    printf("TEST MIME DECODE\n");
    $mobj = new Mail_mimeDecode(file_get_contents($file));
    $message = $mobj->decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'charset' => 'utf-8'));
    $handle = fopen($new_file, "w");
    fwrite($handle, build_mime_message($message));
    fclose($handle);
    foreach ($message->headers as $k => $v) {
        if (is_array($v)) {
            foreach ($v as $vk => $vv) {
                printf("Header <%s> <%s> <%s>\n", $k, $vk, $vv);
            }
        } else {
            printf("Header <%s> <%s>\n", $k, $v);
        }
    }
    $text = $html = "";
    Mail_mimeDecode::getBodyRecursive($message, "plain", $text);
    Mail_mimeDecode::getBodyRecursive($message, "html", $html);
    printf("TEXT Body <%s>\n", $text);
    printf("HTML Body <%s>\n", $html);
}
开发者ID:SvKn,项目名称:Z-Push-contrib,代码行数:29,代码来源:testing-mime-mail-parse.php

示例3: execute

 /**
  * メール受信時の処理
  * 
  * @access public
  * @author sakuragawa
  */
 function execute()
 {
     ini_set('memory_limit', -1);
     // 前処理
     $this->beforefilter();
     // メールの読み込み
     $source = file_get_contents("php://stdin");
     if (empty($source)) {
         return;
     }
     // \nをつけてるのは、そのままだとSoftbankの空メールが取得できなかったから
     $source .= "\n";
     $this->hookMail($source);
     // メールをデコード
     //$this->out($this->params2);
     $Decoder = new Mail_mimeDecode($source);
     $mail = $Decoder->decode($this->mailMimeDecodeParams);
     // Fromを取得
     $from = $this->_parseAddress($mail, 'from');
     $this->hookFromAddress($from);
     // Toを取得
     $to = $this->_parseAddress($mail, 'to');
     $this->hookToAddress($to);
     // 本文・添付等をパース
     $this->_parseBody($mail);
     $this->afterfilter();
     // Toを取得
     /*$to = $this->_getTo($mail);
       $this->getTo($to);*/
 }
开发者ID:kozo,项目名称:harpy,代码行数:36,代码来源:harpy.php

示例4: transport_email_receive

function transport_email_receive($pMsg)
{
    global $gBitUser, $gBitSystem;
    // prolly dont need this
    // $connectionString = '{'.$gBitSystem->getConfig('transport_email_server','imap').':'.$gBitSystem->getConfig('transport_email_port','993').'/'.$gBitSystem->getConfig('transport_email_protocol','imap').'/ssl/novalidate-cert}';
    // Parse msg - get header, body, attachments, to, from, reply header
    if (include_once 'PEAR.php') {
        if (require_once 'Mail/mimeDecode.php') {
            $params['include_bodies'] = true;
            $params['decode_bodies'] = true;
            $params['decode_headers'] = true;
            $decoder = new Mail_mimeDecode($pMsg);
            if ($data = $decoder->decode($params)) {
                if ($handler($data)) {
                    transport_email_expunge($pMsg);
                }
            } else {
                //error
            }
        } else {
            //error
        }
    } else {
        //error
    }
}
开发者ID:bitweaver,项目名称:switchboard,代码行数:26,代码来源:transport.php

示例5: parse

 public function parse($input)
 {
     $decoder = new Mail_mimeDecode($input, "\r\n");
     $structure = $decoder->decode(array('include_bodies' => true, 'decode_bodies' => true));
     $raw_mail = (array) $structure;
     $raw_mail['body'] = $this->getBody($structure);
     return $raw_mail;
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:8,代码来源:Parser.class.php

示例6: decodeEmail

function decodeEmail($input)
{
    $params['include_bodies'] = true;
    $params['decode_bodies'] = true;
    $params['decode_headers'] = true;
    $decoder = new Mail_mimeDecode($input);
    $structure = $decoder->decode($params);
    return $structure;
}
开发者ID:jeremy-cayrasso,项目名称:dtc,代码行数:9,代码来源:support-receive.php

示例7: process

 public function process()
 {
     $this->init();
     ini_set('memory_limit', -1);
     $debug = app()->request->getParam('debug');
     $params = [];
     //SUPPLIER_PRICES_DIR
     $incoming = $debug ? file_get_contents($this->_rootPath . DS . "eml" . DS . "test.eml") : app()->request->getParam('@letter');
     if (!$incoming) {
         $this->log('не корректное получение письма', true);
     }
     $params = ['include_bodies' => true, 'decode_bodies' => true, 'decode_headers' => true];
     $decoder = new Mail_mimeDecode($incoming);
     $result = $decoder->decode($params);
     preg_match_all('/\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+/', $result->headers["from"], $matches);
     $mail = $matches[0];
     //array with from emails
     if (!$mail) {
         $this->log("не установлен отправитель письма от {$result->headers['from']}", true);
     }
     $this->email = $mail[0];
     // временный тестовый лог
     if (isset($result->headers["subject"]) && is_array($result->headers["subject"])) {
         $this->log("ОШИБКА в ParseLetter-e \nДата: " . CJSON::encode($result), true);
     }
     // Пример: Subject: [supplierId 9255]
     if (isset($result->headers["subject"]) && strpos($result->headers["subject"], 'supplierId') !== false) {
         $subject = $result->headers["subject"];
         preg_match_all('/\\[.*?(\\d+)\\]/i', $subject, $matches);
         $idSupplier = $matches[1][0];
     } else {
         $query = app()->db->createCommand()->select('id_supplier, email')->from('supplier_email c')->join('supplier s', 'c.id_supplier = s.id')->where('email = "' . $this->email . '"')->andWhere('follow_manual = 1')->queryRow();
         $idSupplier = $query['id_supplier'];
     }
     if (!$idSupplier) {
         // $this->log("{$this->email} :: не установлен поставщик или для поставщика отключена настройка 'Следить вручную'", true); //временно выключаем
         Yii::app()->end();
     }
     $this->idSupplier = trim($idSupplier);
     $this->_destFileDir = $this->_rootPath . $this->idSupplier . DS . 'new';
     File::checkPermissions($this->_destFileDir);
     setlocale(LC_ALL, 'ru_RU.UTF8');
     if (isset($result->parts)) {
         foreach ($result->parts as $key => $part) {
             if ($part->ctype_primary == 'multipart') {
                 foreach ($part->parts as $k => $v) {
                     $this->mainProccess($v);
                 }
             } else {
                 $this->mainProccess($part);
             }
         }
     }
 }
开发者ID:amanukian,项目名称:test,代码行数:54,代码来源:ParseLetter.php

示例8: decode

 function decode()
 {
     $params = array('crlf' => "\r\n", 'input' => $this->mime_message, 'include_bodies' => $this->include_bodies, 'decode_headers' => $this->decode_headers, 'decode_bodies' => $this->decode_bodies);
     $this->splitBodyHeader();
     $this->struct = Mail_mimeDecode::decode($params);
     return PEAR::isError($this->struct) || !(count($this->struct->headers) > 1) ? FALSE : TRUE;
 }
开发者ID:supaket,项目名称:helpdesk,代码行数:7,代码来源:class.mailparse.php

示例9: processemail

 public static function processemail($emailsrc, $pdfout, $coverfile = '')
 {
     $combfilelist = array();
     # Process the email
     $emailparts = Mail_mimeDecode::decode(array('include_bodies' => true, 'decode_bodies' => true, 'decode_headers' => true, 'input' => file_get_contents($emailsrc), 'crlf' => "\r\n"));
     # Process the cover if it exists
     if ($coverfile !== '') {
         $combfilelist[] = self::processpart(file_get_contents($coverfile), mime_content_type($coverfile));
     }
     # Process the parts
     $combfilelist = array_merge($combfilelist, self::processparts($emailparts));
     # Create an intermediate file to build the pdf
     $tmppdffilename = sys_get_temp_dir() . '/e2p-' . (string) abs((int) (microtime(true) * 100000)) . '.pdf';
     # Build the command to combine all of the intermediate files into one
     $conbcom = str_replace(array_merge(array('INTFILE', 'COMBLIST'), array_keys(self::$driver_paths)), array_merge(array($tmppdffilename, implode(' ', $combfilelist)), array_values(self::$driver_paths)), self::$mime_drivers['gs']);
     exec($conbcom);
     # Remove the intermediate files
     foreach ($combfilelist as $combfilename) {
         unlink($combfilename);
     }
     # Write the intermediate file to the final destination
     $intfileres = fopen($tmppdffilename, 'rb');
     $outfileres = fopen($pdfout, 'ab');
     while (!feof($intfileres)) {
         fwrite($outfileres, fread($intfileres, 8192));
     }
     fclose($intfileres);
     fclose($outfileres);
     # Remove the intermediate file
     unlink($tmppdffilename);
 }
开发者ID:swk,项目名称:bluebox,代码行数:31,代码来源:emailtopdf.php

示例10: decode

 /**
  * メールをデコード
  *
  * @access public
  * @param string メールの生データ
  */
 function decode($raw_mail)
 {
     $params['include_bodies'] = true;
     $params['decode_bodies'] = true;
     $params['decode_headers'] = true;
     $params['input'] = $raw_mail;
     $this->mail =& Mail_mimeDecode::decode($params);
 }
开发者ID:KimuraYoichi,项目名称:PukiWiki,代码行数:14,代码来源:KtaiMail.php

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

示例12: parse

 public function parse($raw)
 {
     $this->raw = $raw;
     // http://pear.php.net/manual/en/package.mail.mail-mimedecode.decode.php
     $decoder = new Mail_mimeDecode($this->raw);
     $this->decoded = $decoder->decode(['decode_headers' => true, 'include_bodies' => true, 'decode_bodies' => true]);
     $this->from = mb_convert_encoding($this->decoded->headers['from'], $this->charset, $this->charset);
     $this->to = mb_convert_encoding($this->decoded->headers['to'], $this->charset, $this->charset);
     $this->subject = mb_convert_encoding($this->decoded->headers['subject'], $this->charset, $this->charset);
     $this->date = mb_convert_encoding($this->decoded->headers['date'], $this->charset, $this->charset);
     $this->from_email = preg_replace('/.*<(.*)>.*/', "\$1", $this->from);
     if (isset($this->decoded->parts) && is_array($this->decoded->parts)) {
         foreach ($this->decoded->parts as $idx => $body_part) {
             $this->decode_part($body_part);
         }
     }
     if (isset($this->decoded->disposition) && $this->decoded->disposition == 'inline') {
         $mime_type = "{$this->decoded->ctype_primary}/{$this->decoded->ctype_secondary}";
         if (isset($this->decoded->d_parameters) && array_key_exists('filename', $this->decoded->d_parameters)) {
             $filename = $this->decoded->d_parameters['filename'];
         } else {
             $filename = 'file';
         }
         if ($this->is_valid_attachment($mime_type)) {
             $this->save_attachment($filename, $this->decoded->body, $mime_type);
         }
         $this->body = "";
     }
     // We might also have uuencoded files. Check for those.
     if (empty($this->body)) {
         $this->body = isset($this->decoded->body) ? $this->decoded->body : "";
     }
     if (preg_match("/begin ([0-7]{3}) (.+)\r?\n(.+)\r?\nend/Us", $this->body) > 0) {
         foreach ($decoder->uudecode($this->body) as $file) {
             // $file = [ 'filename' => $filename, 'fileperm' => $fileperm, 'filedata' => $filedata ]
             $this->save_attachment($file['filename'], $file['filedata']);
         }
         // Strip out all the uuencoded attachments from the body
         while (preg_match("/begin ([0-7]{3}) (.+)\r?\n(.+)\r?\nend/Us", $this->body) > 0) {
             $this->body = preg_replace("/begin ([0-7]{3}) (.+)\r?\n(.+)\r?\nend/Us", "\n", $this->body);
         }
     }
     $this->body = mb_convert_encoding($this->body, $this->charset, $this->charset);
     return $this;
 }
开发者ID:optimumweb,项目名称:php-email-reader-parser,代码行数:45,代码来源:email_parser.php

示例13: MoblogRequest

 function MoblogRequest($request)
 {
     $this->Object();
     $this->_message = $request["message"];
     // it is possible to specify a default user id in the POSTed email message via
     // curl, so that the amount of stuff that we need to type in the email is reduced
     // to only the user password. This basically means that email addresses configured to be used
     // by a default user and blog id cannot be used as 'gateways'
     $this->_blogId = $request["blogId"];
     $this->_user = $request["user"];
     MoblogLogger::log("From REQUEST: user = " . $this->_user . " - blogId = " . $this->_blogId);
     // parse the mime message
     $decode = new Mail_mimeDecode($this->_message, "\r\n");
     $structure = $decode->decode(array("include_bodies" => true, "decode_bodies" => true, "decode_headers" => true));
     // get the reply address, it might be in different headers
     if (isset($structure->headers['x-loop'])) {
         $this->_replyAddress = "";
     } else {
         $replyTo1 = $structure->headers['from'];
         $replyTo2 = $structure->headers['return-path'];
         $this->_replyAddress = $replyTo2 != "" ? $replyTo2 : $replyTo1;
     }
     // parse the body
     $this->parseBody($structure->body);
     $this->_inputEncoding = strtoupper($structure->ctype_parameters['charset']);
     MoblogLogger::log("There are " . count($structure->parts) . " MIME parts available to parse");
     $this->parseMimeParts($structure->parts);
     // if there was no subject specified, then let's see if there was something in the
     // 'subject' line...
     if ($this->_topic == "") {
         $this->_topic = $structure->headers['subject'];
         if ($this->_topic == "" || stristr($this->_topic, "pass:")) {
             // if there is still no subject, get the first 50 characters of the body
             $this->_topic = substr(strip_tags($this->_body), 0, 50);
             if ($this->_topic == "") {
                 $this->_topic = "No Topic";
             }
         }
     }
     MoblogLogger::Log("subject is = " . $this->_topic);
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:41,代码来源:moblogrequest.class.php

示例14: array

 function &_parseMsg(&$msg)
 {
     $arr = array();
     //Parse out attachments/HTML
     $this->_params['input'] = $msg['msg'];
     $structure = Mail_mimeDecode::decode($this->_params);
     $body = $this->_getBody($structure);
     $arr['hash'] = $this->_parseTicketID($structure->headers['subject']);
     $arr['msg'] = $this->_parseBody($body);
     $arr['mime_struct'] = $structure;
     $arr = array_merge($arr, $this->_parseFrom($structure->headers['from']));
     return $arr;
 }
开发者ID:trabisdementia,项目名称:xuups,代码行数:13,代码来源:msgParser.php

示例15: __construct

 /**
  * Constructor
  *
  * @param string                                         $content Http response
  * as string
  *
  * @param WindowsAzure\Common\Internal\Http\BatchRequest $request Source batch
  * request object
  */
 public function __construct($content, $request = null)
 {
     $params['include_bodies'] = true;
     $params['input'] = $content;
     $mimeDecoder = new \Mail_mimeDecode($content);
     $structure = $mimeDecoder->decode($params);
     $parts = $structure->parts;
     $this->_contexts = array();
     $requestContexts = null;
     if ($request != null) {
         Validate::isA($request, 'WindowsAzure\\Common\\Internal\\Http\\BatchRequest', 'request');
         $requestContexts = $request->getContexts();
     }
     $i = 0;
     foreach ($parts as $part) {
         if (!empty($part->body)) {
             $headerEndPos = strpos($part->body, "\r\n\r\n");
             $header = substr($part->body, 0, $headerEndPos);
             $body = substr($part->body, $headerEndPos + 4);
             $headerStrings = explode("\r\n", $header);
             $response = new \HTTP_Request2_Response(array_shift($headerStrings));
             foreach ($headerStrings as $headerString) {
                 $response->parseHeaderLine($headerString);
             }
             $response->appendBody($body);
             $this->_contexts[] = $response;
             if (is_array($requestContexts)) {
                 $expectedCodes = $requestContexts[$i]->getStatusCodes();
                 $statusCode = $response->getStatus();
                 if (!in_array($statusCode, $expectedCodes)) {
                     $reason = $response->getReasonPhrase();
                     throw new ServiceException($statusCode, $reason, $body);
                 }
             }
             $i++;
         }
     }
 }
开发者ID:GameWisp,项目名称:azure-sdk-for-php,代码行数:47,代码来源:BatchResponse.php


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