• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imap_reopen函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: connect

 /**
  * Connect to an IMAP inbox.
  *
  * @return resource|bool The IMAP resource on success. Boolean false on failure.
  */
 protected function connect()
 {
     // stop if IMAP module does not exist
     if (!function_exists('imap_open')) {
         return false;
     }
     $mailbox = $this->get_mailbox();
     //
     if ($this->is_reconnection()) {
         // if PHP is 5.2+, use extra parameter to only try connecting once
         if (!empty($this->args['retries']) && version_compare(PHP_VERSION, '5.2.0') >= 0) {
             $resource = imap_reopen($this->connection, $mailbox, 0, (int) $this->args['retries']);
             // PHP is older, so use the default retry value of 3
         } else {
             $resource = imap_reopen($this->connection, $mailbox);
         }
     } else {
         // if PHP is 5.2+, use extra parameter to only try connecting once
         if (!empty($this->args['retries']) && version_compare(PHP_VERSION, '5.2.0') >= 0) {
             $resource = imap_open($mailbox, $this->args['username'], $this->args['password'], 0, (int) $this->args['retries']);
             // PHP is older, so use the default retry value of 3
         } else {
             $resource = imap_open($mailbox, $this->args['username'], $this->args['password']);
         }
     }
     return $resource;
 }
开发者ID:r-a-y,项目名称:bp-reply-by-email,代码行数:32,代码来源:bp-reply-by-email-connect.php


示例2: selectFolder

 /**
  * select given folder
  *
  * @return bool successfull opened folder
  * @param $folder name
  */
 public function selectFolder($folder)
 {
     $result = imap_reopen($this->imap, $this->mailbox . $folder);
     if ($result === true) {
         $this->folder = $folder;
     }
     return $result;
 }
开发者ID:radub,项目名称:php-imap-client,代码行数:14,代码来源:Imap.php


示例3: connect

 /**
  * Open a connection with the defined server.
  *
  * @return <bool> true/false according to success
  */
 public function connect()
 {
     //TODO: in the future, we can add an option for POP3 access as well
     $success = true;
     $mailbox_str = '{' . $this->hostname . ':' . $this->port . $this->options . '}';
     if ($this->connection == null) {
         $this->connection = @imap_open($mailbox_str, $this->username, $this->password);
         $success = $this->connection != null && $this->connection != false;
     } else {
         //reopen with a new mailbox name
         $success = imap_reopen($this->connection, $mailbox_str);
     }
     return $success;
 }
开发者ID:DBezemer,项目名称:server,代码行数:19,代码来源:KMailChecker.class.php


