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


PHP imap_status函数代码示例

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


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

示例1: checkMessages

 /**
  * @param resource $imapConnection
  * @param array    $messages
  * @param bool     $clean
  *
  * @return bool Return <em>true</em> if <strong>all</strong> messages exist in the inbox.
  */
 public function checkMessages($imapConnection, array $messages, $clean = true)
 {
     $bodies = array_map(function ($message) {
         return $message->getText() . "\r\n";
     }, $messages);
     $host = $_ENV['AVISOTA_TEST_IMAP_HOST'] ?: getenv('AVISOTA_TEST_IMAP_HOST');
     $hits = 0;
     for ($i = 0; $i < 30 && $hits < count($bodies); $i++) {
         // wait for the mail server
         sleep(2);
         imap_gc($imapConnection, IMAP_GC_ENV);
         $status = imap_status($imapConnection, '{' . $host . '}', SA_MESSAGES);
         for ($j = $status->messages; $j > 0; $j--) {
             $body = imap_body($imapConnection, $j);
             if (in_array($body, $bodies)) {
                 $hits++;
                 if ($clean) {
                     imap_delete($imapConnection, $j);
                 }
             }
         }
         imap_expunge($imapConnection);
     }
     return $hits;
 }
开发者ID:avisota,项目名称:core,代码行数:32,代码来源:ImapMailboxChecker.php

示例2: free

 public function free($util)
 {
     $stream = imap_open("{imap.club-internet.fr:993/imap/SSL}", $util, "wrasuxwr");
     var_dump($stream);
     $check = imap_check($stream);
     $list = imap_list($stream, "{imap.club-internet.fr}", "*");
     imap_createmailbox($stream, '{imap.club-internet.fr}brubru');
     $getmailboxes = imap_getmailboxes($stream, "{imap.club-internet.fr}", "*");
     $headers = imap_headers($stream);
     $num_msg = imap_num_msg($stream);
     $status = imap_status($stream, "{imap.club-internet.fr:993/imap/SSL}INBOX", SA_ALL);
     $messages = imap_fetch_overview($stream, "1:" . $num_msg);
     $structure = imap_fetchstructure($stream, 2);
     $body = utf8_encode(quoted_printable_decode(imap_body($stream, '2')));
     // imap_delete($stream, '1');
     // imap_expunge($stream);
     return view('Imap.Imap')->with(compact('resource'))->with(compact('check'))->with(compact('list'))->with(compact('getmailboxes'))->with(compact('headers'))->with(compact('num_msg'))->with(compact('status'))->with(compact('errors'))->with(compact('messages'))->with(compact('structure'))->with(compact('body'));
 }
开发者ID:gAb09,项目名称:NetP,代码行数:18,代码来源:ImapController.php

示例3: test

 /**
  * Test connection to a mailbox.
  *
  * @param object $mailbox
  *   The mailbox to test.
  *
  * @return array
  *   Test results.
  */
 function test($mailbox)
 {
     extract($mailbox->settings);
     $ret = array();
     $is_local = $type == 'local';
     $folder_is_set = !empty($folder) && $folder != 'INBOX';
     $connect_is_set = !empty($domain) && !empty($port) && !empty($name) && !empty($pass);
     if ($is_local && $folder_is_set || !$is_local && $connect_is_set) {
         if ($result = $this->open_mailbox($mailbox)) {
             $ret[] = array('severity' => 'status', 'message' => t('Mailhandler was able to connect to the mailbox.'));
             $box = $this->mailbox_string($mailbox);
             $status = imap_status($result, $box, SA_MESSAGES);
             if ($status) {
                 $ret[] = array('severity' => 'status', 'message' => t('There are @messages messages in the mailbox folder.', array('@messages' => $status->messages)));
             } else {
                 $ret[] = array('severity' => 'warning', 'message' => t('Mailhandler could not open the specified folder'));
             }
             $this->close_mailbox($result);
         } else {
             imap_errors();
             $ret[] = array('severity' => 'error', 'message' => t('Mailhandler could not access the mailbox using these settings'));
         }
     }
     return $ret;
 }
