| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace Heanup\App\Api\Controller\Mail\Count;
- use Heanup\App\Api\Package\Database\Mail;
- use Heanup\App\Api\RestfulController;
- use PhpImap\Mailbox;
- class Unread extends RestfulController
- {
- /**
- * Get Method|获取数据
- * @return void
- * @throws \PhpImap\Exceptions\InvalidParameterException
- */
- protected function getData()
- {
- $email=$this->getQuery()->string("u");
- $account = substr($email, 0, strpos($email, "@"));
- $domain = substr($email, strpos($email, "@") + 1);
- $_mail = Mail::getOne(['email' => $account, 'domain' => $domain, 'status' => 1]);
- $password = $_mail['password'];
- $mailbox = new Mailbox(
- '{mail.97admin.com:993/imap/ssl/novalidate-cert}INBOX', // IMAP server and mailbox folder
- $email, // Username for the before configured mailbox
- $password, // Password for the before configured username
- __DIR__, // Directory, where attachments will be saved (optional)
- 'UTF-8' // Server encoding (optional)
- );
- $count=$mailbox->searchMailbox("UNSEEN");
- $this->showSuccess(count($count));
- }
- /**
- * Post Method|新增数据
- * @return void
- */
- protected function postData()
- {
- // TODO: 需要实现 postData() 方法.
- }
- /**
- * Put Method|更新数据
- * @return void
- */
- protected function putData()
- {
- // TODO: 需要实现 putData() 方法.
- }
- /**
- * Delete Method|删除数据
- * @return void
- */
- protected function deleteData()
- {
- // TODO: 需要实现 deleteData() 方法.
- }
- }
|