6 * Copyright (c) 1999-2002 The SquirrelMail Project 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';
24 $attachments = array();
26 function ClearAttachments() {
27 global $attachments, $attachment_dir, $username;
29 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
30 foreach ($attachments as $info) {
31 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
32 if (file_exists($attached_file)) {
33 unlink($attached_file);
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);
49 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
50 $localfilename = GenerateRandomString(32, '', 7);
51 $full_localfilename = "$hashed_attachment_dir/$localfilename";
52 while (file_exists($full_localfilename)) {
53 $localfilename = GenerateRandomString(32, '', 7);
54 $full_localfilename = "$hashed_attachment_dir/$localfilename";
57 /* Write Attachment to file */
58 $fp = fopen ($full_localfilename, 'w');
59 fputs ($fp, $thebastard);
62 $newAttachment = array();
63 $newAttachment['localfilename'] = $localfilename;
64 $newAttachment['remotefilename'] = 'message.duh';
65 $newAttachment['type'] = 'application/octet-stream';
66 $attachments[] = $newAttachment;
68 $body = "Response: $response\n" .
69 "Message: $message\n" .
70 "FETCH line: $topline\n" .
71 "Server Type: $imap_server_type\n";
73 $imap_stream = fsockopen ($imapServerAddress, $imapPort, &$error_number, &$error_string);
74 $server_info = fgets ($imap_stream, 1024);
76 $body .= " Server info: $server_info";
77 fputs ($imap_stream, "a001 CAPABILITY\r\n");
78 $read = fgets($imap_stream, 1024);
79 $list = explode(' ', $read);
82 $read = implode(' ', $list);
83 $body .= " Capabilities: $read";
84 fputs ($imap_stream, "a002 LOGOUT\r\n");
88 $body .= "\nFETCH line for gathering the whole message: $topline2\n";
90 sendMessage($destination, '', '', 'submitted message', $body, False, 0);
92 displayPageHeader($color, $mailbox);
94 $par = 'mailbox='.urlencode($mailbox)."&passed_id=$passed_id";
95 if (isset($where) && isset($what)) {
96 $par .= '&where='.urlencode($where).'&what='.urlencode($what);
98 $par .= "&startMessage=$startMessage&show_more=0";
101 echo '<BR>The message has been submitted to the developers knowledgebase!<BR>' .
102 'Thank you very much<BR>' .
103 'Please submit every message only once<BR>' .
104 "<A HREF=\"../src/read_body.php?$par\">View the message</A><BR>";