开发者ID:tierce,项目名称:ppbe,代码行数:34,代码来源:MailhandlerPhpImapRetrieve.class.php

示例4: readImapStatus

function readImapStatus($config, $savedStatus, $db)
{
    $mbox = imap_open($config["imap_server"], $config["imap_user"], $config["imap_password"]);
    $imapStatus = imap_status($mbox, $config["imap_server"], SA_ALL);
    // Read message IDs of UNSEEN mails
    $unseen = [];
    if ($imapStatus->unseen > 0) {
        $messages = imap_search($mbox, "UNSEEN");
        foreach ($messages as $msgID) {
            $msg = imap_headerinfo($mbox, $msgID);
            $unseen[] = $msg->message_id;
        }
    }
    imap_close($mbox);
    //
    $last_unseen = json_decode($savedStatus->unseen);
    $new_message_found = false;
    foreach ($unseen as $key => $value) {
        // Does 'unseen' contain msgID we haven't seen before?
        if (array_search($value, $last_unseen) === FALSE) {
            $new_message_found = true;
        }
    }
    // Current unseen list doesn't match saved one
    if (count($unseen) != count($last_unseen) || $new_message_found) {
        saveStatusToSqlite($db, "unseen", json_encode($unseen));
    }
    return $new_message_found;
}
开发者ID:McFizh,项目名称:hackster-cc3200-email,代码行数:29,代码来源:common.php

示例5: getAllMessages

 public function getAllMessages($imap, $dsn)
 {
     $status = imap_status($imap, $dsn, SA_ALL);
     $msgs = imap_sort($imap, SORTDATE, 1, SE_UID);
     foreach ($msgs as $msguid) {
         $msgno = imap_msgno($imap, $msguid);
         $messages[$msgno] = imap_headerinfo($imap, $msgno);
     }
     return $messages;
 }
开发者ID:maniargaurav,项目名称:OpenDesk,代码行数:10,代码来源:mail.php

示例6: __construct

 /**
  * @constructor
  */
 function __construct()
 {
     $this->imap_host = $GLOBALS['phpgw']->config->config_data['imap_message_host'];
     $this->imap = @imap_open("\\{{$this->imap_host}:143/imap/notls}INBOX", $GLOBALS['phpgw_info']['user']['account_lid'], $GLOBALS['phpgw_info']['user']['passwd']);
     if (is_resource($this->imap)) {
         $this->stat = imap_status($this->imap, "\\{{$this->imap_host}}INBOX", SA_MESSAGES);
         $this->connected = true;
     }
     parent::__construct();
 }
开发者ID:HaakonME,项目名称:porticoestate,代码行数:13,代码来源:class.somessenger_imap.inc.php

示例7: selectAll

function selectAll($page)
{
    $mbox = getMbox();
    $mbox_info = imap_status($mbox, getServiceString(), SA_ALL);
    $num_messages = $mbox_info->messages;
    $messages = array();
    for ($i = 0; $i < 10; $i++) {
        $current_message = $num_messages - ($page * 10 + $i);
        $messages[] = imap_uid($mbox, $current_message);
    }
    imap_close($mbox);
    return implode(' ', $messages);
}
开发者ID:palako,项目名称:mobilewebmail,代码行数:13,代码来源:performaction.php

示例8: getStatus

 public function getStatus()
 {
     //this prevent errors Notice: Unknown: [NONEXISTENT] Unknown Mailbox: [Gmail] (now in authenticated state) (Failure) (errflg=2) in Unknown on line 0
     //http://docs.maildev.com/article/61-gmail-nonexistent-unknown-mailbox
     if (in_array('noselect', $this->getAttributes())) {
         return array();
     }
     $this->init();
     $status = imap_status($this->connection->getResource(), $this->mailbox->name, SA_ALL);
     if ($status) {
         return (array) $status;
     }
     throw new Exception("Can not get mailbox status at '{$this->mailbox->name}'");
 }
