function deleteAccount($_hookValues) { $username = $_hookValues['account_lid']; $imapAdminUsername = $this->profileData['imapAdminUsername']; $imapAdminPW = $this->profileData['imapAdminPW']; if ($mbox = @imap_open($this->getMailboxString(), $imapAdminUsername, $imapAdminPW)) { $mailBoxName = "user.{$username}"; // give the admin account the rights to delete this mailbox if (imap_setacl($mbox, $mailBoxName, $imapAdminUsername, "lrswipcda")) { if (imap_deletemailbox($mbox, imap_utf7_encode("{" . $this->profileData['imapServer'] . "}{$mailBoxName}"))) { return true; } else { // not able to delete mailbox return false; } } else { // not able to set acl return false; } } else { // imap open failed return false; } }
/** * Wrapper for imap_deletemailbox(). * @param $mailbox * @return bool */ public function deleteMailbox($mailbox) { return imap_deletemailbox($this->connection->getConnection(), $mailbox); }
function imap_deletemailbox($_folderName) { $mailboxString = ExecMethod('emailadmin.bo.getMailboxString', $_folderName, 3, $this->profileID); @imap_unsubscribe($this->mbox, $mailboxString); $result = imap_deletemailbox($this->mbox, $mailboxString); #print imap_last_error(); return $result; }
/** * mailbox_delete() * Delete a mailbox from the server. */ function mailbox_delete($mailbox) { if ($this->connection == 0) { return false; } if (!imap_deletemailbox($this->connection, "\\{{$this->server}:{$this->port}}{$mailbox}")) { if ($this->debug) { echo "We had problems deleting the mailbox: {$mailbox}<br>"; echo implode("<br />\n", imap_errors()); } return false; } return true; }
public function deletemailbox($folder) { return imap_deletemailbox($this->imapStream, $this->getAccountVar('cnx') . $folder); }
/** * Deletes a folder * * @param string $id * @param string $parent is normally false * * @access public * @return boolean status - false if e.g. does not exist * @throws StatusException could throw specific SYNC_FSSTATUS_* exceptions * */ public function DeleteFolder($id, $parentid) { $imapid = $this->getImapIdFromFolderId($id); if ($imapid) { return imap_deletemailbox($this->mbox, $this->server . $imapid); } return false; }
public function deleteMailbox(Mailbox $mailbox) { if (false === imap_deletemailbox($this->resource, $this->server . $mailbox->getName())) { throw new Exception('Mailbox ' . $mailbox->getName() . ' could not be deleted'); } $this->mailboxes = $this->mailboxNames = null; }
/** * Delete a mailbox * * @param string $folder * @return bool * @access public */ function delete_mailbox($folder) { if ($this->protocol == 'POP3') { $this->errors[] = GM_NO_POP3_SUPPORT; return false; } if ($this->use_native) { $mailbox = "\\{{$this->host}}INBOX.{$folder}"; $res = imap_deletemailbox($this->mailer, $mailbox); if (!$res) { $this->errors[] = imap_last_error(); return false; } } elseif ($this->protocol == 'IMAP') { $res = $this->mailer->deleteMailbox($folder); if ($res !== true) { return false; } } return true; }
public function deleteMailbox($mailbox) { return imap_deletemailbox($this->stream, $mailbox); }
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); }
/** * Delete the specified folder. * * @param string $folder The folder to delete. * * @return NULL */ public function delete($folder) { $result = imap_deletemailbox($this->getBackend(), $this->_getBaseMbox() . $this->encodePath($folder)); if (!$result) { throw new Horde_Kolab_Storage_Exception(sprintf(Horde_Kolab_Storage_Translation::t("Deleting folder %s failed.") . ' ' . Horde_Kolab_Storage_Translation::t("Error: %s"), $this->_getBaseMbox() . $folder, imap_last_error())); } }
function deletemailbox($stream, $mailbox) { $this->folder_list_did_change(); $mailbox = $this->utf7_encode($mailbox); return imap_deletemailbox($stream, $mailbox); }
/** * Remove a folder * * @param string name * @return void * @throws peer.mail.MessagingException */ public function removeFolder($name) { if (!imap_deletemailbox($this->_hdl[0], $this->_hdl[1] . $name)) { throw new \peer\mail\MessagingException('Deleting mailbox failed', $this->_errors()); } $this->cache->remove(SKEY_FOLDER . $name); }
/** * Deletes mailbox * * @param string $name * @throws DriverException */ public function deleteMailbox($name) { if (!imap_deletemailbox($this->resource, $this->server . $name)) { throw new DriverException("Cannot delete mailbox '{$name}': " . imap_last_error()); } }
/** * remove folder * * @return bool success or not * @param $name of the folder */ public function removeFolder($name) { return imap_deletemailbox($this->imap, $this->mailbox . $name); }
function delete_mailbox($arr) { $namebox = $arr['del_past']; $imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer']; $mbox_stream = $this->mbox ? $this->mbox : $this->open_mbox(); //$del_folder = imap_deletemailbox($mbox_stream,"{".$imap_server."}INBOX.$namebox"); $result = "Ok"; $namebox = mb_convert_encoding($namebox, "UTF7-IMAP", "UTF-8"); if (!imap_deletemailbox($mbox_stream, "{" . $imap_server . "}{$namebox}")) { $result = imap_last_error(); } /* if($mbox_stream) imap_close($mbox_stream); */ Logger::info('expressomail', 'deldir', $namebox); return $result; }
/** * Deletes the specified folder * @param string $mbox "::" delimited IMAP mailbox path, ie, INBOX.saved.stuff * @return bool */ function deleteFolder($mbox) { $connectString = $this->getConnectString('', $mbox); //Remove Folder cache global $sugar_config; unlink("{$sugar_config['cache_dir']}modules/Emails/{$this->id}/folders/folders.php"); if (imap_unsubscribe($this->conn, imap_utf7_encode($connectString))) { if (imap_deletemailbox($this->conn, $connectString)) { $this->mailbox = str_replace("," . $mbox, "", $this->mailbox); $this->save(); $sessionFoldersString = $this->getSessionInboundFoldersString($this->server_url, $this->email_user, $this->port, $this->protocol); $sessionFoldersString = str_replace("," . $mbox, "", $sessionFoldersString); $this->setSessionInboundFoldersString($this->server_url, $this->email_user, $this->port, $this->protocol, $sessionFoldersString); return true; } else { echo "NOOP: could not delete folder: {$connectString}"; $GLOBALS['log']->error("*** ERROR: EMAIL2.0 - could not delete IMAP mailbox with path: [ {$connectString} ]"); return false; } } else { echo "NOOP: could not unsubscribe from folder, {$connectString} before deletion."; $GLOBALS['log']->error("*** ERROR: EMAIL2.0 - could not unsubscribe from folder, {$connectString} before deletion."); } }
/** * Deletes the specified folder * @param string $mbox "::" delimited IMAP mailbox path, ie, INBOX.saved.stuff * @return bool */ public function deleteFolder($mbox) { $returnArray = array(); if ($this->getCacheCount($mbox) > 0) { $returnArray['status'] = false; $returnArray['errorMessage'] = "Can not delete {$mbox} as it has emails."; } else { $connectString = $this->getConnectString('', $mbox); //Remove Folder cache unlink("{$this->EmailCachePath}/{$this->id}/folders/folders.php"); if (imap_unsubscribe($this->conn, imap_utf7_encode($connectString))) { if (imap_deletemailbox($this->conn, $connectString)) { $this->mailbox = str_replace("," . $mbox, "", $this->mailbox); $this->save(); $sessionFoldersString = $this->getSessionInboundFoldersString($this->server_url, $this->email_user, $this->port, $this->protocol); $sessionFoldersString = str_replace("," . $mbox, "", $sessionFoldersString); $this->setSessionInboundFoldersString($this->server_url, $this->email_user, $this->port, $this->protocol, $sessionFoldersString); $returnArray['status'] = true; } else { $GLOBALS['log']->error("*** ERROR: EMAIL2.0 - could not delete IMAP mailbox with path: [ {$connectString} ]"); $returnArray['status'] = false; $returnArray['errorMessage'] = 'ERR_DELETE_FOLDER'; } } else { $GLOBALS['log']->error("*** ERROR: EMAIL2.0 - could not unsubscribe from folder, {$connectString} before deletion."); $returnArray['status'] = false; $returnArray['errorMessage'] = 'ERR_UNSUBSCRIBE_FROM_FOLDER'; } } if (strlen($returnArray['errorMessage']) > 0) { $returnArray['errorMessage'] = translate($returnArray['errorMessage'], $this->module_name); } return $returnArray; }
/** * Deletes the given mailbox. * * @param $mailbox * * @return bool */ public function deleteMailBox($mailbox) { return imap_deletemailbox($this->getImapStream(), $this->getServerSpecification() . $mailbox); }
public function deleteMailbox($mailbox) { imap_deletemailbox($this->mbox, imap_utf7_encode($mailbox)); }
/** * 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; } }
echo "*** Testing imap_createmailbox() : basic functionality ***\n"; require_once dirname(__FILE__) . '/imap_include.inc'; $imap_stream = imap_open($default_mailbox, $username, $password) or die("Cannot connect to mailbox {$default_mailbox}: " . imap_last_error()); $newname = "phpnewbox"; echo "Newname will be '{$newname}'\n"; $newbox = imap_utf7_encode($server . $newname); if (imap_createmailbox($imap_stream, $newbox)) { echo "Add a couple of msgs to '{$newname}' mailbox\n"; populate_mailbox($imap_stream, $newbox, 2); $status = imap_status($imap_stream, $newbox, SA_ALL); if ($status) { echo "Your new mailbox '{$newname}' has the following status:\n"; echo "Messages: " . $status->messages . "\n"; echo "Recent: " . $status->recent . "\n"; echo "Unseen: " . $status->unseen . "\n"; echo "UIDnext: " . $status->uidnext . "\n"; echo "UIDvalidity: " . $status->uidvalidity . "\n"; } else { echo "imap_status on new mailbox failed: " . imap_last_error() . "\n"; } if (imap_deletemailbox($imap_stream, $newbox)) { echo "Mailbox '{$newname}' removed to restore initial state\n"; } else { echo "imap_deletemailbox on new mailbox failed: " . implode("\n", imap_errors()) . "\n"; } } else { echo "could not create new mailbox: " . implode("\n", imap_errors()) . "\n"; } imap_close($imap_stream); ?> ===Done===
/** * Deletes the specified folder * @param string $mbox "::" delimited IMAP mailbox path, ie, INBOX.saved.stuff * @return bool */ function deleteFolder($mbox) { $returnArray = array(); if ($this->getCacheCount($mbox) > 0) { $returnArray['status'] = false; $returnArray['errorMessage'] = "Can not delete {$mbox} as it has emails."; return $returnArray; } $connectString = $this->getConnectString('', $mbox); //Remove Folder cache global $sugar_config; unlink("{$this->EmailCachePath}/{$this->id}/folders/folders.php"); if (imap_unsubscribe($this->conn, imap_utf7_encode($connectString))) { if (imap_deletemailbox($this->conn, $connectString)) { $this->mailbox = str_replace("," . $mbox, "", $this->mailbox); $this->save(); $sessionFoldersString = $this->getSessionInboundFoldersString($this->server_url, $this->email_user, $this->port, $this->protocol); $sessionFoldersString = str_replace("," . $mbox, "", $sessionFoldersString); $this->setSessionInboundFoldersString($this->server_url, $this->email_user, $this->port, $this->protocol, $sessionFoldersString); $returnArray['status'] = true; return $returnArray; } else { $GLOBALS['log']->error("*** ERROR: EMAIL2.0 - could not delete IMAP mailbox with path: [ {$connectString} ]"); $returnArray['status'] = false; $returnArray['errorMessage'] = "NOOP: could not delete folder: {$connectString}"; return $returnArray; return false; } } else { $GLOBALS['log']->error("*** ERROR: EMAIL2.0 - could not unsubscribe from folder, {$connectString} before deletion."); $returnArray['status'] = false; $returnArray['errorMessage'] = "NOOP: could not unsubscribe from folder, {$connectString} before deletion."; return $returnArray; } }
/** * Deletes the given mailbox. * * @param string $name * @return bool */ public function deleteMailBox($name) { return imap_deletemailbox($this->ressource, $name); }