コード例 #1
0
ファイル: gmail.php プロジェクト: veslo1/gmail-php-starter
         * Enable Batch Request to ease up on our HTTP Requests
         */
        $client->setUseBatch(true);
        $batch = new Google_Http_Batch($client);
        /**
         * Prepare batch request for getting user messages
         */
        foreach ($messageList as $mlist) {
            $batch->add($service->users_messages->get('me', $mlist->id, ['format' => 'raw']), $mlist->id);
        }
        /**
         * Execute the Batch Request
         */
        $batchMessages = $batch->execute();
        $inboxMessage = [];
        /**
         * Create a new Mime Mail Parser Instance ready to decode raw message content
         */
        $mimeDecode = new PhpMimeMailParser\Parser();
        foreach ($batchMessages as $dMessage) {
            $messageId = $dMessage->id;
            $gMessage = $service->users_messages->get('me', $messageId, ['format' => 'raw']);
            $dcMessage = base64url_decode($dMessage->getRaw());
            $mimeDecode->setText($dcMessage);
            $mimeSubject = $mimeDecode->getHeader('subject');
            $inboxMessage[] = ['messageId' => $messageId, 'messageSubject' => $mimeSubject];
        }
    }
} catch (Google_Auth_Exception $e) {
    $authException = true;
}
コード例 #2
0
ファイル: Ezmlm.php プロジェクト: kstefanini/ezmlm-php
 /**
  * Uses php-mime-mail-parser to extract and save attachments to message $id,
  * into subfolder "attachments" of the associated cache folder; if subfolder
  * "attachments" already exists and unlesst $force is true, does nothing.
  */
 protected function saveMessageAttachments($id, $force = false)
 {
     $messageCacheFolder = $this->getMessageCacheFolder($id);
     $attachmentsFolder = $messageCacheFolder . '/attachments/';
     $attachmentsFolderExists = is_dir($attachmentsFolder);
     if ($force || !$attachmentsFolderExists) {
         if (!$attachmentsFolderExists) {
             mkdir($attachmentsFolder);
         }
         $messageFile = $this->getMessageFileForId($id);
         $parser = new PhpMimeMailParser\Parser();
         $parser->setPath($messageFile);
         $parser->saveAttachments($attachmentsFolder);
     }
 }