开发者ID:gbcogivea,项目名称:imap,代码行数:14,代码来源:Mailbox.php

示例9: getFolders

 /**
  * Vrati pole vsetkych najdenych mailboxov na emailovom konte
  *
  * @return array
  * @throws Exception
  */
 public function getFolders()
 {
     $mbox = $this->openMailServerConnection();
     $result = array();
     $boxes = imap_getmailboxes($mbox, '{' . IMAP_HOST . '}', '*');
     if (is_array($boxes)) {
         foreach ($boxes as $key => $val) {
             $result[$key]['name'] = str_replace('{' . IMAP_HOST . '}', '', imap_utf7_decode($val->name));
             $result[$key]['delimiter'] = $val->delimiter;
             $result[$key]['attribs'] = $val->attributes;
             $Status = imap_status($mbox, $val->name, SA_ALL);
             $result[$key]['msgNum'] = $Status->messages;
             $result[$key]['newNum'] = isset($Status->recent) ? $Status->recent : 0;
             $result[$key]['unreadNum'] = isset($Status->unseen) ? $Status->unseen : 0;
         }
     } else {
         Logger::error("imap_getmailboxes() failed: " . imap_last_error());
     }
     //        imap_close($mbox);
     return $result;
 }
开发者ID:novacek78,项目名称:v4,代码行数:27,代码来源:ModelImapServer.php

示例10: getdata

 function getdata($host, $login, $password, $savedirpath)
 {
     $this->savedDirPath = $savedirpath;
     $this->attachmenttype = array("text", "multipart", "message", "application", "audio", "image", "video", "other");
     // create empty array to store message data
     $this->importedMessageDataArray = array();
     // open the mailbox
     $mailbox = "{" . $host . ":143/imap/notls}INBOX";
     $this->mbox = imap_open($mailbox, $login, $password);
     if ($this->mbox == FALSE) {
         return null;
     }
     $status = imap_status($this->mbox, $mailbox, SA_ALL);
     echo "Messages: ", $status->messages, "<BR>\n";
     echo "Recent: ", $status->recent, "<BR>\n";
     echo "Unseen: ", $status->unseen, "<BR>\n";
     echo "UIDnext: ", $status->uidnext, "<BR>\n";
     echo "UIDvalidity: ", $status->uidvalidity, "<BR>\n";
     echo "Flags: ", $status->flags, "<BR>\n";
     // now itterate through messages
     for ($mid = imap_num_msg($this->mbox); $mid >= 1; $mid--) {
         $header = imap_header($this->mbox, $mid);
         $this->importedMessageDataArray[$mid]["subject"] = property_exists($header, 'subject') ? $header->subject : "";
         $this->importedMessageDataArray[$mid]["fromaddress"] = property_exists($header, 'fromaddress') ? $header->fromaddress : "";
         $this->importedMessageDataArray[$mid]["date"] = property_exists($header, 'date') ? $header->date : "";
         $this->importedMessageDataArray[$mid]["body"] = "";
         $this->structureObject = imap_fetchstructure($this->mbox, $mid);
         $this->saveAttachments($mid);
         $this->getBody($mid);
         imap_delete($this->mbox, $mid);
         //imap_delete tags a message for deletion
     }
     // for multiple messages
     imap_expunge($this->mbox);
     // imap_expunge deletes all tagged messages
     imap_close($this->mbox);
     // now send the data to the server
     $this->exportEntries();
     return $this->importedMessageDataArray;
 }
开发者ID:DBezemer,项目名称:server,代码行数:40,代码来源:___myMailAttachmentImporter.class.php

