Added IMAP server information plugin called 'info'. See the README for details :)
[squirrelmail.git] / src / retrievalerror.php
1 <?php
2
3 /**
4 * retrievalerror.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 * 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 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');
22
23 $destination = 'retrievalerror@squirrelmail.org';
24 $attachments = array();
25
26 function ClearAttachments() {
27 global $attachments, $attachment_dir, $username;
28
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);
34 }
35 }
36
37 $attachments = array();
38 }
39
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);
48
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";
55 }
56
57 /* Write Attachment to file */
58 $fp = fopen ($full_localfilename, 'w');
59 fputs ($fp, $thebastard);
60 fclose ($fp);
61
62 $newAttachment = array();
63 $newAttachment['localfilename'] = $localfilename;
64 $newAttachment['remotefilename'] = 'message.duh';
65 $newAttachment['type'] = 'application/octet-stream';
66 $attachments[] = $newAttachment;
67
68 $body = "Response: $response\n" .
69 "Message: $message\n" .
70 "FETCH line: $topline\n" .
71 "Server Type: $imap_server_type\n";
72
73 $imap_stream = fsockopen ($imapServerAddress, $imapPort, &$error_number, &$error_string);
74 $server_info = fgets ($imap_stream, 1024);
75 if ($imap_stream) {
76 $body .= " Server info: $server_info";
77 fputs ($imap_stream, "a001 CAPABILITY\r\n");
78 $read = fgets($imap_stream, 1024);
79 $list = explode(' ', $read);
80 array_shift($list);
81 array_shift($list);
82 $read = implode(' ', $list);
83 $body .= " Capabilities: $read";
84 fputs ($imap_stream, "a002 LOGOUT\r\n");
85 fclose($imap_stream);
86 }
87
88 $body .= "\nFETCH line for gathering the whole message: $topline2\n";
89
90 sendMessage($destination, '', '', 'submitted message', $body, False, 0);
91
92 displayPageHeader($color, $mailbox);
93
94 $par = 'mailbox='.urlencode($mailbox)."&amp;passed_id=$passed_id";
95 if (isset($where) && isset($what)) {
96 $par .= '&amp;where='.urlencode($where).'&amp;what='.urlencode($what);
97 } else {
98 $par .= "&amp;startMessage=$startMessage&amp;show_more=0";
99 }
100
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>";
105
106 ?>