More work done on the options stuff.
[squirrelmail.git] / src / retrievalerror.php
CommitLineData
a019eeb8 1<?php
028ddc33 2 /**
3 ** retrievalerror.php
4 **
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
8 ** Submits a message which Squirrelmail couldn't handle
9 ** because of malformedness of the message
10 ** sends it to retrievalerror@squirrelmail.org
11 ** Of course, this only happens when the end user has chosen to do so
12 **
13 ** $Id$
14 **/
15
a019eeb8 16 require_once('../src/validate.php');
17 require_once("../functions/imap.php");
18 require_once("../functions/smtp.php");
19 require_once("../functions/page_header.php");
20 require_once("../src/load_prefs.php");
21
028ddc33 22 $destination = "retrievalerror@squirrelmail.org";
a019eeb8 23
24 $attachments = array();
25
26
27 function ClearAttachments() {
28 global $attachments, $attachment_dir;
29
30 foreach ($attachments as $info) {
31 if (file_exists($attachment_dir . $info['localfilename'])) {
32 unlink($attachment_dir . $info['localfilename']);
33 }
34 }
35
36 $attachments = array();
37 }
38
39 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
40 sqimap_mailbox_select($imap_stream, $mailbox);
41 $sid = sqimap_session_id();
42 fputs ($imap_stream, "$sid FETCH $passed_id BODY[]\r\n");
43 $data = sqimap_read_data ($imap_stream, $sid, true, $response, $message);
44 sqimap_logout($imap_stream);
45 $topline2 = array_shift($data);
46 $thebastard = implode('', $data);
47
48
49
50 $localfilename = GenerateRandomString(32, '', 7);
51 while (file_exists($attachment_dir . $localfilename))
52 $localfilename = GenerateRandomString(32, '', 7);
53 // Write Attachment to file
54 $fp = fopen ($attachment_dir.$localfilename, 'w');
55 fputs ($fp, $thebastard);
56 fclose ($fp);
57
58 $newAttachment = array();
59 $newAttachment['localfilename'] = $localfilename;
60 $newAttachment['remotefilename'] = 'message.duh';
61 $newAttachment['type'] = 'application/octet-stream';
62 $attachments[] = $newAttachment;
63
64
65 $body = "Response: $response\n" .
66 "Message: $message\n" .
67 "FETCH line: $topline\n" .
68 "Server Type: $imap_server_type\n";
69
70 $imap_stream = fsockopen ($imapServerAddress, $imapPort, &$error_number, &$error_string);
71 $server_info = fgets ($imap_stream, 1024);
72 if ($imap_stream)
73 {
74 $body .= " Server info: $server_info";
75 fputs ($imap_stream, "a001 CAPABILITY\r\n");
76 $read = fgets($imap_stream, 1024);
77 $list = explode(' ', $read);
78 array_shift($list);
79 array_shift($list);
80 $read = implode(' ', $list);
81 $body .= " Capabilities: $read";
82 fputs ($imap_stream, "a002 LOGOUT\r\n");
83 fclose($imap_stream);
84 }
85
86 $body .= "\nFETCH line for gathering the whole message: $topline2\n";
87
88
89 sendMessage($destination, "", "", "submitted message", $body, 0);
90
91
92
93
94 displayPageHeader($color, $mailbox);
95
96 $par = "mailbox=".urlencode($mailbox)."&passed_id=$passed_id";
97 if (isset($where) && isset($what)) {
98 $par .= "&where=".urlencode($where)."&what=".urlencode($what);
99 } else {
100 $par .= "&startMessage=$startMessage&show_more=0";
101 }
102
103 echo '<BR>The message has been submitted to the developers knowledgebase!<BR>' .
104 'Thank you very much<BR>' .
105 'Please submit every message only once<BR>' .
106 "<A HREF=\"../src/read_body.php?$par\">View the message</A><BR>";
107
028ddc33 108?>