function renamemailbox($stream, $mailbox_old, $mailbox_new) { $this->folder_list_did_change(); $mailbox_old = $this->utf7_encode($mailbox_old); $mailbox_new = $this->utf7_encode($mailbox_new); return imap_renamemailbox($stream, $mailbox_old, $mailbox_new); }
/** * This method creates, renames and deletes mailboxes from the server. * * @param string $action * One of create|rename|delete, this tells the method what you want to * do with a mailbox. * @param string $mb_name * The name of the mailbox to create, delete or rename. * @param string $mb_rename * (optional) New name for the mailbox, if it is being renamed. * * @return BOOL * @access public * @see imap_createmailbox * @see imap_renamemailbox * @see imap_deletemailbox * @tutorial http://www.smilingsouls.net/Mail_IMAP?content=Mail_IMAP_ManageMB/manageMB */ function manageMB($action, $mb_name, $mb_rename = NULL) { switch ($action) { case 'create': if (@imap_createmailbox($this->mailbox, imap_utf7_encode($this->mailboxInfo['host'] . 'INBOX.' . $mb_name))) { $ret = TRUE; } else { $this->error->push(Mail_IMAPv2_ERROR, 'error', NULL, 'Unable to create MB: ' . $mb_name); $ret = FALSE; } break; case 'rename': if (empty($mb_rename)) { $this->error->push(Mail_IMAPv2_ERROR, 'error', NULL, 'No mailbox provided to rename.'); } if (@imap_renamemailbox($this->mailbox, $this->mailboxInfo['host'] . 'INBOX.' . $mb_name, $this->mailboxInfo['host'] . 'INBOX.' . $mb_rename)) { $ret = TRUE; } else { $this->error->push(Mail_IMAPv2_ERROR, 'error', NULL, 'Unable to rename MB: ' . $mb_name); $ret = FALSE; } break; case 'delete': if (@imap_deletemailbox($this->mailbox, $this->mailboxInfo['host'] . 'INBOX.' . $mb_name)) { $ret = TRUE; } else { $this->error->push(Mail_IMAPv2_ERROR, 'error', NULL, 'Unable to delete MB: ' . $mb_name); $ret = FALSE; } break; default: $this->error->push(Mail_IMAPv2_ERROR_INVALID_ACTION, 'error', array('action' => $action, 'arg' => '$action')); $ret = FALSE; return $ret; } }
/** * Rename a mailbox. * * @param $oldMailbox * @param $newMailbox * * @return bool */ public function renameMailbox($oldMailbox, $newMailbox) { return imap_renamemailbox($this->getImapStream(), $this->getServerSpecification() . $oldMailbox, $this->getServerSpecification() . $newMailbox); }
/** * rename folder * * @return bool success or not * @param $name of the folder * @param $newname of the folder */ public function renameFolder($name, $newname) { return imap_renamemailbox($this->imap, $this->mailbox . $name, $this->mailbox . $newname); }
/** * Renames the current folder * @param string $oldName * @param string $newName * @return bool */ public function renameFolder($oldName, $newName) { return imap_renamemailbox($this->connection->getConnection(), $oldName, $newName); }
function imap_renamemailbox($_oldMailboxName, $_newMailboxName) { if (strcasecmp("inbox", $_oldMailboxName) == 0 || strcasecmp("inbox", $_newMailboxName) == 0) { return False; } $oldMailboxName = ExecMethod('emailadmin.bo.getMailboxString', $_oldMailboxName, 3, $this->profileID); $newMailboxName = ExecMethod('emailadmin.bo.getMailboxString', $_newMailboxName, 3, $this->profileID); $result = @imap_renamemailbox($this->mbox, $oldMailboxName, $newMailboxName); #print imap_last_error(); return $result; }
public function renameMailbox($oldbox, $newbox) { imap_renamemailbox($this->mbox, imap_utf7_encode($oldbox), imap_utf7_encode($newbox)); }
<?php echo "Checking with no parameters\n"; imap_renamemailbox(); echo "Checking with incorrect parameter type\n"; imap_renamemailbox(''); imap_renamemailbox(false); require_once dirname(__FILE__) . '/imap_include.inc'; $stream_id = setup_test_mailbox('', 1); if (!is_resource($stream_id)) { exit("TEST FAILED: Unable to create test mailbox\n"); } $newbox = $default_mailbox . "." . $mailbox_prefix; imap_renamemailbox($stream_id, $newbox . 'not'); imap_renamemailbox($stream_id, $newbox); //commented because of bug #49901 //$ancError = error_reporting(0); //$z = imap_renamemailbox($stream_id, $newbox.'not2', $newbox.'2'); //var_dump($z); //error_reporting($ancError); echo "Checking OK\n"; var_dump(imap_createmailbox($stream_id, $newbox . '.test')); var_dump(imap_renamemailbox($stream_id, $newbox . '.test', $newbox . '.testd')); imap_close($stream_id); require_once 'clean.inc';
/** * Rename a mailbox * * @param string $oldfolder * @param string $newfolder * @return bool * @access public */ function renamefolder($oldfolder, $newfolder) { if ($this->protocol == 'POP3') { $this->errors[] = GM_NO_POP3_SUPPORT; return false; } if ($this->use_native) { if (!imap_renamemailbox($this->mailer, $oldfolder, $newfolder)) { $this->errors[] = imap_last_error(); return false; } } else { $res = $this->mailer->renameMailbox($oldfolder, $newfolder); if ($res !== true) { $this->errors[] = 'rename failed'; return false; } } }
/** * Rename the specified folder. * * @param string $old The folder to rename. * @param string $new The new name of the folder. * * @return NULL */ public function rename($old, $new) { $result = imap_renamemailbox($this->getBackend(), $this->_getBaseMbox() . $this->encodePath($old), $this->_getBaseMbox() . $this->encodePath($new)); if (!$result) { throw new Horde_Kolab_Storage_Exception(sprintf(Horde_Kolab_Storage_Translation::t("Renaming folder %s to %s failed.") . ' ' . Horde_Kolab_Storage_Translation::t("Error: %s"), $this->_getBaseMbox() . $old, $this->_getBaseMbox() . $new, imap_last_error())); } }
function createMailBox($name, $id) { $srv = getUsrMailData($id); $mbox = mail_login($srv["msrv"], $srv["port"], $srv["postf"], $srv["mailuser"], $srv["kennw"], $srv["proto"], $srv["ssl"]); $name1 = $name; $name2 = imap_utf7_encode($name); $newname = $name1; echo "Newname will be '{$name1}'<br>\n"; # we will now create a new mailbox "phptestbox" in your inbox folder, # check its status after creation and finaly remove it to restore # your inbox to its initial state if (@imap_createmailbox($mbox, imap_utf7_encode("{" . $srv["msrv"] . "}INBOX.{$newname}"))) { $status = @imap_status($mbox, "{" . $srv["msrv"] . "}INBOX.{$newname}", SA_ALL); if ($status) { print "your new mailbox '{$name1}' has the following status:<br>\n"; print "Messages: " . $status->messages . "<br>\n"; print "Recent: " . $status->recent . "<br>\n"; print "Unseen: " . $status->unseen . "<br>\n"; print "UIDnext: " . $status->uidnext . "<br>\n"; print "UIDvalidity:" . $status->uidvalidity . "<br>\n"; if (imap_renamemailbox($mbox, "{" . $srv["msrv"] . "}INBOX.{$newname}", "{your.imap.host}INBOX.{$name2}")) { echo "renamed new mailbox from '{$name1}' to '{$name2}'<br>\n"; $newname = $name2; } else { print "imap_renamemailbox on new mailbox failed: " . imap_last_error() . "<br>\n"; } } else { print "imap_status on new mailbox failed: " . imap_last_error() . "<br>\n"; } if (@imap_deletemailbox($mbox, "{" . $srv["msrv"] . "}INBOX.{$newname}")) { print "new mailbox removed to restore initial state<br>\n"; } else { print "imap_deletemailbox on new mailbox failed: " . implode("<br>\n", imap_errors()) . "<br>\n"; } } else { print "could not create new mailbox: " . implode("<br>\n", imap_errors()) . "<br>\n"; } imap_close($mbox); }
/** * Renames mailbox * * @param string $from * @param string $to * @throws DriverException */ public function renameMailbox($from, $to) { if (!imap_renamemailbox($this->resource, $this->server . $from, $this->server . $to)) { throw new DriverException("Cannot rename mailbox from '{$from}' to '{$to}': " . imap_last_error()); } }
public function renamemailbox($old, $new) { return imap_renamemailbox($this->imapStream, $this->getAccountVar('cnx') . $old, $this->getAccountVar('cnx') . $new); }
/** * mailbox_rename() * Renames a mailbox */ function mailbox_rename($oldname, $newname) { if ($this->connection == 0) { return false; } if (!imap_renamemailbox($this->connection, "\\{{$this->server}:{$this->port}}{$oldname}", "\\{{$this->server}:{$this->port}}{$newname}")) { if ($this->debug) { echo "We had problems renaming the mailbox: {$oldname} to {$newname}<br>"; echo implode("<br />\n", imap_errors()); } return false; } return true; }
function ren_mailbox($arr) { $namebox = $arr['current']; $path_delimiter = strrpos($namebox, $this->imap_delimiter) + 1; $base_path = substr($namebox, 0, $path_delimiter); $rename = preg_split("/\\/|\\./", substr($arr['rename'], $path_delimiter)); $new_box = array_shift($rename); $subfolders = $rename; $imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer']; $mbox_stream = $this->open_mbox(); $result = "Ok"; $namebox = mb_convert_encoding($namebox, "UTF7-IMAP", "UTF-8"); $new_box = mb_convert_encoding($base_path . $new_box, "UTF7-IMAP", "UTF-8"); $created = ''; if (!imap_renamemailbox($mbox_stream, "{" . $imap_server . "}{$namebox}", "{" . $imap_server . "}{$new_box}")) { $result = imap_last_error(); } /*Cria as subpastas*/ if (is_array($subfolders)) { $child = $new_box . $this->imap_delimiter; $subfolders_count = count($subfolders); for ($i = 0; $i < $subfolders_count; ++$i) { $child .= $subfolders[$i] ? $subfolders[$i] : $this->functions->getLang("New Folder"); $namebox = mb_convert_encoding($child, "UTF7-IMAP", "UTF-8"); $result = "Ok"; if (!imap_createmailbox($mbox_stream, "{" . $imap_server . "}{$namebox}")) { $result = imap_last_error(); } $created .= "[{$namebox}]"; $child .= $this->imap_delimiter; } } if ($mbox_stream) { imap_close($mbox_stream); } $namebox = mb_convert_encoding($arr['current'], "UTF7-IMAP", "UTF-8"); Logger::info('expressomail', 'renamedir', $namebox . " TO " . $new_box); if ($created != '') { Logger::info('expressomail', 'createdir', $created); } return $result; }
/** * Renames an IMAP mailbox * @param string $newName */ function renameFolder($oldName, $newName) { //$this->mailbox = "INBOX" $this->connectMailserver(); $oldConnect = $this->getConnectString('', $oldName); $newConnect = $this->getConnectString('', $newName); if (!imap_renamemailbox($this->conn, $oldConnect, $newConnect)) { $GLOBALS['log']->debug("***INBOUNDEMAIL: failed to rename mailbox [ {$oldConnect} ] to [ {$newConnect} ]"); } else { $this->mailbox = str_replace($oldName, $newName, $this->mailbox); $this->save(); $sessionFoldersString = $this->getSessionInboundFoldersString($this->server_url, $this->email_user, $this->port, $this->protocol); $sessionFoldersString = str_replace($oldName, $newName, $sessionFoldersString); $this->setSessionInboundFoldersString($this->server_url, $this->email_user, $this->port, $this->protocol, $sessionFoldersString); } }
/** * Renames the given mailbox. * * @param string $from * @param string $to * @return bool */ public function renameMailBox($from, $to) { return imap_renamemailbox($this->ressource, $from, $to); }