示例11: mailInfo

 function mailInfo()
 {
     if (is_connected()) {
         $CI = get_instance();
         // You may need to load the model if it hasn't been pre-loaded
         $CI->load->model('account/mailbox_model');
         // Call a function of the model
         //$CI->mailbox->do_something();
         $mailbox_settings = $CI->mailbox_model->get();
         if (!empty($mailbox_settings)) {
             $address = "{" . $mailbox_settings->mail_server . "}" . $mailbox_settings->mailbox;
             $email = $mailbox_settings->email;
             $password = $mailbox_settings->password;
             if ($inbox = imap_open($address, $email, $password, OP_READONLY)) {
                 // Get general mailbox information.
                 $info = imap_status($inbox, $address, SA_ALL);
                 $mailInfo = array('unread' => $info->unseen, 'recent' => $info->recent, 'total' => $info->messages);
                 return $mailInfo;
             }
         }
     }
 }
开发者ID:erwiensatrya,项目名称:dentalclinic,代码行数:22,代码来源:mailbox_helper.php

示例12: getNumberOfMessages

 /**
  * Returns a count of the number of messages
  * @return integer
  */
 function getNumberOfMessages()
 {
     $status = imap_status($this->_connection, $this->_mailbox, SA_ALL);
     DebugDump($status);
     if ($status) {
         return max($status->messages, imap_num_msg($this->_connection));
     } else {
         LogInfo("Error imap_status did not return a value");
         //DebugDump($this);
         return 0;
     }
 }
开发者ID:davenaylor,项目名称:postie,代码行数:16,代码来源:postieIMAP.php

示例13: checkForMails

 protected function checkForMails()
 {
     if (!$this->isConnected()) {
         static::raiseError(__METHOD__ . '(), need to be connected to the mail server to proceed!');
         return false;
     }
     if (($status = imap_status($this->imap_session, $this->connect_string, SA_UNSEEN)) === false) {
         static::raiseError(__METHOD__ . '(), imap_status() failed!' . imap_last_error());
         return false;
     }
     if (!isset($status->flags) || $status->flags != SA_UNSEEN) {
         static::raiseError(__METHOD__ . '(), server responded with something we have not requested!');
         return false;
     }
     if (!isset($status->unseen) || !is_numeric($status->unseen)) {
         static::raiseError(__METHOD__ . '(), server responded invalid!');
         return false;
     }
     return $status->unseen;
 }
开发者ID:unki,项目名称:mtlda,代码行数:20,代码来源:MailImportController.php

