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


PHP imap_ping函数代码示例

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


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

示例1: ping

 /**
  * 
  * @return booleam
  */
 public function ping()
 {
     if (!imap_ping($this->connect)) {
         $this->connect();
     }
     return true;
 }
开发者ID:ncrousset,项目名称:imap,代码行数:11,代码来源:ImapConnect.php

示例2: pingMailbox

 public function pingMailbox()
 {
     if (!imap_ping($this->mbox)) {
         return $this->reconnect();
     }
     return true;
 }
开发者ID:carriercomm,项目名称:jbs,代码行数:7,代码来源:ImapMailbox.php

示例3: ping

 /**
  * Ping the connection
  *
  * @return bool
  */
 public function ping()
 {
     //init the catching
     $this->exceptionThrower->start();
     $success = imap_ping($this->mailbox);
     $this->exceptionThrower->stop();
     return $success;
 }
开发者ID:jolucama,项目名称:php-simplemail-receiver,代码行数:13,代码来源:Mailserver.php

示例4: open

 function open()
 {
     //echo $this->serverstr;
     if ($this->mbox && imap_ping($this->mbox)) {
         return $this->mbox;
     }
     $this->mbox = @imap_open($this->serverstr, $this->username, $this->password);
     return $this->mbox;
 }
开发者ID:iHunt101,项目名称:OsTicket,代码行数:9,代码来源:class.mailfetch.php

示例5: getImapStream

	/**
	 * Get IMAP mailbox connection stream
	 * @param bool $forceConnection Initialize connection if it's not initialized
	 * @return null|resource
	 */
	public function getImapStream($forceConnection = true) {
		if($forceConnection) {
			if($this->imapStream && (!is_resource($this->imapStream) || !imap_ping($this->imapStream))) {
				$this->disconnect();
				$this->imapStream = null;
			}
			if(!$this->imapStream) {
				$this->imapStream = $this->initImapStream();
			}
		}
		return $this->imapStream;
	}
开发者ID:hoanghd,项目名称:tools,代码行数:17,代码来源:Mailbox.php

示例6: get_imap_stream

 /**
  * Get IMAP mailbox connection stream
  * @param bool $forceConnection Initialize connection if it's not initialized
  * @return null|resource
  */
 public function get_imap_stream($force_connection = true)
 {
     static $imap_stream;
     if ($force_connection) {
         if ($imap_stream && (!is_resource($imap_stream) || !imap_ping($imap_stream))) {
             $this->disconnect();
             $imap_stream = null;
         }
         if (!$imap_stream) {
             $imap_stream = $this->_init_imap_stream();
         }
     }
     return $imap_stream;
 }
开发者ID:nguyenanhnhan,项目名称:CI_Imap,代码行数:19,代码来源:MY_Email.php

示例7: emailListener

function emailListener()
{
    //$output = "<script>console.log( 'just got in' );</script>";
    //echo $output;
    $connection = establishConnection();
    $dbConn = establishDBConnection();
    //$output = "<script>console.log( 'set up connection' );</script>";
    //$dbConn->query("INSERT INTO away_mentor (userID, tiStamp) VALUES (99897, NOW())");//test the db connection
    //echo $output;//develop thread/loop
    $messagestatus = "UNSEEN";
    $countTo24 = 0;
    while (true) {
        echo "in check loop";
        $emails = imap_search($connection, $messagestatus);
        if ($emails) {
            rsort($emails);
            foreach ($emails as $email_number) {
                echo "in email loop";
                $header = imap_headerinfo($connection, $email_number);
                $message = imap_fetchbody($connection, $email_number, 1.1);
                if ($message == "") {
                    $message = imap_fetchbody($connection, $email_number, 1);
                }
                $emailaddress = substr($header->senderaddress, stripos($header->senderaddress, "<") + 1, stripos($header->senderaddress, ">") - (stripos($header->senderaddress, ">") + 1));
                if (!detectOOOmessage($header->subject, $message, $emailaddress)) {
                    detectB00message($header->subject, $emailaddress);
                }
                imap_delete($connection, 1);
                //this might bug out but should delete the top message that was just parsed
            }
        }
        sleep(600);
        //do check every 10 minutes
        $countTo24 = $countTo24 + 1;
        if ($countTo24 >= 144) {
            $countTo24 = 0;
            $dbConn->query("DELETE FROM away_mentor WHERE tiStamp <= DATE_ADD(CURRENT_DATE, INTERVAL -1 DAY)");
            //delete mentors that have been away for more than 24 hours from the away list
            //$command = Yii::app()->db->createCommand();
            //   $command->delete('away_mentor', 'tiStamp <= DATE_ADD(CURRENT_DATE , INTERVAL -1 DAY )');//this might bug the hell out deletes mentors on the away list that were put on over 24 hours ago
        }
        if (!imap_ping($connection)) {
            $connection = establishConnection();
        }
    }
}
开发者ID:acuba001,项目名称:Collaborative-Platform,代码行数:46,代码来源:EmailListener.php

