updated dutch translation
[squirrelmail.git] / src / compose.php
CommitLineData
59177427 1<?php
ef870322 2 /**
3 ** compose.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 ** This code sends a mail.
df15de21 9 **
10 ** There are 3 modes of operation:
11 ** - Start new mail
12 ** - Add an attachment
13 ** - Send mail
245a6892 14 **
15 ** $Id$
df15de21 16 **/
f7fb20fe 17
f740c049 18 include('../src/validate.php');
f740c049 19 include("../functions/imap.php");
20 include("../functions/date.php");
21 include("../functions/mime.php");
22 include("../functions/smtp.php");
23 include("../functions/display_messages.php");
24 include ("../functions/plugin.php");
8467bf00 25
79be8a0b 26 if (!isset($attachments))
f972eb46 27 {
79be8a0b 28 $attachments = array();
f972eb46 29 session_register('attachments');
30 }
a98bed68 31
d7981cd8 32
4ba45d11 33 // This function is used when not sending or adding attachments
df15de21 34 function newMail () {
35 global $forward_id, $imapConnection, $msg, $ent_num, $body_ary, $body,
a794e82c 36 $reply_id, $send_to, $send_to_cc, $mailbox, $send_to_bcc, $editor_size;
e39d73e5 37
d51894be 38 $send_to = decodeHeader($send_to);
39 $send_to_cc = decodeHeader($send_to_cc);
40 $send_to_bcc = decodeHeader($send_to_bcc);
a53e5469 41
429f8906 42 if ($forward_id)
43 $id = $forward_id;
3b5b889f 44 elseif ($reply_id)
429f8906 45 $id = $reply_id;
46
1195c340 47
245a6892 48 if (isset($id)) {
813eba2f 49 sqimap_mailbox_select($imapConnection, $mailbox);
429f8906 50 $message = sqimap_get_message($imapConnection, $id, $mailbox);
8d8ab69a 51 $orig_header = $message->header;
1195c340 52 if ($ent_num)
53 $message = getEntity($message, $ent_num);
429f8906 54
55 if ($message->header->type0 == "text" || $message->header->type1 == "message") {
1195c340 56 if ($ent_num)
57 $body = decodeBody(mime_fetch_body($imapConnection, $id, $ent_num), $message->header->encoding);
58 else
59 $body = decodeBody(mime_fetch_body($imapConnection, $id, 1), $message->header->encoding);
429f8906 60 } else {
61 $body = "";
df15de21 62 }
f923b93d 63
429f8906 64 if ($message->header->type1 == "html")
65 $body = strip_tags($body);
f82d9be2 66
01aab860 67 sqUnWordWrap($body);
a794e82c 68 $body_ary = explode("\n", $body);
fb6ce88e 69 $i = count($body_ary) - 1;
3bc5ef2d 70 while ($i >= 0 && ereg("^[>\\s]*$", $body_ary[$i])) {
fb6ce88e 71 unset($body_ary[$i]);
72 $i --;
441f2d33 73 }
a794e82c 74 $body = "";
3bc5ef2d 75 for ($i=0; isset($body_ary[$i]); $i++) {
01aab860 76 if (! $forward_id)
77 {
59a29c4b 78 if (ereg('^[ >]+', $body_ary[$i]))
01aab860 79 {
80 $body_ary[$i] = '>' . $body_ary[$i];
81 }
82 else
83 {
84 $body_ary[$i] = '> ' . $body_ary[$i];
85 }
86 }
a794e82c 87 sqWordWrap($body_ary[$i], $editor_size - 1);
01aab860 88 $body .= $body_ary[$i] . "\n";
f923b93d 89 unset($body_ary[$i]);
a794e82c 90 }
01aab860 91 if ($forward_id)
92 {
93 $bodyTop = "-------- " . _("Original Message") . " --------\n";
94 $bodyTop .= _("Subject") . ": " . $orig_header->subject . "\n";
95 $bodyTop .= _("From") . ": " . $orig_header->from . "\n";
96 $bodyTop .= _("To") . ": " . $orig_header->to[0] . "\n";
97 if (count($orig_header->to) > 1) {
98 for ($x=1; $x < count($orig_header->to); $x++) {
99 $bodyTop .= " " . $orig_header->to[$x] . "\n";
100 }
101 }
102 $bodyTop .= "\n";
103 $body = $bodyTop . $body;
78509c54 104 }
441f2d33 105
01aab860 106 return;
78509c54 107 }
429f8906 108
29d08a52 109 if (!$send_to) {
110 $send_to = sqimap_find_email($send_to);
111 }
112
df15de21 113 /** This formats a CC string if they hit "reply all" **/
114 if ($send_to_cc != "") {
a48fbf9b 115 $send_to_cc = ereg_replace( '"[^"]*"', "", $send_to_cc);
df15de21 116 $send_to_cc = ereg_replace(";", ",", $send_to_cc);
117 $sendcc = explode(",", $send_to_cc);
118 $send_to_cc = "";
119
120 for ($i = 0; $i < count($sendcc); $i++) {
121 $sendcc[$i] = trim($sendcc[$i]);
122 if ($sendcc[$i] == "")
123 continue;
124
a53e5469 125 $sendcc[$i] = sqimap_find_email($sendcc[$i]);
813eba2f 126 $whofrom = sqimap_find_displayable_name($msg["HEADER"]["FROM"]);
127 $whoreplyto = sqimap_find_email($msg["HEADER"]["REPLYTO"]);
df15de21 128
129 if ((strtolower(trim($sendcc[$i])) != strtolower(trim($whofrom))) &&
130 (strtolower(trim($sendcc[$i])) != strtolower(trim($whoreplyto))) &&
131 (trim($sendcc[$i]) != "")) {
132 $send_to_cc .= trim($sendcc[$i]) . ", ";
133 }
134 }
135 $send_to_cc = trim($send_to_cc);
136 if (substr($send_to_cc, -1) == ",") {
137 $send_to_cc = substr($send_to_cc, 0, strlen($send_to_cc) - 1);
138 }
139 }
140 } // function newMail()
78509c54 141
5713b4f9 142 function getAttachments($message) {
143 global $mailbox, $attachments, $attachment_dir, $imapConnection,
144 $ent_num, $forward_id;
f972eb46 145
5713b4f9 146 if (!$message) {
147 sqimap_mailbox_select($imapConnection, $mailbox);
991a059e 148 $message = sqimap_get_message($imapConnection, $forward_id,
f923b93d 149 $mailbox);
991a059e 150 }
5713b4f9 151
991a059e 152 if (count($message->entities) == 0) {
153 if ($message->header->entity_id != $ent_num) {
154 $filename = decodeHeader($message->header->filename);
5713b4f9 155
991a059e 156 if ($filename == "")
157 $filename = "untitled-".$message->header->entity_id;
5713b4f9 158
991a059e 159 $localfilename = GenerateRandomString(32, '', 7);
f923b93d 160 while (file_exists($attachment_dir . $localfilename))
161 $localfilename = GenerateRandomString(32, '', 7);
f972eb46 162
163 $newAttachment['localfilename'] = $localfilename;
f923b93d 164 $newAttachment['remotefilename'] = $filename;
165 $newAttachment['type'] = strtolower($message->header->type0 .
166 '/' . $message->header->type1);
991a059e 167
168 // Write Attachment to file
f972eb46 169 $fp = fopen ($attachment_dir.$localfilename, 'w');
991a059e 170 fputs ($fp, decodeBody(mime_fetch_body($imapConnection,
f923b93d 171 $forward_id, $message->header->entity_id),
172 $message->header->encoding));
991a059e 173 fclose ($fp);
5713b4f9 174
f972eb46 175 $attachments[] = $newAttachment;
991a059e 176 }
5713b4f9 177 } else {
991a059e 178 for ($i = 0; $i < count($message->entities); $i++) {
5713b4f9 179 getAttachments($message->entities[$i]);
991a059e 180 }
5713b4f9 181 }
182 return;
991a059e 183 }
5713b4f9 184
df15de21 185 function showInputForm () {
186 global $send_to, $send_to_cc, $reply_subj, $forward_subj, $body,
b8163cc4 187 $passed_body, $color, $use_signature, $signature, $prefix_sig,
188 $editor_size, $attachments, $subject, $newmail,
189 $use_javascript_addr_book, $send_to_bcc, $reply_id, $mailbox,
aaf9abef 190 $from_htmladdr_search, $location_of_buttons, $attachment_dir,
191 $username, $data_dir, $identity;
78509c54 192
d51894be 193 $subject = decodeHeader($subject);
2e434774 194 $reply_subj = decodeHeader($reply_subj);
195 $forward_subj = decodeHeader($forward_subj);
01aab860 196
3806fa52 197 if ($use_javascript_addr_book) {
198 echo "\n<SCRIPT LANGUAGE=JavaScript><!--\n";
199 echo "function open_abook() { \n";
200 echo " var nwin = window.open(\"addrbook_popup.php\",\"abookpopup\",";
201 echo "\"width=670,height=300,resizable=yes,scrollbars=yes\");\n";
202 echo " if((!nwin.opener) && (document.windows != null))\n";
203 echo " nwin.opener = document.windows;\n";
204 echo "}\n";
205 echo "// --></SCRIPT>\n\n";
206 }
5100704d 207
b3911477 208 echo "\n<FORM name=compose action=\"compose.php\" METHOD=POST ENCTYPE=\"multipart/form-data\"";
209 do_hook("compose_form");
f923b93d 210 echo ">\n";
966286ae 211 if ($reply_id) {
212 echo "<input type=hidden name=reply_id value=$reply_id>\n";
6e79bfe2 213 }
cf8758c7 214 printf("<INPUT TYPE=hidden NAME=mailbox VALUE=\"%s\">\n", htmlspecialchars($mailbox));
c5d828b3 215 echo "<TABLE WIDTH=\"100%\" ALIGN=center CELLSPACING=0 BORDER=0>\n";
441f2d33 216
217 if ($location_of_buttons == 'top') showComposeButtonRow();
218
aaf9abef 219 $idents = getPref($data_dir, $username, 'identities');
220 if ($idents != '' && $idents > 1)
221 {
222 echo " <TR>\n";
e7db48af 223 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=\"10%\" ALIGN=RIGHT>\n";
aaf9abef 224 echo _("From:");
e7db48af 225 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=\"90%\">\n";
aaf9abef 226 echo "<select name=identity>\n";
227 echo "<option value=default>" .
228 htmlspecialchars(getPref($data_dir, $username, 'full_name'));
229 $em = getPref($data_dir, $username, 'email_address');
230 if ($em != '')
231 echo htmlspecialchars(' <' . $em . '>') . "\n";
232 for ($i = 1; $i < $idents; $i ++) {
233 echo '<option value="' . $i . '"';
234 if (isset($identity) && $identity == $i)
235 echo ' SELECTED';
236 echo '>';
237 echo htmlspecialchars(getPref($data_dir, $username, 'full_name' .
238 $i));
239 $em = getPref($data_dir, $username, 'email_address' . $i);
240 if ($em != '')
241 echo htmlspecialchars(' <' . $em . '>') . "\n";
242 }
243 echo "</select>\n";
244 echo " </TD>\n";
245 echo " </TR>\n";
246 }
df15de21 247 echo " <TR>\n";
e7db48af 248 echo " <TD BGCOLOR=\"$color[4]\" WIDTH=\"10%\" ALIGN=RIGHT>\n";
df15de21 249 echo _("To:");
e7db48af 250 echo " </TD><TD BGCOLOR=\"$color[4]\" WIDTH=\"90%\">\n";
cf8758c7 251 printf(" <INPUT TYPE=text NAME=\"send_to\" VALUE=\"%s\" SIZE=60><BR>\n",
6e79bfe2 252 htmlspecialchars($send_to));
df15de21 253 echo " </TD>\n";
254 echo " </TR>\n";
255 echo " <TR>\n";
c5d828b3 256 echo " <TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
aae41ae9 257 echo _("CC:");
c5d828b3 258 echo " </TD><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
cf8758c7 259 printf(" <INPUT TYPE=text NAME=\"send_to_cc\" SIZE=60 VALUE=\"%s\"><BR>\n",
6e79bfe2 260 htmlspecialchars($send_to_cc));
df15de21 261 echo " </TD>\n";
262 echo " </TR>\n";
263 echo " <TR>\n";
c5d828b3 264 echo " <TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
aae41ae9 265 echo _("BCC:");
761d149e 266 echo " </TD><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
cf8758c7 267 printf(" <INPUT TYPE=text NAME=\"send_to_bcc\" VALUE=\"%s\" SIZE=60><BR>\n",
6e79bfe2 268 htmlspecialchars($send_to_bcc));
3806fa52 269 echo "</TD></TR>\n";
5100704d 270
df15de21 271 echo " <TR>\n";
c5d828b3 272 echo " <TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
df15de21 273 echo _("Subject:");
761d149e 274 echo " </TD><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n";
df15de21 275 if ($reply_subj) {
276 $reply_subj = str_replace("\"", "'", $reply_subj);
df15de21 277 $reply_subj = trim($reply_subj);
278 if (substr(strtolower($reply_subj), 0, 3) != "re:")
279 $reply_subj = "Re: $reply_subj";
cf8758c7 280 printf(" <INPUT TYPE=text NAME=subject SIZE=60 VALUE=\"%s\">",
6e79bfe2 281 htmlspecialchars($reply_subj));
df15de21 282 } else if ($forward_subj) {
df15de21 283 $forward_subj = trim($forward_subj);
f972eb46 284 if ((substr(strtolower($forward_subj), 0, 4) != 'fwd:') &&
285 (substr(strtolower($forward_subj), 0, 5) != '[fwd:') &&
286 (substr(strtolower($forward_subj), 0, 6) != '[ fwd:'))
df15de21 287 $forward_subj = "[Fwd: $forward_subj]";
cf8758c7 288 printf(" <INPUT TYPE=text NAME=subject SIZE=60 VALUE=\"%s\">",
6e79bfe2 289 htmlspecialchars($forward_subj));
df15de21 290 } else {
6e79bfe2 291 printf(" <INPUT TYPE=text NAME=subject SIZE=60 VALUE=\"%s\">",
292 htmlspecialchars($subject));
31f3d7c0 293 }
480feea7 294 echo "</td></tr>\n\n";
295
441f2d33 296 if ($location_of_buttons == 'between') showComposeButtonRow();
4ba45d11 297
e5b23ff2 298 echo " <TR>\n";
c5d828b3 299 echo " <TD BGCOLOR=\"$color[4]\" COLSPAN=2>\n";
cf8758c7 300 echo " &nbsp;&nbsp;<TEXTAREA NAME=body ROWS=20 COLS=\"$editor_size\" WRAP=HARD>";
441f2d33 301 echo htmlspecialchars($body);
6e79bfe2 302 if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) {
b8163cc4 303 if ( $prefix_sig == true )
304 echo "\n\n-- \n" . htmlspecialchars($signature);
305 else
306 echo "\n\n" . htmlspecialchars($signature);
cf8758c7 307 }
308 echo "</TEXTAREA><BR>\n";
e5b23ff2 309 echo " </TD>\n";
310 echo " </TR>\n";
441f2d33 311
312 if ($location_of_buttons == 'bottom')
313 showComposeButtonRow();
314 else {
315 echo " <TR><TD>&nbsp;</TD><TD ALIGN=LEFT><INPUT TYPE=SUBMIT NAME=send VALUE=\""._("Send")."\"></TD></TR>\n";
316 }
e5b23ff2 317
4ba45d11 318 // This code is for attachments
a98bed68 319 echo " <tr>\n";
320 echo " <TD BGCOLOR=\"$color[0]\" VALIGN=TOP ALIGN=RIGHT>\n";
321 echo " <SMALL><BR></SMALL>"._("Attach:");
322 echo " </td><td ALIGN=left BGCOLOR=\"$color[0]\">\n";
944eb785 323 echo " <INPUT NAME=\"attachfile\" SIZE=48 TYPE=\"file\">\n";
95de6c91 324 echo " &nbsp;&nbsp;<input type=\"submit\" name=\"attach\"";
325 echo " value=\"" . _("Add") ."\">\n";
469eb37b 326 echo " </td>\n";
469eb37b 327 echo " </tr>\n";
f972eb46 328 if (count($attachments))
329 {
a98bed68 330 echo "<tr><td bgcolor=\"$color[0]\" align=right>\n";
e5b23ff2 331 echo "&nbsp;";
a98bed68 332 echo "</td><td align=left bgcolor=\"$color[0]\">";
f923b93d 333 foreach ($attachments as $key => $info) {
f972eb46 334 echo "<input type=\"checkbox\" name=\"delete[]\" value=\"$key\">\n";
f923b93d 335 echo $info['remotefilename'] . " - " . $info['type'] . " (";
336 echo show_readable_size(filesize($attachment_dir .
337 $info['localfilename'])) . ")<br>\n";
4ba45d11 338 }
339
340 echo "<input type=\"submit\" name=\"do_delete\" value=\""._("Delete selected attachments")."\">\n";
469eb37b 341 echo "</td></tr>";
4ba45d11 342 }
4ba45d11 343 // End of attachment code
344
ffc2ccbc 345 echo "</TABLE>\n";
df15de21 346 echo "</FORM>";
d7d3c4d4 347 do_hook("compose_bottom");
31f3d7c0 348 }
441f2d33 349
350 function showComposeButtonRow() {
2037f4f3 351 global $use_javascript_addr_book;
f972eb46 352
441f2d33 353 echo " <TR><td>\n </td><td>\n";
354 if ($use_javascript_addr_book) {
355 echo " <SCRIPT LANGUAGE=JavaScript><!--\n document.write(\"";
356 echo " <input type=button value=\\\""._("Addresses")."\\\" onclick='javascript:open_abook();'>\");";
357 echo " // --></SCRIPT><NOSCRIPT>\n";
358 echo " <input type=submit name=\"html_addr_search\" value=\""._("Addresses")."\">";
359 echo " </NOSCRIPT>\n";
360 } else {
361 echo " <input type=submit name=\"html_addr_search\" value=\""._("Addresses")."\">";
362 }
363 echo "\n <INPUT TYPE=SUBMIT NAME=send VALUE=\"". _("Send") . "\">\n";
364
365 do_hook("compose_button_row");
366
367 echo " </TD>\n";
368 echo " </TR>\n\n";
369 }
8467bf00 370
0ad7dbda 371 function checkInput ($show) {
372 /** I implemented the $show variable because the error messages
373 were getting sent before the page header. So, I check once
374 using $show=false, and then when i'm ready to display the
375 error message, show=true **/
376 global $body, $send_to, $subject, $color;
b278172f 377
99fa2b21 378 if ($send_to == "") {
0ad7dbda 379 if ($show)
380 plain_error_message(_("You have not filled in the \"To:\" field."), $color);
df15de21 381 return false;
b278172f 382 }
df15de21 383 return true;
384 } // function checkInput()
385
3806fa52 386
056ddad7 387 // True if FAILURE
388 function saveAttachedFiles() {
389 global $HTTP_POST_FILES, $attachment_dir, $attachments;
390
056ddad7 391 $localfilename = GenerateRandomString(32, '', 7);
f972eb46 392 while (file_exists($attachment_dir . $localfilename))
a4fe5de0 393 $localfilename = GenerateRandomString(32, '', 7);
f972eb46 394
056ddad7 395 if (!@rename($HTTP_POST_FILES['attachfile']['tmp_name'], $attachment_dir.$localfilename)) {
396 if (!@copy($HTTP_POST_FILES['attachfile']['tmp_name'], $attachment_dir.$localfilename)) {
397 return true;
398 }
399 }
f972eb46 400
401 $newAttachment['localfilename'] = $localfilename;
402 $newAttachment['remotefilename'] = $HTTP_POST_FILES['attachfile']['name'];
403 $newAttachment['type'] =
404 strtolower($HTTP_POST_FILES['attachfile']['type']);
056ddad7 405
f972eb46 406 $attachments[] = $newAttachment;
056ddad7 407 }
068acdf9 408
23fd3c8e 409 if (!isset($mailbox) || $mailbox == "" || ($mailbox == "None"))
dcb7f454 410 $mailbox = "INBOX";
3806fa52 411
f972eb46 412 if (isset($send)) {
245a6892 413 if (isset($HTTP_POST_FILES['attachfile']) &&
414 $HTTP_POST_FILES['attachfile']['tmp_name'] &&
78b4216e 415 $HTTP_POST_FILES['attachfile']['tmp_name'] != 'none')
056ddad7 416 $AttachFailure = saveAttachedFiles();
a7ea7540 417 if (checkInput(false) && !isset($AttachFailure)) {
35d520d3 418 $urlMailbox = urlencode (trim($mailbox));
419 if (! isset($reply_id))
420 $reply_id = 0;
ebab5342 421 // Set $default_charset to correspond with the user's selection
f923b93d 422 // of language interface.
423 set_my_charset();
424 do_hook("compose_send");
425
f95d9e7b 426 if (! sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id)) {
427 showInputForm();
428 exit();
429 }
430 Header("Location: right_main.php?mailbox=$urlMailbox&sort=$sort&startMessage=1");
df15de21 431 } else {
01aab860 432 //$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
dcb7f454 433 displayPageHeader($color, $mailbox);
056ddad7 434
435 if ($AttachFailure)
436 plain_error_message(_("Could not move/copy file. File not attached"), $color);
437
0ad7dbda 438 checkInput(true);
439
df15de21 440 showInputForm();
01aab860 441 //sqimap_logout($imapConnection);
7c6cb7ca 442 }
245a6892 443 } else if (isset($html_addr_search_done)) {
dcb7f454 444 displayPageHeader($color, $mailbox);
3806fa52 445
b8796881 446 if (isset($send_to_search) && is_array($send_to_search)) {
447 foreach ($send_to_search as $k => $v) {
448 if (substr($k, 0, 1) == 'T') {
449 if ($send_to)
450 $send_to .= ', ';
451 $send_to .= $v;
452 }
453 elseif (substr($k, 0, 1) == 'C') {
454 if ($send_to_cc)
455 $send_to_cc .= ', ';
456 $send_to_cc .= $v;
457 }
458 elseif (substr($k, 0, 1) == 'B') {
459 if ($send_to_bcc)
460 $send_to_bcc .= ', ';
461 $send_to_bcc .= $v;
462 }
e53f7484 463 }
a98bed68 464 }
465
3806fa52 466 showInputForm();
245a6892 467 } else if (isset($html_addr_search)) {
f17728d1 468 if (isset($HTTP_POST_FILES['attachfile']) &&
469 $HTTP_POST_FILES['attachfile']['tmp_name'] &&
470 $HTTP_POST_FILES['attachfile']['tmp_name'] != 'none')
471 {
472 if (saveAttachedFiles())
473 plain_error_message(_("Could not move/copy file. File not attached"), $color);
474 }
591d2a88 475 // I am using an include so as to elminiate an extra unnecessary click. If you
476 // can think of a better way, please implement it.
2037f4f3 477 include ("./addrbook_search_html.php");
4ba45d11 478 } else if (isset($attach)) {
056ddad7 479 if (saveAttachedFiles())
22ef7536 480 plain_error_message(_("Could not move/copy file. File not attached"), $color);
21bc0570 481 displayPageHeader($color, $mailbox);
4ba45d11 482 showInputForm();
483 } else if (isset($do_delete)) {
dcb7f454 484 displayPageHeader($color, $mailbox);
fc3348ac 485
f972eb46 486 if (isset($delete) && is_array($delete))
487 {
488 foreach($delete as $index)
489 {
490 unlink ($attachment_dir.$attachments[$index]['localfilename']);
491 unset ($attachments[$index]);
f923b93d 492 }
4ba45d11 493 }
4bfed9f3 494
4ba45d11 495 showInputForm();
496 } else {
991a059e 497 // This handles the default case as well as the error case
498 // (they had the same code) --> if (isset($smtpErrors))
499 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
500 $imapPort, 0);
dcb7f454 501 displayPageHeader($color, $mailbox);
fc3348ac 502
b57c4e63 503 $newmail = true;
f972eb46 504
505 ClearAttachments();
506
991a059e 507 if (isset($forward_id) && $forward_id && isset($ent_num) && $ent_num)
508 getAttachments(0);
5713b4f9 509
1220e677 510 newMail();
4ba45d11 511 showInputForm();
1195c340 512 sqimap_logout($imapConnection);
4ba45d11 513 }
f972eb46 514
515
516
517
f923b93d 518 function ClearAttachments() {
f972eb46 519 global $attachments, $attachment_dir;
520
f923b93d 521 foreach ($attachments as $info) {
522 if (file_exists($attachment_dir . $info['localfilename'])) {
f972eb46 523 unlink($attachment_dir . $info['localfilename']);
f923b93d 524 }
f972eb46 525 }
526
527 $attachments = array();
528 }
529
da79853a 530?>