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