/** * 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 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."); } }
function subscribe($_folderName, $_status) { #$this->mailPreferences['imapServerAddress'] #$this->mailPreferences['imapPort'], $folderName = $this->encodeFolderName($_folderName); $folderName = "{" . $this->mailPreferences['imapServerAddress'] . ":" . $this->mailPreferences['imapPort'] . "}" . $folderName; if ($_status == 'unsubscribe') { return imap_unsubscribe($this->mbox, $folderName); } else { return imap_subscribe($this->mbox, $folderName); } }
/** * 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; }
public function unsubscribe($mailbox) { return imap_unsubscribe($this->stream, $mailbox); }
/** * Unsubscribe a mailbox * * @param string $unsubscribe * @return bool * @access public */ function unsubscribe($mailbox) { if ($this->protocol == 'POP3') { $this->errors[] = GM_NO_POP3_SUPPORT; return false; } if ($this->use_native) { $res = imap_unsubscribe($this->mailer, $mailbox); if (!$res) { $this->errors[] = imap_last_error(); return false; } } else { $res = $this->mailer->unsubscribeMailbox($mailbox); if ($res === false) { $this->errors[] = 'mailbox could not be unsubscribed'; return false; } } return true; }