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