6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Deletes a meesage from the IMAP server
12 * @package squirrelmail
16 * Path for SquirrelMail required files.
19 define('SM_PATH','../');
21 /* SquirrelMail required files. */
22 require_once(SM_PATH
. 'include/validate.php');
23 require_once(SM_PATH
. 'functions/display_messages.php');
24 require_once(SM_PATH
. 'functions/imap.php');
27 sqgetGlobalVar('username', $username, SQ_SESSION
);
28 sqgetGlobalVar('key', $key, SQ_COOKIE
);
29 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
31 sqgetGlobalVar('message', $message, SQ_FORM
);
32 sqgetGlobalVar('mailbox', $mailbox, SQ_GET
);
34 sqgetGlobalVar('bypass_trash', $bypass_trash, SQ_FORM
);
38 if (sqGetGlobalVar('saved_draft', $tmp, SQ_GET
)) {
39 $saved_draft = urlencode($tmp);
41 if (sqGetGlobalVar('mail_sent', $tmp, SQ_GET
)) {
42 $mail_sent = urlencode($tmp);
44 if (sqGetGlobalVar('where', $tmp, SQ_FORM
)) {
45 $where = urlencode($tmp);
47 if (sqGetGlobalVar('what', $tmp, SQ_FORM
)) {
48 $what = urlencode($tmp);
50 if (sqGetGlobalVar('sort', $tmp, SQ_FORM
)) {
53 if (sqGetGlobalVar('startMessage', $tmp, SQ_FORM
)) {
54 $startMessage = (int) $tmp;
57 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
59 sqimap_mailbox_select($imapConnection, $mailbox);
61 sqimap_messages_delete($imapConnection, $message, $message, $mailbox,$bypass_trash);
63 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
65 if (!isset($saved_draft)) {
69 if (!isset($mail_sent)) {
73 $location = get_location();
75 if (isset($where) && isset($what)) {
76 header("Location: $location/search.php?where=" . $where .
77 '&what=' . $what . '&mailbox=' . urlencode($mailbox));
79 if (!empty($saved_draft) ||
!empty($mail_sent)) {
80 header("Location: $location/compose.php?mail_sent=$mail_sent&saved_draft=$saved_draft");
83 header("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=" .
88 sqimap_logout($imapConnection);