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