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


PHP mailparse_msg_parse_file函数代码示例

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


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

示例1: setPath

 /**
  * Set the file path we use to get the email text
  * @return Object MimeMailParser Instance
  * @param $mail_path Object
  */
 public function setPath($path)
 {
     // should parse message incrementally from file
     $this->resource = mailparse_msg_parse_file($path);
     $this->stream = fopen($path, 'r');
     $this->parse();
     return $this;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:13,代码来源:MimeMailParser.class.php

示例2: _parseFile

 function _parseFile($full_filename)
 {
     $logger = DevblocksPlatform::getConsoleLog();
     $fileparts = pathinfo($full_filename);
     $logger->info("[Parser] Reading " . $fileparts['basename'] . "...");
     $time = microtime(true);
     $mime = mailparse_msg_parse_file($full_filename);
     $message = CerberusParser::parseMime($mime, $full_filename);
     $time = microtime(true) - $time;
     $logger->info("[Parser] Decoded! (" . sprintf("%d", $time * 1000) . " ms)");
     //	    echo "<b>Plaintext:</b> ", $message->body,"<BR>";
     //	    echo "<BR>";
     //	    echo "<b>HTML:</b> ", htmlspecialchars($message->htmlbody), "<BR>";
     //	    echo "<BR>";
     //	    echo "<b>Files:</b> "; print_r($message->files); echo "<BR>";
     //	    echo "<HR>";
     $time = microtime(true);
     $ticket_id = CerberusParser::parseMessage($message);
     $time = microtime(true) - $time;
     $logger->info("[Parser] Parsed! (" . sprintf("%d", $time * 1000) . " ms) " . (!empty($ticket_id) ? "(Ticket ID: " . $ticket_id . ")" : "(Local Delivery Rejected.)"));
     @unlink($full_filename);
     mailparse_msg_free($mime);
     //		flush();
 }
开发者ID:rmiddle,项目名称:cerb4,代码行数:24,代码来源:cron.classes.php

示例3: parseMessage


//.........这里部分代码省略.........
         $sSubject = $headers['subject'];
         if (is_array($sSubject)) {
             $sSubject = array_shift($sSubject);
         }
     }
     // The subject can still end up empty after QP decode
     if (empty($sSubject)) {
         $sSubject = "(no subject)";
     }
     // Date
     $iDate = @strtotime($headers['date']);
     // If blank, or in the future, set to the current date
     if (empty($iDate) || $iDate > time()) {
         $iDate = time();
     }
     // Is banned?
     if (1 == $fromAddressInst->is_banned) {
         $logger->info("[Parser] Ignoring ticket from banned address: " . $fromAddressInst->email);
         return NULL;
     }
     // Overloadable
     $enumSpamTraining = '';
     // Message Id / References / In-Reply-To
     @($sMessageId = $headers['message-id']);
     $body_append_text = array();
     $body_append_html = array();
     // [mdf]Check attached files before creating the ticket because we may need to overwrite the message-id
     // also store any contents of rfc822 files so we can include them after the body
     foreach ($message->files as $filename => $file) {
         /* @var $file ParserFile */
         switch ($file->mime_type) {
             case 'message/rfc822':
                 $full_filename = $file->tmpname;
                 $mail = mailparse_msg_parse_file($full_filename);
                 $struct = mailparse_msg_get_structure($mail);
                 $msginfo = mailparse_msg_get_part_data($mail);
                 $inline_headers = $msginfo['headers'];
                 if (isset($headers['from']) && (strtolower(substr($headers['from'], 0, 11)) == 'postmaster@' || strtolower(substr($headers['from'], 0, 14)) == 'mailer-daemon@')) {
                     $headers['in-reply-to'] = $inline_headers['message-id'];
                 }
                 break;
         }
     }
     // [JAS] [TODO] References header may contain multiple message-ids to find
     if (null != ($ids = self::findParentMessage($headers))) {
         $bIsNew = false;
         $id = $ids['ticket_id'];
         $msgid = $ids['message_id'];
         // Is it a worker reply from an external client?  If so, proxy
         if (null != ($worker_address = DAO_AddressToWorker::getByAddress($fromAddressInst->email))) {
             $logger->info("[Parser] Handling an external worker response from " . $fromAddressInst->email);
             if (!DAO_Ticket::isTicketRequester($worker_address->address, $id)) {
                 // Watcher Commands [TODO] Document on wiki/etc
                 if (0 != ($matches = preg_match_all("/\\[(.*?)\\]/i", $message->headers['subject'], $commands))) {
                     @($command = strtolower(array_pop($commands[1])));
                     $logger->info("[Parser] Worker command: " . $command);
                     switch ($command) {
                         case 'close':
                             DAO_Ticket::updateTicket($id, array(DAO_Ticket::IS_CLOSED => CerberusTicketStatus::CLOSED));
                             break;
                         case 'take':
                             DAO_Ticket::updateTicket($id, array(DAO_Ticket::NEXT_WORKER_ID => $worker_address->worker_id));
                             break;
                         case 'comment':
                             $comment_id = DAO_TicketComment::create(array(DAO_TicketComment::ADDRESS_ID => $fromAddressInst->id, DAO_TicketComment::CREATED => time(), DAO_TicketComment::TICKET_ID => $id, DAO_TicketComment::COMMENT => $message->body));
                             return $id;
开发者ID:Hildy,项目名称:cerb5,代码行数:67,代码来源:Parser.php

示例4: _postSourceParseAction

 private function _postSourceParseAction($path)
 {
     $xml_in = simplexml_load_string($this->getPayload());
     @($source = (string) $xml_in->source);
     if (empty($source)) {
         $this->_error("No message source was provided.");
     }
     //echo("<pre>");print_r($source);echo("</pre>");exit();
     $file = CerberusParser::saveMimeToFile($source);
     $mime = mailparse_msg_parse_file($file);
     $message = CerberusParser::parseMime($mime, $file);
     mailparse_msg_free($mime);
     @unlink($file);
     $ticket_id = CerberusParser::parseMessage($message);
     if (null != ($ticket = DAO_Ticket::getTicket($ticket_id))) {
         // [TODO] Denote if ticket is new or reply?
         $xml_out = new SimpleXMLElement("<ticket></ticket>");
         $xml_out->addChild("id", $ticket_id);
         $xml_out->addChild("mask", $ticket->mask);
         $this->_render($xml_out->asXML());
     } else {
         $this->_error("Message could not be parsed.");
     }
 }
开发者ID:joegeck,项目名称:cerb4,代码行数:24,代码来源:App.php

示例5: array

$match_array = array();
$match_array["D-Link Camera Alert: Camera-Living-Room - PIR Sensor Triggered"] = "https://graph.api.smartthings.com/api/smartapps/installations/INSTANCE/%ACTION%?access_token=TOKEN";
$match_array["D-Link Camera Alert: Camera-Elia-Evi - PIR Sensor Triggered"] = "https://graph.api.smartthings.com/api/smartapps/installations/INSTANCE/%ACTION%?access_token=TOKEN";
$match_array["D-Link Camera Alert: Camera-Sam - PIR Sensor Triggered"] = "https://graph.api.smartthings.com/api/smartapps/installations/INSTANCE/%ACTION%?access_token=TOKEN";
$match_array["D-Link Camera Alert: Camera-Loft - PIR Sensor Triggered"] = "https://graph.api.smartthings.com/api/smartapps/installations/INSTANCE/%ACTION%?access_token=TOKEN";
// read email
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
    $line = fread($fd, 1024);
    $email .= $line;
}
fclose($fd);
$email_file = "/tmp/email_" . rand();
file_put_contents($email_file, $email);
$mime = mailparse_msg_parse_file($email_file);
$struct = mailparse_msg_get_structure($mime);
foreach ($struct as $st) {
    $section = mailparse_msg_get_part($mime, $st);
    $info = mailparse_msg_get_part_data($section);
    $subject = $info[headers][subject];
    $curl_string = $match_array[$subject];
    // trigger event active
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, str_replace("%ACTION%", "active", $curl_string));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
    curl_exec($ch);
    curl_close($ch);
    sleep(15);
    // trigger event inactive
    $ch = curl_init();
开发者ID:spritian,项目名称:SmartThingsPublic,代码行数:31,代码来源:cli_parse.php

示例6: switch

    switch (strtolower(trim($key))) {
        case 'x-original-to':
        case 'to':
            $recipient = iconv_mime_decode($headers[2][$id]);
            break;
        case 'from':
            $sender = iconv_mime_decode($headers[2][$id]);
            break;
        case 'subject':
            $subject = trim(iconv_mime_decode($headers[2][$id]));
            break;
        default:
    }
}
// Get structure
$mp = mailparse_msg_parse_file($tmpFile);
$structure = mailparse_msg_get_structure($mp);
// Retrieve security code. Doesn't consider invalid e-mail adresses, the e-mail was delivered after all.
list($localPart, $domain) = explode("@", $recipient);
$mailAuthToken = null;
if (strstr($localPart, "+")) {
    list($prefix, $mailAuthToken, $target) = explode("+", $localPart);
}
// Get user
$userId = 0;
if ($mailAuthToken) {
    $q = $db->buildQuery("select id from users where mail_auth_token='%s'", $mailAuthToken);
    $userId = $db->getSingleValue($q);
}
Log::debug("mailAuthToken: {$mailAuthToken}, userId: {$userId}");
$errors = array();
开发者ID:robkaper,项目名称:kiki,代码行数:31,代码来源:email-importer.php

示例7: mailparse_msg_parse_file

 * make sure that $filename points to a file containing an email message and
 * load this page in your browser.
 * You will be able to choose a part to view.
 * */
if ($argv[1]) {
    $filename = $argv[1];
} else {
    $filename = "yourmessage.txt";
}
if ($argv[2]) {
    $showpart = $argv[2];
} else {
    $showpart = $_REQUEST['showpart'];
}
/* parse the message and return a mime message resource */
$mime = mailparse_msg_parse_file($filename);
debug_zval_dump($mime);
/* return an array of message parts - this consists of the names of the parts
 * only */
$struct = mailparse_msg_get_structure($mime);
echo "<table>\n";
/* print a choice of sections */
foreach ($struct as $st) {
    echo "<tr>\n";
    echo "<td><a href=\"{$PHP_SELF}?showpart={$st}\">{$st}</a></td>\n";
    /* get a handle on the message resource for a subsection */
    $section = mailparse_msg_get_part($mime, $st);
    /* get content-type, encoding and header information for that section */
    $info = mailparse_msg_get_part_data($section);
    print_r($info);
    echo "\n";
开发者ID:Jan-E,项目名称:pecl-mail-mailparse,代码行数:31,代码来源:try.php


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