7cc08b1cf2924f7b340844f918c238d95f7493c8
[squirrelmail.git] / src / delete_message.php
1 <?php
2
3 /**
4 * delete_message.php
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Deletes a meesage from the IMAP server
10 *
11 * $Id$
12 */
13
14 require_once('../src/validate.php');
15 require_once('../functions/display_messages.php');
16 require_once('../functions/imap.php');
17
18 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
19
20 sqimap_mailbox_select($imapConnection, $mailbox);
21
22 sqimap_messages_delete($imapConnection, $message, $message, $mailbox);
23 if ($auto_expunge) {
24 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
25 }
26 if (!isset($saved_draft)) {
27 $saved_draft = '';
28 }
29
30 if (!isset($mail_sent)) {
31 $mail_sent = '';
32 }
33
34 $location = get_location();
35
36 if (isset($where) && isset($what)) {
37 header("Location: $location/search.php?where=" . urlencode($where) .
38 '&what=' . urlencode($what) . '&mailbox=' . urlencode($mailbox));
39 } else {
40 if (!empty($saved_draft) || !empty($mail_sent)) {
41 header("Location: $location/compose.php?mail_sent=$mail_sent&saved_draft=$saved_draft");
42 }
43 else {
44 header("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=" .
45 urlencode($mailbox));
46 }
47 }
48
49 sqimap_logout($imapConnection);
50
51 ?>