示例8: imap_reopen_folder

 /**
  * Helper to re-initialize the folder to speed things up
  * Remember what folder is currently open and only change if necessary
  *
  * @param string        $folderid       id of the folder
  * @param boolean       $force          re-open the folder even if currently opened
  *
  * @access protected
  * @return boolean      if folder is opened
  */
 protected function imap_reopen_folder($folderid, $force = false)
 {
     // if the stream is not alive, we open it again
     if (!@imap_ping($this->mbox)) {
         $this->mbox = @imap_open($this->server, $this->username, $this->password, OP_HALFOPEN);
         $this->mboxFolder = "";
     }
     // to see changes, the folder has to be reopened!
     if ($this->mboxFolder != $folderid || $force) {
         $s = @imap_reopen($this->mbox, $this->server . $folderid);
         // TODO throw status exception
         if (!$s) {
             ZLog::Write(LOGLEVEL_WARN, sprintf("BackendIMAP->imap_reopen_folder('%s'): failed to change folder: %s", $folderid, implode(", ", imap_errors())));
             return false;
         }
         $this->mboxFolder = $folderid;
     }
     return true;
 }
开发者ID:alanturing1,项目名称:Z-Push-contrib,代码行数:29,代码来源:imap.php

示例9: isConnected

 /**
  * Check if the stream is connected
  *
  * @return bool
  */
 protected function isConnected()
 {
     return $this->isConfigured() && $this->imapStream && is_resource($this->imapStream) && @imap_ping($this->imapStream);
 }
开发者ID:Yame-,项目名称:mautic,代码行数:9,代码来源:Mailbox.php

示例10: checkConnection

 /**
  * Checks connection state and if not connected, reconnects
  */
 public function checkConnection()
 {
     if (!imap_ping($this->stream)) {
         $this->reconnect();
     }
 }
开发者ID:strong2much,项目名称:yii2-imap,代码行数:9,代码来源:Imap.php

示例11: imap_ping

<?php

echo "Checking with no parameters\n";
imap_ping();
echo "Checking with incorrect parameter type\n";
imap_ping('');
imap_ping(false);
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:imap_ping_error.php