示例4: open_mailbox

 function open_mailbox($folder = "", $ops = OP_HALFOPEN, $fatal = true)
 {
     if ($this->connection && is_resource($this->connection)) {
         imap_close($this->connection);
     }
     $this->connect_string = '{' . $this->host . ':' . $this->port . '/' . $this->protocol . config::get_config_item("allocEmailExtra") . '}';
     $this->connection = imap_open($this->connect_string, $this->username, $this->password, $ops);
     if (!$this->connection && $fatal) {
         alloc_error("Unable to access mail folder(1).");
     }
     $list = imap_list($this->connection, $this->connect_string, "*");
     if (!is_array($list) || !count($list)) {
         // || !in_array($connect_string.$folder,$list)) {
         $this->unlock();
         imap_close($this->connection);
         if ($fatal) {
             alloc_error("Unable to access mail folder(2).");
         }
     } else {
         $rtn = imap_reopen($this->connection, $this->connect_string . $folder);
         $errs = print_r(imap_errors(), 1);
         if (!$rtn || preg_match("/Invalid mailbox name/i", $errs) || preg_match("/Mailbox does not exist/i", $errs)) {
             $rtn = imap_reopen($this->connection, $this->connect_string . str_replace("/", ".", $folder));
         }
         if (!$rtn) {
             imap_close($this->connection);
             if ($fatal) {
                 alloc_error("Unable to access mail folder(3).");
             }
         }
     }
     if (!$rtn && $fatal) {
         alloc_error("<pre>IMAP errors: " . print_r(imap_errors(), 1) . print_r(imap_alerts(), 1) . "</pre>");
     }
     return $rtn;
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:36,代码来源:email_receive.inc.php


示例5: set_imap_stream

 /**
  * This function creates or reopens an imap_stream when called.
  *
  */
 protected function set_imap_stream()
 {
     if (isset($this->imap_stream)) {
         if (!imap_reopen($this->imap_stream, $this->mailbox, $this->options, 1)) {
             throw new Imap_Exception(imap_last_error());
         }
     } else {
         $imap_stream = imap_open($this->get_server_string(), $this->username, $this->password, $this->options, 1);
         if ($imap_stream === FALSE) {
             throw new Imap_Exception(imap_last_error());
         }
         $this->imap_stream = $imap_stream;
     }
 }
开发者ID:kolanos,项目名称:kohana-imap,代码行数:18,代码来源:imap.php


示例6: import_msgs

 /**
  * Função que importa arquivos .eml exportados pelo expresso para a caixa do usuário. Testado apenas
  * com .emls gerados pelo expresso, e o arquivo pode ser um zip contendo vários emls ou um .eml.
  */
 function import_msgs($params)
 {
     if (!$this->mbox) {
         $this->mbox = $this->open_mbox();
     }
     if (preg_match('/local_/', $params["folder"])) {
         // PLEASE, BE CAREFULL!!! YOU SHOULD USE EMAIL CONFIGURATION VALUES (EMAILADMIN MODULE)
         //$tmp_box = mb_convert_encoding('INBOX'.$this->folders['trash'].$this->imap_delimiter.'tmpMoveToLocal', "UTF7-IMAP", "UTF-8");
         $tmp_box = mb_convert_encoding($this->mount_url_folder(array("INBOX", $this->folders['trash'], "tmpMoveToLocal")), "UTF7-IMAP", "UTF-8");
         if (!imap_createmailbox($this->mbox, "{" . $this->imap_server . "}{$tmp_box}")) {
             return $this->functions->getLang('Import to Local : fail...');
         }
         imap_reopen($this->mbox, "{" . $this->imap_server . ":" . $this->imap_port . $this->imap_options . "}" . $tmp_box);
         $params["folder"] = $tmp_box;
     }
     $errors = array();
     $invalid_format = false;
     $filename = $params['FILES'][0]['name'];
     $params["folder"] = mb_convert_encoding($params["folder"], "UTF7-IMAP", "ISO-8859-1, UTF-8");
     $quota = imap_get_quotaroot($this->mbox, $params["folder"]);
     if (($quota['limit'] - $quota['usage']) * 1024 <= $params['FILES'][0]['size']) {
         return array('error' => $this->functions->getLang("fail in import:") . " " . $this->functions->getLang("Over quota"));
     }
     if (substr($filename, strlen($filename) - 4) == ".zip") {
         $zip = zip_open($params['FILES'][0]['tmp_name']);
         if ($zip) {
             while ($zip_entry = zip_read($zip)) {
                 if (zip_entry_open($zip, $zip_entry, "r")) {
                     $email = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                     /*Caso mensagens vierem com quebras de linha diferentes do esperado, como por exemplo,
                     		mensagens exportadas pelo MailArchiver, é preciso corrigir.*/
                     $email = str_replace("\r\n", "\n", $email);
                     $email = str_replace("\n", "\r\n", $email);
                     $status = @imap_append($this->mbox, "{" . $this->imap_server . ":" . $this->imap_port . $this->imap_options . "}" . $params["folder"], $email);
                     if (!$status) {
                         array_push($errors, zip_entry_name($zip_entry));
                     }
                     zip_entry_close($zip_entry);
                 }
             }
             zip_close($zip);
         }
         if (isset($tmp_box) && !sizeof($errors)) {
             $mc = imap_check($this->mbox);
             $result = imap_fetch_overview($this->mbox, "1:{$mc->Nmsgs}", 0);
             $ids = array();
             foreach ($result as $overview) {
                 $ids[] = $overview->uid;
             }
             return implode(',', $ids);
         }
     } else {
         if (substr($filename, strlen($filename) - 4) == ".eml") {
             $email = implode("", file($params['FILES'][0]['tmp_name']));
             /*Caso mensagens vierem com quebras de linha diferentes do esperado, como por exemplo,
             		mensagens exportadas pelo MailArchiver, é preciso corrigir.*/
             $email = str_replace("\r\n", "\n", $email);
             $email = str_replace("\n", "\r\n", $email);
             $status = imap_append($this->mbox, "{" . $this->imap_server . ":" . $this->imap_port . $this->imap_options . "}" . $params["folder"], $email);
             if (!$status) {
                 return "Error importing";
             }
             if (isset($tmp_box) && !sizeof($errors)) {
                 $mc = imap_check($this->mbox);
                 $result = imap_fetch_overview($this->mbox, "1:{$mc->Nmsgs}", 0);
                 $ids = array();
                 foreach ($result as $overview) {
                     $ids[] = $overview->uid;
                 }
                 return implode(',', $ids);
             }
         } else {
             if (isset($tmp_box)) {
                 imap_deletemailbox($this->mbox, "{" . $this->imap_server . "}{$tmp_box}");
             }
             return array("error" => $this->functions->getLang("wrong file format"));
             $invalid_format = true;
         }
     }
     if (!$invalid_format) {
         if (count($errors) > 0) {
             $message = $this->functions->getLang("fail in import:") . "\n";
             foreach ($errors as $arquivo) {
                 $message .= $arquivo . "\n";
             }
             return array("error" => $message);
         } else {
             return $this->functions->getLang("The import was executed successfully.");
         }
     }
 }
开发者ID:cjvaz,项目名称:expressomail,代码行数:95,代码来源:class.imap_functions.inc.php


示例7: 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


示例8: pathOpen

 function pathOpen($p, $stat = 'stat')
 {
     // Open a Folder
     if (is_object($p)) {
         //$x = $f;
         //$f = new stdClass();
         //$f->name = $this->_c_host . $x;
         $p = $this->_c_host . self::folderName($p->name);
     }
     // prepend host if not found
     if (strpos($p, $this->_c_host) === false) {
         $p = $this->_c_host . self::folderName($p);
     }
     // Reset
     $this->_folder_stat = null;
     $this->_message_cur = 1;
     $this->_message_max = 0;
     // Open
     imap_check($this->_c);
     imap_reopen($this->_c, $p, 0, 1);
     //$this->_c_stat = imap_status($this->_c);
     $x = $this->stat();
     if (empty($x)) {
         $this->_folder_name = $p;
         $this->_message_cur = 1;
         // switch ($stat) {
         // case 'count':
         // 	$this->_message_max = imap_num_msg($this->_c);
         // 	return $this->_message_max;
         // case 'stat':
         // 	$this->_folder_stat = imap_status($this->_c, $p, SA_ALL);
         // 	print_r($this->_folder_stat);
         // 	die('stat');
         // 	return $this->_folder_stat;
         // case 'info':
         // 	$this->_folder_stat = imap_mailboxmsginfo($this->_c);
         // 	$this->_message_max = $this->_folder_stat->Nmsgs;
         // }
         // return $this->_folder_stat;
         // $x0 = self::folderName($p);
         // $x1 = self::folderName($this->_folder_stat->Mailbox);
         // if ($x0 == $x1) {
         // 	return $this->_folder_stat;
         // }
     } else {
         if (preg_match('/no such mailbox/', $x)) {
             return self::E_NO_MAILBOX;
         }
         if (preg_match('/Unknown Mailbox/', $x)) {
             return self::E_NO_MAILBOX;
         }
         die("\nimap_reopen({$this->_c_host}, {$p}) failed: {$x}\n");
     }
 }
开发者ID:edoceo,项目名称:radix,代码行数:54,代码来源:IMAP.php


示例9: reopen

 function reopen($mailbox, $flags)
 {
     if (version_compare(PHP_VERSION, '5.2.1') != -1) {
         $result = @imap_reopen($this->_stream, $this->getServerString($mailbox), $flags, $this->_config['login_tries']);
     } else {
         $result = @imap_reopen($this->_stream, $this->getServerString($mailbox), $flags);
     }
     return $result;
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:9,代码来源:class.imap.manager.php


示例10: setImapStream

 /**
  * This function creates or reopens an imapStream when called.
  *
  */
 protected function setImapStream()
 {
     if (!empty($this->imapStream)) {
         if (!imap_reopen($this->imapStream, $this->getServerString(), $this->options, 1)) {
             throw new \RuntimeException(imap_last_error());
         }
     } else {
         $imapStream = @imap_open($this->getServerString(), $this->username, $this->password, $this->options, 1, $this->params);
         if ($imapStream === false) {
             throw new \RuntimeException(imap_last_error());
         }
         $this->imapStream = $imapStream;
     }
 }
开发者ID:kamaroly,项目名称:Fetch,代码行数:18,代码来源:Server.php


示例11: init

 /**
  * If connection is not currently in this mailbox, switch it to this mailbox
  */
 protected function init()
 {
     $check = \imap_check($this->connection->getResource());
     if ($check->Mailbox != $this->mailbox) {
         \imap_reopen($this->connection->getResource(), $this->mailbox);
     }
 }
开发者ID:jhonn921007,项目名称:imap,代码行数:10,代码来源:Mailbox.php


示例12: setActiveMailbox

 public function setActiveMailbox($mailbox)
 {
     imap_reopen($this->con, $mailbox, 0, 3);
 }
开发者ID:hadvig,项目名称:laravel-imap,代码行数:4,代码来源:Client.php


示例13: url_stat

 public function url_stat($path, $flags)
 {
     $emptyString = '';
     if ($this->stream_open($path, 'np', $flags, $emptyString)) {
         if (!empty($this->path) && empty($this->currentAttachmentData)) {
             // Mail
             //$stats = array();
             if (empty($this->size) && empty($this->time)) {
                 list($stats, ) = imap_fetch_overview($this->ih, $this->path);
                 $this->size = $stats->size;
                 $this->time = strtotime($stats->date);
             }
             $keys = array('dev' => 0, 'ino' => 0, 'mode' => 33216, 'nlink' => 0, 'uid' => 0, 'gid' => 0, 'rdev' => 0, 'size' => $this->size, 'atime' => $this->time, 'mtime' => $this->time, 'ctime' => $this->time, 'blksize' => 0, 'blocks' => 0);
         } else {
             // BOX
             if (empty($this->currentAttachmentData) && !empty($this->mailbox) && !$this->pop3) {
                 // GET LAST MESSAGE
                 imap_reopen($this->ih, self::$currentRef . $this->mailbox);
                 $last = imap_num_msg($this->ih);
                 //AJXP_Logger::debug(__CLASS__,__FUNCTION__,"Should get mailbox data ".self::$currentRef.$this->mailbox . $last);
                 list($stats, ) = imap_fetch_overview($this->ih, $last);
                 $this->size = $stats->size;
                 $this->time = strtotime($stats->date);
             }
             $keys = array('dev' => 0, 'ino' => 0, 'mode' => empty($this->currentAttachmentData) ? 33216 | 040000 : 33216, 'nlink' => 0, 'uid' => 0, 'gid' => 0, 'rdev' => 0, 'size' => !empty($this->currentAttachmentData) ? $this->currentAttachmentData["size"] : 0, 'atime' => !empty($this->time) ? $this->time : 0, 'mtime' => !empty($this->time) ? $this->time : 0, 'ctime' => !empty($this->time) ? $this->time : 0, 'blksize' => 0, 'blocks' => 0);
         }
         $this->stream_close();
         return $keys;
     } else {
         return false;
     }
 }
开发者ID:biggtfish,项目名称:cms,代码行数:32,代码来源:class.imapAccessWrapper.php


示例14: init

 /**
  * If connection is not currently in this mailbox, switch it to this mailbox
  */
 private function init()
 {
     $check = imap_check($this->connection->getResource());
     if ($check === false || $check->Mailbox != $this->mailbox) {
         imap_reopen($this->connection->getResource(), $this->mailbox);
     }
 }
开发者ID:julio004,项目名称:imap,代码行数:10,代码来源:Mailbox.php


示例15: reopen

 public function reopen($mailbox)
 {
     if (!imap_reopen($this->mbox, $mailbox)) {
         throw new \ConnectionException('cannot set mailbox');
     }
 }
开发者ID:skrokbogumil,项目名称:KlientPoczty,代码行数:6,代码来源:mailService.php


示例16: imap_reopenFolder

 function imap_reopenFolder($folderid, $force = false)
 {
     // to see changes, the folder has to be reopened!
     if ($this->_mboxFolder != $folderid || $force) {
         $s = @imap_reopen($this->_mbox, $this->_server . imap_utf7_encode(str_replace(".", $this->_serverdelimiter, $folderid)));
         $this->_mboxFolder = $folderid;
     }
 }
开发者ID:BackupTheBerlios,项目名称:z-push-svn,代码行数:8,代码来源:imap.php


示例17: createmailbox

    if ($debug) {
        print "creating {$dest_mailbox} on {$dest_server} {$dest_mbox}\n";
    }
    createmailbox($dest_mbox, $dest_server, $dest_mailbox);
}
/*
// Create TEMP folder to back up INBOX messages from src_server not being 'archived'
if ($inbox && !folderExists($dest_mbox, $dest_server, $backup_inbox_folder)) {
  if ($debug) print "creating $backup_inbox_folder on $dest_server $dest_mbox\n";
  createmailbox($dest_mbox, $dest_server, $backup_inbox_folder);
}
*/
// And then reopen dest_server to $dest_mailbox so we can count before and afters
// NOTE - the use of foo is a cludge to fix the imap_reopen bug!!
$foo = $dest_mbox;
$dest_mbox = imap_reopen($dest_mbox, $dst_imap_string . $dest_mailbox);
$dest_mbox = $foo;
if ($debug) {
    print "\$dest_mbox = {$dest_mbox}\n";
}
// Print out number of messages from source server
$da_no_msgs = imap_num_msg($src_mbox);
print "Msg Count on {$src_server} - {$mailbox}: " . $da_no_msgs . "\n";
// Print out number of message from dest server before running append()s
$no_msgs = imap_num_msg($dest_mbox);
print "Msg Count on {$dest_server} - {$dest_mailbox} before migration: " . $no_msgs . "\n";
// Get each message from src_mbox (connected to the correct mailbox)
//  and append it to {$dest_server}$mailbox IF it's older
//  than $archive_date, which is set based on $folder_date_weeks
// Then mark message deleted on src_server IF $delete_src_msg is true
for ($i = 1; $i <= $da_no_msgs; $i++) {
开发者ID:Jensen-Technologies,项目名称:imap-importing,代码行数:31,代码来源:archive.php


示例18: to_folder

 public function to_folder($folder)
 {
     imap_reopen($this->mbox, $folder);
 }
开发者ID:andriiabaimov,项目名称:php,代码行数:4,代码来源:ImapRequest.php


示例19: change_to_mailbox

 /**
  * Reopens the IMAP connection pointing at a different mailbox
  * Accepts name or full server spec string
  * (like the one that is returned by imap_list())
  *
  */
 public function change_to_mailbox($mailbox_name_or_full_server_spec_string)
 {
     // should check if it is a valid mailbox
     // but for now, just see if it starts with curly bracket
     if (strncmp('{', $mailbox_name_or_full_server_spec_string, 1) === 0) {
         // it is (probably) a spec string
         // but, maybe mailbox names can start with {?
         // set the local mailbox property by splitting on curly brackets
         // use strtok twice to get the end of the string because it is surper fast
         strtok($mailbox_name_or_full_server_spec_string, '}');
         $this->mailbox = strtok($mailbox_name_or_full_server_spec_string);
         // reopen the connection using the new server spec string
         $bool = imap_reopen($this->resource, $mailbox_name_or_full_server_spec_string);
     } else {
         $this->mailbox = $mailbox_name_or_full_server_spec_string;
         $new_sss_with_mb = $this->_generate_server_spec_string();
         $bool = imap_reopen($this->resource, $new_sss_with_mb);
     }
 }
开发者ID:anteknik,项目名称:tomanage,代码行数:25,代码来源:peeker_connect.php


示例20: init

 /**
  * If connection is not currently in this mailbox, switch it to this mailbox
  */
 private function init()
 {
     $check = imap_check($this->connection->getResource());
     if ($check === false || $check->Mailbox != $this->mailbox->name) {
         set_error_handler([$this, 'errorHandler']);
         $this->setLastException(null);
         $result = imap_reopen($this->connection->getResource(), $this->mailbox->name);
         restore_error_handler();
         if (!$result) {
             throw new MailboxOpenException($this->mailbox->name);
         }
         $ex = $this->getLastException();
         if ($ex) {
             throw $ex;
         }
     }
 }
开发者ID:gbcogivea,项目名称:imap,代码行数:20,代码来源:Mailbox.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imap_rfc822_parse_adrlist函数代码示例发布时间:2022-05-15
下一篇:
PHP imap_renamemailbox函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap