陈德本 5 yıl önce
ebeveyn
işleme
cef1e636dd
6 değiştirilmiş dosya ile 275 ekleme ve 4 silme
  1. 31 0
      .idea/php.xml
  2. 29 1
      .idea/taoqu88.iml
  3. 70 0
      App/Api/Controller/Msg.php
  4. 35 0
      App/Api/Template/Msg.phtml
  5. 3 1
      composer.json
  6. 107 2
      composer.lock

+ 31 - 0
.idea/php.xml

@@ -1,4 +1,35 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
+  <component name="PhpIncludePathManager">
+    <include_path>
+      <path value="$PROJECT_DIR$/vendor/jaeger/querylist" />
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php72" />
+      <path value="$PROJECT_DIR$/vendor/psr/http-message" />
+      <path value="$PROJECT_DIR$/vendor/jaeger/phpquery-single" />
+      <path value="$PROJECT_DIR$/vendor/psr/cache" />
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php80" />
+      <path value="$PROJECT_DIR$/vendor/ralouphie/getallheaders" />
+      <path value="$PROJECT_DIR$/vendor/cache/tag-interop" />
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-idn" />
+      <path value="$PROJECT_DIR$/vendor/guzzlehttp/psr7" />
+      <path value="$PROJECT_DIR$/vendor/cache/adapter-common" />
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-normalizer" />
+      <path value="$PROJECT_DIR$/vendor/cache/filesystem-adapter" />
+      <path value="$PROJECT_DIR$/vendor/guzzlehttp/promises" />
+      <path value="$PROJECT_DIR$/vendor/psr/simple-cache" />
+      <path value="$PROJECT_DIR$/vendor/psr/log" />
+      <path value="$PROJECT_DIR$/vendor/paragonie/random_compat" />
+      <path value="$PROJECT_DIR$/vendor/guzzlehttp/guzzle" />
+      <path value="$PROJECT_DIR$/vendor/composer" />
+      <path value="$PROJECT_DIR$/vendor/symfony/var-dumper" />
+      <path value="$PROJECT_DIR$/vendor/league/flysystem" />
+      <path value="$PROJECT_DIR$/vendor/tightenco/collect" />
+      <path value="$PROJECT_DIR$/vendor/jaeger/g-http" />
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php70" />
+      <path value="$PROJECT_DIR$/vendor/ark/filecache" />
+      <path value="$PROJECT_DIR$/vendor/php-imap/php-imap" />
+    </include_path>
+  </component>
   <component name="PhpProjectSharedConfiguration" php_language_level="7" />
 </project>

+ 29 - 1
.idea/taoqu88.iml

@@ -1,7 +1,35 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module type="WEB_MODULE" version="4">
   <component name="NewModuleRootManager">
-    <content url="file://$MODULE_DIR$" />
+    <content url="file://$MODULE_DIR$">
+      <excludeFolder url="file://$MODULE_DIR$/vendor/cache/adapter-common" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/cache/filesystem-adapter" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/cache/tag-interop" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/guzzle" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/promises" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/psr7" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/jaeger/g-http" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/jaeger/phpquery-single" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/jaeger/querylist" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/league/flysystem" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/paragonie/random_compat" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/cache" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-message" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/log" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/simple-cache" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/ralouphie/getallheaders" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-idn" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-normalizer" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php70" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php72" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php80" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/var-dumper" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/tightenco/collect" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/ark/filecache" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/php-imap/php-imap" />
+    </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
   </component>

+ 70 - 0
App/Api/Controller/Msg.php

@@ -0,0 +1,70 @@
+<?php
+
+
+namespace Heanup\App\Api\Controller;
+
+
+use Ark\Filecache\FileCache;
+use Heanup\App\Api\Controller;
+use PhpImap\Mailbox;
+
+class Msg extends Controller
+{
+
+    /**
+     * Get Method|获取数据
+     * @return void
+     */
+    protected function main()
+    {
+        $mailbox = new Mailbox(
+            '{mail.97admin.com:993/imap/ssl/novalidate-cert}INBOX', // IMAP server and mailbox folder
+            "gv@a4sky.com", // Username for the before configured mailbox
+            "6485882", // Password for the before configured username
+            __DIR__, // Directory, where attachments will be saved (optional)
+            'UTF-8' // Server encoding (optional)
+        );
+
+        $mail_ids = $mailbox->searchMailbox('ALL');
+//        $mail_info = $mailbox->getMailsInfo($mail_ids);
+        $mail_info=[];
+        $mail_ids=array_reverse($mail_ids);
+        $i=0;
+        $cache = new FileCache([
+            'root' => APP_DIR.'/cache', // Cache root
+            'ttl' => 0,                    // Time to live
+            'compress' => false,             // Compress data with gzcompress or not
+            'serialize' => 'json',          // How to serialize data: json, php, raw
+        ]);
+        foreach ($mail_ids as $mail_id) {
+
+            if ($i>=10){
+//                $mailbox->deleteMail($mail_id);
+                break;
+            }else{
+                $temp=$cache->get($mail_id);
+                if (!$temp) {
+                    $detail = $mailbox->getMail($mail_id);
+                    $txt = explode("\r\n", $detail->textPlain);
+                    $temp = [
+                        'subject' => $detail->subject,
+                        'content' => $txt[1],
+                        'from' => $detail->fromAddress,
+                        'fromName' => $detail->fromName,
+                        'replyTo' => $detail->replyTo,
+                        'date' => $detail->date,
+                        'cc' => $detail->cc,
+                        'bcc' => $detail->bcc,
+                    ];
+                    $cache->set($mail_id, $temp);
+                }
+                $mail_info[]=$temp;
+            }
+            $i++;
+
+
+        }
+        $this->result=$mail_info;
+        $this->render();
+    }
+}

+ 35 - 0
App/Api/Template/Msg.phtml

@@ -0,0 +1,35 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+    <title>短信内容详情</title>
+
+</head>
+<body>
+<div class="message-container">
+    <div class="message-details">
+        <?php
+        foreach ($this->result as $item) {
+        ?>
+            <div style="text-align:left;border-bottom:2px solid #fff;padding:5px;margin-top:20px">
+                <div class="title">
+                                <span style="padding:2px;display:inline-block;height:20px;line-height:18px;background:#449d44;color:#fff;border-radius:5px;text-align:center">
+                                <?php echo $item['date']; ?></span>
+                    <span style="padding:2px;display:inline-block;height:20px;line-height:18px;background:#fe4365;color:#fff;border-radius:5px;text-align:center">
+                                <span>来自:</span><span><?php echo $item['fromName']; ?></span>
+                                </span>
+                </div>
+                <div class="conters">
+                            <span style="margin-top:5px;padding:5px;display:inline-block;background:#3fb8af;color:#fff;border-radius:5px;text-align:left">
+                            <?php echo $item['content']; ?>
+                            </span>
+                </div>
+            </div>
+        <?php
+        }
+        ?>
+    </div>
+
+</div>
+</body>
+</html>

+ 3 - 1
composer.json

@@ -1,5 +1,7 @@
 {
   "require": {
-    "jaeger/querylist": "^4.1"
+    "jaeger/querylist": "^4.1",
+    "ark/filecache": "^0.1.0",
+    "php-imap/php-imap": "^4.1"
   }
 }

+ 107 - 2
composer.lock

@@ -4,8 +4,44 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "a21dabb608d5c9d22c9c0565d3a614fb",
+    "content-hash": "05250fbc60d12ba7805788602d83c639",
     "packages": [
+        {
+            "name": "ark/filecache",
+            "version": "v0.1.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/arkphp/filecache.git",
+                "reference": "2646305ff6b9dfec96f3df00a42dc33a7a13560d"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/arkphp/filecache/zipball/2646305ff6b9dfec96f3df00a42dc33a7a13560d",
+                "reference": "2646305ff6b9dfec96f3df00a42dc33a7a13560d",
+                "shasum": ""
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Ark\\Filecache\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "dong",
+                    "email": "ddliuhb@gmail.com"
+                }
+            ],
+            "description": "Cache with file system",
+            "support": {
+                "source": "https://github.com/arkphp/filecache/tree/master"
+            },
+            "time": "2015-03-22T07:32:53+00:00"
+        },
         {
             "name": "cache/adapter-common",
             "version": "1.1.0",
@@ -710,6 +746,75 @@
             ],
             "time": "2018-07-02T15:55:56+00:00"
         },
+        {
+            "name": "php-imap/php-imap",
+            "version": "4.1.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/barbushin/php-imap.git",
+                "reference": "7ca3d19451bfe6de47186b52f4b266179a5858b9"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/barbushin/php-imap/zipball/7ca3d19451bfe6de47186b52f4b266179a5858b9",
+                "reference": "7ca3d19451bfe6de47186b52f4b266179a5858b9",
+                "shasum": ""
+            },
+            "require": {
+                "ext-fileinfo": "*",
+                "ext-iconv": "*",
+                "ext-imap": "*",
+                "ext-mbstring": "*",
+                "php": "^7.2"
+            },
+            "require-dev": {
+                "friendsofphp/php-cs-fixer": "^2.16",
+                "jakub-onderka/php-parallel-lint": "^1.0",
+                "maglnet/composer-require-checker": "^2.0",
+                "paragonie/hidden-string": "^1.0",
+                "phpunit/phpunit": "^8.5",
+                "povils/phpmnd": "^2.2",
+                "psalm/plugin-phpunit": "^0.10.0",
+                "roave/security-advisories": "dev-master",
+                "sebastian/phpcpd": "^4.1",
+                "vimeo/psalm": "^3.11.5"
+            },
+            "suggest": {
+                "ext-fileinfo": "To facilitate IncomingMailAttachment::getFileInfo() auto-detection"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "PhpImap\\": "src/PhpImap"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Sergey Barbushin",
+                    "email": "barbushin@gmail.com",
+                    "homepage": "http://linkedin.com/in/barbushin"
+                }
+            ],
+            "description": "Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)",
+            "homepage": "https://github.com/barbushin/php-imap",
+            "keywords": [
+                "imap",
+                "mail",
+                "mailbox",
+                "php",
+                "pop3",
+                "receive emails"
+            ],
+            "support": {
+                "issues": "https://github.com/barbushin/php-imap/issues",
+                "source": "https://github.com/barbushin/php-imap/tree/master"
+            },
+            "time": "2020-06-14T20:18:24+00:00"
+        },
         {
             "name": "psr/cache",
             "version": "1.0.1",
@@ -1642,5 +1747,5 @@
     "prefer-lowest": false,
     "platform": [],
     "platform-dev": [],
-    "plugin-api-version": "1.1.0"
+    "plugin-api-version": "2.0.0"
 }