argh! (forgot to remove debug code, done now)
[squirrelmail.git] / src / retrievalerror.php
CommitLineData
a019eeb8 1<?php
2 require_once('../src/validate.php');
3 require_once("../functions/imap.php");
4 require_once("../functions/smtp.php");
5 require_once("../functions/page_header.php");
6 require_once("../src/load_prefs.php");
7
8 $destination = "retrievalerror@gm44c.xs4all.nl";
9
10 $attachments = array();
11
12
13 function ClearAttachments() {
14 global $attachments, $attachment_dir;
15
16 foreach ($attachments as $info) {
17 if (file_exists($attachment_dir . $info['localfilename'])) {
18 unlink($attachment_dir . $info['localfilename']);
19 }
20 }
21
22 $attachments = array();
23 }
24
25 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
26 sqimap_mailbox_select($imap_stream, $mailbox);
27 $sid = sqimap_session_id();
28 fputs ($imap_stream, "$sid FETCH $passed_id BODY[]\r\n");
29 $data = sqimap_read_data ($imap_stream, $sid, true, $response, $message);
30 sqimap_logout($imap_stream);
31 $topline2 = array_shift($data);
32 $thebastard = implode('', $data);
33
34
35
36 $localfilename = GenerateRandomString(32, '', 7);
37 while (file_exists($attachment_dir . $localfilename))
38 $localfilename = GenerateRandomString(32, '', 7);
39 // Write Attachment to file
40 $fp = fopen ($attachment_dir.$localfilename, 'w');
41 fputs ($fp, $thebastard);
42 fclose ($fp);
43
44 $newAttachment = array();
45 $newAttachment['localfilename'] = $localfilename;
46 $newAttachment['remotefilename'] = 'message.duh';
47 $newAttachment['type'] = 'application/octet-stream';
48 $attachments[] = $newAttachment;
49
50
51 $body = "Response: $response\n" .
52 "Message: $message\n" .
53 "FETCH line: $topline\n" .
54 "Server Type: $imap_server_type\n";
55
56 $imap_stream = fsockopen ($imapServerAddress, $imapPort, &$error_number, &$error_string);
57 $server_info = fgets ($imap_stream, 1024);
58 if ($imap_stream)
59 {
60 $body .= " Server info: $server_info";
61 fputs ($imap_stream, "a001 CAPABILITY\r\n");
62 $read = fgets($imap_stream, 1024);
63 $list = explode(' ', $read);
64 array_shift($list);
65 array_shift($list);
66 $read = implode(' ', $list);
67 $body .= " Capabilities: $read";
68 fputs ($imap_stream, "a002 LOGOUT\r\n");
69 fclose($imap_stream);
70 }
71
72 $body .= "\nFETCH line for gathering the whole message: $topline2\n";
73
74
75 sendMessage($destination, "", "", "submitted message", $body, 0);
76
77
78
79
80 displayPageHeader($color, $mailbox);
81
82 $par = "mailbox=".urlencode($mailbox)."&passed_id=$passed_id";
83 if (isset($where) && isset($what)) {
84 $par .= "&where=".urlencode($where)."&what=".urlencode($what);
85 } else {
86 $par .= "&startMessage=$startMessage&show_more=0";
87 }
88
89 echo '<BR>The message has been submitted to the developers knowledgebase!<BR>' .
90 'Thank you very much<BR>' .
91 'Please submit every message only once<BR>' .
92 "<A HREF=\"../src/read_body.php?$par\">View the message</A><BR>";
93
4a73225b 94?>