a019eeb8 |
1 | <?php |
895905c0 |
2 | |
028ddc33 |
3 | /** |
4 | ** retrievalerror.php |
5 | ** |
895905c0 |
6 | ** Copyright (c) 1999-2001 The SquirrelMail development team |
028ddc33 |
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 | |
a019eeb8 |
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 | |
028ddc33 |
23 | $destination = "retrievalerror@squirrelmail.org"; |
a019eeb8 |
24 | |
25 | $attachments = array(); |
26 | |
27 | |
28 | function ClearAttachments() { |
29 | global $attachments, $attachment_dir; |
30 | |
31 | foreach ($attachments as $info) { |
32 | if (file_exists($attachment_dir . $info['localfilename'])) { |
33 | unlink($attachment_dir . $info['localfilename']); |
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 | |
50 | |
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); |
57 | fclose ($fp); |
58 | |
59 | $newAttachment = array(); |
60 | $newAttachment['localfilename'] = $localfilename; |
61 | $newAttachment['remotefilename'] = 'message.duh'; |
62 | $newAttachment['type'] = 'application/octet-stream'; |
63 | $attachments[] = $newAttachment; |
64 | |
65 | |
66 | $body = "Response: $response\n" . |
67 | "Message: $message\n" . |
68 | "FETCH line: $topline\n" . |
69 | "Server Type: $imap_server_type\n"; |
70 | |
71 | $imap_stream = fsockopen ($imapServerAddress, $imapPort, &$error_number, &$error_string); |
72 | $server_info = fgets ($imap_stream, 1024); |
73 | if ($imap_stream) |
74 | { |
75 | $body .= " Server info: $server_info"; |
76 | fputs ($imap_stream, "a001 CAPABILITY\r\n"); |
77 | $read = fgets($imap_stream, 1024); |
78 | $list = explode(' ', $read); |
79 | array_shift($list); |
80 | array_shift($list); |
81 | $read = implode(' ', $list); |
82 | $body .= " Capabilities: $read"; |
83 | fputs ($imap_stream, "a002 LOGOUT\r\n"); |
84 | fclose($imap_stream); |
85 | } |
86 | |
87 | $body .= "\nFETCH line for gathering the whole message: $topline2\n"; |
88 | |
89 | |
90 | sendMessage($destination, "", "", "submitted message", $body, 0); |
91 | |
92 | |
93 | |
94 | |
95 | displayPageHeader($color, $mailbox); |
96 | |
97 | $par = "mailbox=".urlencode($mailbox)."&passed_id=$passed_id"; |
98 | if (isset($where) && isset($what)) { |
99 | $par .= "&where=".urlencode($where)."&what=".urlencode($what); |
100 | } else { |
101 | $par .= "&startMessage=$startMessage&show_more=0"; |
102 | } |
103 | |
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>"; |
108 | |
028ddc33 |
109 | ?> |