示例12: run

 /**
  * The main method we use to parse an IMAP inbox.
  */
 public function run()
 {
     // $instance must be initialized before we go on!
     if (self::$instance === false) {
         return false;
     }
     // If safe mode isn't on, then let's set the execution time to unlimited
     if (!ini_get('safe_mode')) {
         set_time_limit(0);
     }
     // Try to connect
     $connect = $this->connect();
     if (!$connect) {
         return false;
     }
     // Total duration we should keep the IMAP stream alive for in seconds
     $duration = bp_rbe_get_execution_time();
     bp_rbe_log('--- Keep alive for ' . $duration / 60 . ' minutes ---');
     bp_rbe_remove_imap_lock();
     // Mark the current timestamp, mark the future time when we should close the IMAP connection;
     // Do our parsing until $future > $now; re-mark the timestamp at end of loop... rinse and repeat!
     for ($now = time(), $future = time() + $duration; $future > $now; $now = time()) {
         // Get number of messages
         $message_count = imap_num_msg($this->connection);
         // If there are messages in the inbox, let's start parsing!
         if ($message_count != 0) {
             // According to this:
             // http://www.php.net/manual/pl/function.imap-headerinfo.php#95012
             // This speeds up rendering the email headers... could be wrong
             imap_headers($this->connection);
             bp_rbe_log('- Checking inbox -');
             // Loop through each email message
             for ($i = 1; $i <= $message_count; ++$i) {
                 // flush object cache if necessary
                 //
                 // we only flush the cache if the default object cache is in use
                 // why? b/c the default object cache is only meant for single page loads and
                 // since RBE runs in the background, we need to flush the object cache so WP
                 // will do a direct DB query for the next data fetch
                 if (!wp_using_ext_object_cache()) {
                     wp_cache_flush();
                 }
                 self::$html = false;
                 $content = self::body_parser($this->connection, $i);
                 $headers = $this->get_mail_headers($this->connection, $i);
                 $data = array('headers' => $headers, 'to_email' => BP_Reply_By_Email_Parser::get_header($headers, 'To'), 'from_email' => BP_Reply_By_Email_Parser::get_header($headers, 'From'), 'content' => $content, 'is_html' => self::$html, 'subject' => imap_utf8(BP_Reply_By_Email_Parser::get_header($headers, 'Subject')));
                 $parser = BP_Reply_By_Email_Parser::init($data, $i);
                 if (is_wp_error($parser)) {
                     //do_action( 'bp_rbe_imap_no_match', $this->connection, $i, $headers, $parser->get_error_code() );
                     do_action('bp_rbe_no_match', $parser, $data, $i, $this->connection);
                 }
                 // do something during the loop
                 // we mark the message for deletion here via this hook
                 do_action('bp_rbe_imap_loop', $this->connection, $i);
                 // unset some variables at the end of the loop
                 unset($content, $headers, $data, $parser);
             }
             // do something after the loop
             do_action('bp_rbe_imap_after_loop', $this->connection);
         }
         // stop the loop if necessary
         if (bp_rbe_should_stop()) {
             if ($this->close()) {
                 bp_rbe_log('--- Manual termination of connection confirmed! Kaching! ---');
             } else {
                 bp_rbe_log('--- Error - invalid connection during manual termination ---');
             }
             remove_action('shutdown', 'bp_rbe_spawn_inbox_check');
             exit;
         }
         // Give IMAP server a break
         sleep(10);
         // If the IMAP connection is down, reconnect
         if (!imap_ping($this->connection)) {
             bp_rbe_log('-- IMAP connection is down, attempting to reconnect... --');
             if (bp_rbe_is_connecting(array('clearcache' => true))) {
                 bp_rbe_log('--- RBE is already attempting to connect - stopping connection attempt ---');
                 continue;
             }
             // add lock marker before connecting
             bp_rbe_add_imap_lock();
             // attempt to reconnect
             $reopen = BP_Reply_By_Email_Connect::init(array('reconnect' => true), $this->connection);
             if ($reopen) {
                 bp_rbe_log('-- Reconnection successful! --');
             } else {
                 bp_rbe_log('-- Reconnection failed! :( --');
                 bp_rbe_log('Cannot connect: ' . imap_last_error());
                 // cleanup RBE after failure
                 bp_rbe_cleanup();
                 remove_action('shutdown', 'bp_rbe_spawn_inbox_check');
                 exit;
             }
         }
         // Unset some variables to clear some memory
         unset($message_count);
     }
//.........这里部分代码省略.........
开发者ID:r-a-y,项目名称:bp-reply-by-email,代码行数:101,代码来源:bp-reply-by-email-imap.php

示例13: check_mailbox

 protected function check_mailbox()
 {
     imap_ping($this->conn);
     $count = imap_num_msg($this->conn);
     common_log(LOG_INFO, "Found {$count} messages");
     if ($count > 0) {
         $handler = new IMAPMailHandler();
         for ($i = 1; $i <= $count; $i++) {
             $rawmessage = imap_fetchheader($this->conn, $count, FT_PREFETCHTEXT) . imap_body($this->conn, $i);
             $handler->handle_message($rawmessage);
             imap_delete($this->conn, $i);
         }
         imap_expunge($this->conn);
         common_log(LOG_INFO, "Finished processing messages");
     }
     return $count;
 }
开发者ID:Br3nda,项目名称:StatusNet,代码行数:17,代码来源:imapmanager.php

示例14: imapPing

 /**
  * prüft, ob die Connection noch aktiv ist, Exception falls keine Connection definiert ist,
  * oder die Connection geschlossen wurde
  * wenn reconnect = true, dann wird bei einer geschlossenen Connection die Connection neu aufgebaut
  * @param boolean $reconnect
  * @return boolean
  */
 public function imapPing($reconnect = false)
 {
     if ($this->imap === null) {
         throw new IMAPException(__METHOD__ . ' not connected');
     }
     $ret = imap_ping($this->imap);
     if ($ret === false) {
         if ($reconnect === true) {
             $this->imap = $this->imapOpen($this->server . $this->mbox, $this->config->username, $this->config->password, OP_HALFOPEN);
             $ret = imap_ping($this->imap);
             if ($ret === false) {
                 throw new IMAPException(__METHOD__ . ' reconnect failed');
             }
             $this->reopenedConnection = true;
         } else {
             throw new IMAPException(__METHOD__ . ' not connected');
         }
     }
     return true;
 }
开发者ID:NEOatNHNG,项目名称:cacert-testmgr,代码行数:27,代码来源:imapConnection.php

示例15: ping

 public function ping()
 {
     if ($this->closed) {
         return true;
     }
     imap_ping($this->resource);
 }
开发者ID:gbcogivea,项目名称:imap,代码行数:7,代码来源:Connection.php


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