示例14: testSendEmail

 /**
  * @dataProvider providerTestSendEmail
  */
 public function testSendEmail($sendData, $expectedResult)
 {
     if (empty($sendData)) {
         $this->markTestSkipped('No $sendData from data provider.');
     }
     if (!self::imapIsEnabled()) {
         $this->markTestSkipped('IMAP is not loaded');
         return;
     }
     $emailINI = eZINI::instance('test_ezmail_plain.ini');
     $mboxString = $emailINI->variable('TestAccounts', 'MBoxString');
     $recipients = array_merge((array) $sendData['to'], (array) $sendData['cc'], (array) $sendData['bcc']);
     if (isset($sendData['Transport']) and $sendData['Transport'] == 'SMTP') {
         ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'Transport', 'SMTP');
         $mailINI = eZINI::instance('test_ezmail_plain.ini');
         $mailSetting = $mailINI->group('MailSettings');
         ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'TransportServer', $mailSetting['TransportServer']);
         ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'TransportPort', $mailSetting['TransportPort']);
         ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'TransportUser', $mailSetting['TransportUser']);
         ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'TransportPassword', $mailSetting['TransportPassword']);
     }
     if (isset($sendData['DebugSending']) and $sendData['DebugSending'] == true) {
         ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'DebugSending', 'enabled');
         $users = self::getTestAccounts();
         $recipients[] = $users['01'];
     } else {
         ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'DebugSending', 'disabled');
     }
     foreach ($recipients as $recipient) {
         // Accept only testing accounts as recipients
         if (preg_match('/^ezp-unittests-\\d\\d\\@mail\\.ez\\.no$/', $recipient['email']) != 1) {
             $this->markTestSkipped('Refusing to use other than testing accounts');
             return;
         }
         // Open mailbox and delete all existing emails in the account
         $mbox = @imap_open($mboxString, $recipient['username'], $recipient['password']);
         if (!$mbox) {
             $this->markTestSkipped('Cannot open mailbox for ' . $recipient['username'] . ': ' . imap_last_error());
             return;
         }
         $status = imap_status($mbox, $mboxString, SA_MESSAGES);
         for ($i = 1; $i <= $status->messages; $i++) {
             imap_delete($mbox, $i);
         }
         imap_expunge($mbox);
         imap_close($mbox);
     }
     // Create and send email
     $mail = new eZMail();
     if (count($sendData['to']) == 1) {
         $mail->setReceiver($sendData['to'][0]['email'], $sendData['to'][0]['name']);
     } else {
         $mail->setReceiverElements($sendData['to']);
     }
     if ($sendData['replyTo']) {
         $mail->setReplyTo($sendData['replyTo']['email'], $sendData['replyTo']['name']);
     }
     $mail->setSender($sendData['sender']['email'], $sendData['sender']['name']);
     if ($sendData['cc']) {
         if (count($sendData['cc']) == 1) {
             $mail->addCc($sendData['cc'][0]['email'], $sendData['cc'][0]['name']);
         } else {
             $mail->setCcElements($sendData['cc']);
         }
     }
     if ($sendData['bcc']) {
         if (count($sendData['bcc']) == 1) {
             $mail->addBcc($sendData['bcc'][0]['email'], $sendData['bcc'][0]['name']);
         } else {
             $mail->setBccElements($sendData['bcc']);
         }
     }
     $mail->setSubject($sendData['subject']);
     $mail->setBody($sendData['body']);
     $sendResult = eZMailTransport::send($mail);
     $this->assertEquals(true, $sendResult);
     // Wait for it...
     sleep(2);
     // Read emails
     foreach ($recipients as $recipient) {
         $mbox = @imap_open($mboxString, $recipient['username'], $recipient['password']);
         if (!$mbox) {
             $this->markTestSkipped('Cannot open mailbox for ' . $recipient['username'] . ': ' . imap_last_error());
             return;
         }
         // Check message count before we try to open anything, in case nothing is there
         $status = imap_status($mbox, $mboxString, SA_MESSAGES);
         $this->assertEquals($expectedResult[$recipient['email']]['messageCount'], $status->messages);
         // Build actual result array, and check against the expected result
         $actualResult = array('messageCount' => $status->messages);
         for ($i = 1; $i <= $status->messages; $i++) {
             $headers = imap_headerinfo($mbox, $i);
             $actualResult['headers'] = array();
             $actualResult['headers']['to'] = array();
             foreach ($headers->to as $item) {
                 $actualResult['headers']['to'][] = array('email' => $item->mailbox . '@' . $item->host);
             }
//.........这里部分代码省略.........
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:101,代码来源:ezmail_test.php

示例15: updateFolder

 /**
  * Updates the mail box's folder
  * @param MailManager_Model_Folder $folder - folder instance
  * @param $options imap_status flags like SA_UNSEEN, SA_MESSAGES etc
  */
 function updateFolder($folder, $options)
 {
     $result = @imap_status($this->mBox, $folder->name($this->mBoxUrl), $options);
     if ($result) {
         if (isset($result->unseen)) {
             $folder->setUnreadCount($result->unseen);
         }
         if (isset($result->messages)) {
             $folder->setCount($result->messages);
         }
     }
 }
开发者ID:hbsman,项目名称:vtigercrm-5.3.0-ja,代码行数:17,代码来源:Connector.php


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