6 ** Copyright (c) 1999-2001 The SquirrelMail development team
7 ** Licensed under the GNU GPL. For full terms see the file COPYING.
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
17 require_once('../src/validate.php');
18 require_once("../functions/imap.php");
19 require_once("../functions/smtp.php");
20 require_once("../functions/page_header.php");
21 require_once("../src/load_prefs.php");
23 $destination = "retrievalerror@squirrelmail.org";
25 $attachments = array();
28 function ClearAttachments() {
29 global $attachments, $attachment_dir;
31 foreach ($attachments as $info) {
32 if (file_exists($attachment_dir . $info['localfilename'])) {
33 unlink($attachment_dir . $info['localfilename']);
37 $attachments = array();
40 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
41 sqimap_mailbox_select($imap_stream, $mailbox);
42 $sid = sqimap_session_id();
43 fputs ($imap_stream, "$sid FETCH $passed_id BODY[]\r\n");
44 $data = sqimap_read_data ($imap_stream, $sid, true, $response, $message);
45 sqimap_logout($imap_stream);
46 $topline2 = array_shift($data);
47 $thebastard = implode('', $data);
51 $localfilename = GenerateRandomString(32, '', 7);
52 while (file_exists($attachment_dir . $localfilename))
53 $localfilename = GenerateRandomString(32, '', 7);
54 // Write Attachment to file
55 $fp = fopen ($attachment_dir.$localfilename, 'w');
56 fputs ($fp, $thebastard);
59 $newAttachment = array();
60 $newAttachment['localfilename'] = $localfilename;
61 $newAttachment['remotefilename'] = 'message.duh';
62 $newAttachment['type'] = 'application/octet-stream';
63 $attachments[] = $newAttachment;
66 $body = "Response: $response\n" .
67 "Message: $message\n" .
68 "FETCH line: $topline\n" .
69 "Server Type: $imap_server_type\n";
71 $imap_stream = fsockopen ($imapServerAddress, $imapPort, &$error_number, &$error_string);
72 $server_info = fgets ($imap_stream, 1024);
75 $body .= " Server info: $server_info";
76 fputs ($imap_stream, "a001 CAPABILITY\r\n");
77 $read = fgets($imap_stream, 1024);
78 $list = explode(' ', $read);
81 $read = implode(' ', $list);
82 $body .= " Capabilities: $read";
83 fputs ($imap_stream, "a002 LOGOUT\r\n");
87 $body .= "\nFETCH line for gathering the whole message: $topline2\n";
90 sendMessage($destination, "", "", "submitted message", $body, 0);
95 displayPageHeader($color, $mailbox);
97 $par = "mailbox=".urlencode($mailbox)."&passed_id=$passed_id";
98 if (isset($where) && isset($what)) {
99 $par .= "&where=".urlencode($where)."&what=".urlencode($what);
101 $par .= "&startMessage=$startMessage&show_more=0";
104 echo '<BR>The message has been submitted to the developers knowledgebase!<BR>' .
105 'Thank you very much<BR>' .
106 'Please submit every message only once<BR>' .
107 "<A HREF=\"../src/read_body.php?$par\">View the message</A><BR>";