Getting ready for 1.2.0 release.
[squirrelmail.git] / src / retrievalerror.php
CommitLineData
a019eeb8 1<?php
895905c0 2
35586184 3/**
4 * retrievalerror.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Submits a message which Squirrelmail couldn't handle
10 * because of malformedness of the message
11 * sends it to retrievalerror@squirrelmail.org
12 * Of course, this only happens when the end user has chosen to do so
13 *
14 * $Id$
15 */
16
17/*****************************************************************/
18/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
19/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
20/*** + Base level indent should begin at left margin, as ***/
21/*** the require_once below looks. ***/
22/*** + All identation should consist of four space blocks ***/
23/*** + Tab characters are evil. ***/
24/*** + all comments should use "slash-star ... star-slash" ***/
25/*** style -- no pound characters, no slash-slash style ***/
26/*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
27/*** ALWAYS USE { AND } CHARACTERS!!! ***/
28/*** + Please use ' instead of ", when possible. Note " ***/
29/*** should always be used in _( ) function calls. ***/
30/*** Thank you for your help making the SM code more readable. ***/
31/*****************************************************************/
32
33require_once('../src/validate.php');
34require_once("../functions/imap.php");
35require_once("../functions/smtp.php");
36require_once("../functions/page_header.php");
37require_once("../src/load_prefs.php");
a019eeb8 38
028ddc33 39 $destination = "retrievalerror@squirrelmail.org";
a019eeb8 40
41 $attachments = array();
42
43
44 function ClearAttachments() {
3392dc86 45 global $attachments, $attachment_dir, $username;
a019eeb8 46
3392dc86 47 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
a019eeb8 48 foreach ($attachments as $info) {
3392dc86 49 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
50 if (file_exists($attached_file)) {
51 unlink($attached_file);
a019eeb8 52 }
53 }
54
55 $attachments = array();
56 }
57
58 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
59 sqimap_mailbox_select($imap_stream, $mailbox);
60 $sid = sqimap_session_id();
61 fputs ($imap_stream, "$sid FETCH $passed_id BODY[]\r\n");
62 $data = sqimap_read_data ($imap_stream, $sid, true, $response, $message);
63 sqimap_logout($imap_stream);
64 $topline2 = array_shift($data);
65 $thebastard = implode('', $data);
66
67
3392dc86 68 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
a019eeb8 69 $localfilename = GenerateRandomString(32, '', 7);
3392dc86 70 $full_localfilename = "$hashed_attachment_dir/$localfilename";
71 while (file_exists($full_localfilename)) {
a019eeb8 72 $localfilename = GenerateRandomString(32, '', 7);
3392dc86 73 $full_localfilename = "$hashed_attachment_dir/$localfilename";
74 }
75
a019eeb8 76 // Write Attachment to file
3392dc86 77 $fp = fopen ($full_localfilename, 'w');
a019eeb8 78 fputs ($fp, $thebastard);
79 fclose ($fp);
80
81 $newAttachment = array();
82 $newAttachment['localfilename'] = $localfilename;
83 $newAttachment['remotefilename'] = 'message.duh';
84 $newAttachment['type'] = 'application/octet-stream';
85 $attachments[] = $newAttachment;
86
87
88 $body = "Response: $response\n" .
89 "Message: $message\n" .
90 "FETCH line: $topline\n" .
91 "Server Type: $imap_server_type\n";
92
93 $imap_stream = fsockopen ($imapServerAddress, $imapPort, &$error_number, &$error_string);
94 $server_info = fgets ($imap_stream, 1024);
95 if ($imap_stream)
96 {
97 $body .= " Server info: $server_info";
98 fputs ($imap_stream, "a001 CAPABILITY\r\n");
99 $read = fgets($imap_stream, 1024);
100 $list = explode(' ', $read);
101 array_shift($list);
102 array_shift($list);
103 $read = implode(' ', $list);
104 $body .= " Capabilities: $read";
105 fputs ($imap_stream, "a002 LOGOUT\r\n");
106 fclose($imap_stream);
107 }
108
109 $body .= "\nFETCH line for gathering the whole message: $topline2\n";
110
111
112 sendMessage($destination, "", "", "submitted message", $body, 0);
113
114
115
116
117 displayPageHeader($color, $mailbox);
118
119 $par = "mailbox=".urlencode($mailbox)."&passed_id=$passed_id";
120 if (isset($where) && isset($what)) {
121 $par .= "&where=".urlencode($where)."&what=".urlencode($what);
122 } else {
123 $par .= "&startMessage=$startMessage&show_more=0";
124 }
125
126 echo '<BR>The message has been submitted to the developers knowledgebase!<BR>' .
127 'Thank you very much<BR>' .
128 'Please submit every message only once<BR>' .
129 "<A HREF=\"../src/read_body.php?$par\">View the message</A><BR>";
130
028ddc33 131?>