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
15 /** Path for SquirrelMail required files. */
16 define('SM_PATH','../');
18 /* SquirrelMail required files. */
19 require_once(SM_PATH
. 'include/validate.php');
20 require_once(SM_PATH
. 'functions/display_messages.php');
21 require_once(SM_PATH
. 'functions/imap.php');
24 sqgetGlobalVar('username', $username, SQ_SESSION
);
25 sqgetGlobalVar('key', $key, SQ_COOKIE
);
26 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
28 sqgetGlobalVar('message', $message, SQ_FORM
);
29 sqgetGlobalVar('mailbox', $mailbox, SQ_GET
);
31 sqgetGlobalVar('bypass_trash', $bypass_trash, SQ_FORM
);
35 if (sqGetGlobalVar('saved_draft', $tmp, SQ_GET
)) {
36 $saved_draft = urlencode($tmp);
38 if (sqGetGlobalVar('mail_sent', $tmp, SQ_GET
)) {
39 $mail_sent = urlencode($tmp);
41 if (sqGetGlobalVar('where', $tmp, SQ_FORM
)) {
42 $where = urlencode($tmp);
44 if (sqGetGlobalVar('what', $tmp, SQ_FORM
)) {
45 $what = urlencode($tmp);
47 if (sqGetGlobalVar('sort', $tmp, SQ_FORM
)) {
50 if (sqGetGlobalVar('startMessage', $tmp, SQ_FORM
)) {
51 $startMessage = (int) $tmp;
54 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
56 sqimap_mailbox_select($imapConnection, $mailbox);
58 sqimap_messages_delete($imapConnection, $message, $message, $mailbox,$bypass_trash);
60 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
62 if (!isset($saved_draft)) {
66 if (!isset($mail_sent)) {
70 $location = get_location();
72 if (isset($where) && isset($what)) {
73 header("Location: $location/search.php?where=" . $where .
74 '&what=' . $what . '&mailbox=' . urlencode($mailbox));
76 if (!empty($saved_draft) ||
!empty($mail_sent)) {
77 header("Location: $location/compose.php?mail_sent=$mail_sent&saved_draft=$saved_draft");
80 header("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=" .
85 sqimap_logout($imapConnection);