6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This code sends a mail.
11 * There are 4 modes of operation:
20 /* Path for SquirrelMail required files. */
21 define('SM_PATH','../');
23 /* SquirrelMail required files. */
24 require_once(SM_PATH
. 'include/validate.php');
25 require_once(SM_PATH
. 'functions/imap.php');
26 require_once(SM_PATH
. 'functions/date.php');
27 require_once(SM_PATH
. 'functions/mime.php');
28 require_once(SM_PATH
. 'functions/plugin.php');
29 require_once(SM_PATH
. 'functions/display_messages.php');
30 require_once(SM_PATH
. 'class/deliver/Deliver.class.php');
31 require_once(SM_PATH
. 'functions/addressbook.php');
33 /* --------------------- Get globals ------------------------------------- */
34 $username = $_SESSION['username'];
35 $onetimepad = $_SESSION['onetimepad'];
36 $base_uri = $_SESSION['base_uri'];
37 $delimiter = $_SESSION['delimiter'];
39 if (isset($_POST['return'])) {
40 $html_addr_search_done = 'Use Addresses';
42 if ( isset($_SESSION['composesession']) ) {
43 $composesession = $_SESSION['composesession'];
45 sqgetGlobalVar('action',$action);
46 sqgetGlobalVar('session',$session);
47 sqgetGlobalVar('mailbox',$mailbox);
48 sqgetGlobalVar('identity',$identity);
49 sqgetGlobalVar('send_to',$send_to);
50 sqgetGlobalVar('send_to_cc',$send_to_cc);
51 sqgetGlobalVar('send_to_bcc',$send_to_bcc);
52 sqgetGlobalVar('subject',$subject);
53 sqgetGlobalVar('body',$body);
54 sqgetGlobalVar('mailprio',$mailprio);
55 sqgetGlobalVar('request_mdn',$request_mdn);
56 sqgetGlobalVar('request_dr',$request_dr);
57 sqgetGlobalVar('html_addr_search',$html_addr_search);
58 sqgetGlobalVar('mail_sent',$mail_sent);
59 sqgetGlobalVar('passed_id',$passed_id);
60 sqgetGlobalVar('passed_ent_id',$passed_ent_id);
61 sqgetGlobalVar('send',$send);
63 if ( isset($_POST['sigappend']) ) {
64 $sigappend = $_POST['sigappend'];
66 /* From addressbook search */
67 if ( isset($_POST['from_htmladdr_search']) ) {
68 $from_htmladdr_search = $_POST['from_htmladdr_search'];
70 if ( isset($_POST['addr_search_done']) ) {
71 $html_addr_search_done = $_POST['addr_search_done'];
73 if ( isset($_POST['send_to_search']) ) {
74 $send_to_search = &$_POST['send_to_search'];
78 sqgetGlobalVar('attach',$attach);
79 if ( isset($_POST['do_delete']) ) {
80 $do_delete = $_POST['do_delete'];
82 if ( isset($_POST['delete']) ) {
83 $delete = &$_POST['delete'];
85 if ( isset($_SESSION['compose_messages']) ) {
86 $compose_messages = &$_SESSION['compose_messages'];
90 /* Forward message as attachment */
91 if ( isset($_GET['attachedmessages']) ) {
92 $attachedmessages = $_GET['attachedmessages'];
96 sqgetGlobalVar('draft',$draft);
97 sqgetGlobalVar('draft_id',$draft_id);
98 sqgetGlobalVar('ent_num',$ent_num);
99 sqgetGlobalVar('saved_draft',$saved_draft);
100 sqgetGlobalVar('delete_draft',$delete_draft);
102 $key = $_COOKIE['key'];
104 /* --------------------- Specific Functions ------------------------------ */
106 function replyAllString($header) {
107 global $include_self_reply_all, $username, $data_dir;
110 * 1) Remove the addresses we'll be sending the message 'to'
112 $url_replytoall_avoid_addrs = '';
113 if (isset($header->replyto
)) {
114 $excl_ar = $header->getAddr_a('replyto');
117 * 2) Remove our identities from the CC list (they still can be in the
118 * TO list) only if $include_self_reply_all is turned off
120 if (!$include_self_reply_all) {
121 $email_address = strtolower(trim(getPref($data_dir, $username, 'email_address')));
122 $excl_ar[$email_address] = '';
123 $idents = getPref($data_dir, $username, 'identities');
124 if ($idents != '' && $idents > 1) {
126 for ($i = 1; $i < $idents; $i ++
) {
127 $cur_email_address = getPref($data_dir, $username,
128 'email_address' . $i);
129 $cur_email_address = strtolower(trim($cur_email_address));
130 $excl_ar[$cur_email_address] = '';
136 * 3) get the addresses.
138 $url_replytoall_ar = $header->getAddr_a(array('to','cc'), $excl_ar);
141 * 4) generate the string.
143 $url_replytoallcc = '';
144 foreach( $url_replytoall_ar as $email => $personal) {
146 $url_replytoallcc .= ", \"$personal\" <$email>";
148 $url_replytoallcc .= ', '. $email;
151 $url_replytoallcc = substr($url_replytoallcc,2);
152 return $url_replytoallcc;
155 function getReplyCitation($orig_from) {
156 global $reply_citation_style, $reply_citation_start, $reply_citation_end;
157 $orig_from = decodeHeader($orig_from->getAddress(false),false,false);
158 // $from = decodeHeader($orig_header->getAddr_s('from',"\n$indent"),false,false);
159 /* First, return an empty string when no citation style selected. */
160 if (($reply_citation_style == '') ||
($reply_citation_style == 'none')) {
164 /* Make sure our final value isn't an empty string. */
165 if ($orig_from == '') {
169 /* Otherwise, try to select the desired citation style. */
170 switch ($reply_citation_style) {
173 $end = ' ' . _("said") . ':';
176 $start = '<' . _("quote") . ' ' . _("who") . '="';
180 $start = $reply_citation_start .
181 ($reply_citation_start == '' ?
'' : ' ');
182 $end = $reply_citation_end;
188 /* Build and return the citation string. */
189 return ($start . $orig_from . $end . "\n");
192 function getforwardHeader($orig_header) {
195 $display = array( _("Subject") => strlen(_("Subject")),
196 _("From") => strlen(_("From")),
197 _("Date") => strlen(_("Date")),
198 _("To") => strlen(_("To")),
199 _("Cc") => strlen(_("Cc")) );
200 $maxsize = max($display);
201 $indent = str_pad('',$maxsize+
2);
202 foreach($display as $key => $val) {
203 $display[$key] = $key .': '. str_pad('', $maxsize - $val);
205 $from = decodeHeader($orig_header->getAddr_s('from',"\n$indent"),false,false);
206 $from = str_replace(' ',' ',$from);
207 $to = decodeHeader($orig_header->getAddr_s('to',"\n$indent"),false,false);
208 $to = str_replace(' ',' ',$to);
209 $subject = decodeHeader($orig_header->subject
,false,false);
210 $subject = str_replace(' ',' ',$subject);
211 $bodyTop = str_pad(' '._("Original Message").' ',$editor_size -2,'-',STR_PAD_BOTH
) .
212 "\n\n". $display[_("Subject")] . $subject . "\n" .
213 $display[_("From")] . $from . "\n" .
214 $display[_("Date")] . getLongDateString( $orig_header->date
). "\n" .
215 $display[_("To")] . $to . "\n";
216 if ($orig_header->cc
!= array() && $orig_header->cc
!='') {
217 $cc = decodeHeader($orig_header->getAddr_s('cc',"\n$indent"),false,false);
218 $cc = str_replace(' ',' ',$cc);
219 $bodyTop .= $display[_("Cc")] .$cc . "\n";
221 $bodyTop .= str_pad('', $editor_size -2 , '-') .
225 /* ----------------------------------------------------------------------- */
228 * If the session is expired during a post this restores the compose session
231 if (sqsession_is_registered('session_expired_post')) {
232 $session_expired_post = $_SESSION['session_expired_post'];
234 * extra check for username so we don't display previous post data from
235 * another user during this session.
237 if ($session_expired_post['username'] != $username) {
238 unset($session_expired_post);
239 sqsession_unregister('session_expired_post');
240 session_write_close();
242 foreach ($session_expired_post as $postvar => $val) {
249 $compose_messages = unserialize(urldecode($restoremessages));
250 sqsession_register($compose_messages,'compose_messages');
251 sqsession_register($composesession,'composesession');
255 $session_expired = true;
257 unset($session_expired_post);
258 sqsession_unregister('session_expired_post');
259 session_write_close();
260 if (!isset($mailbox)) {
263 if ($compose_new_win == '1') {
264 compose_Header($color, $mailbox);
266 displayPageHeader($color, $mailbox);
268 showInputForm($session, false);
271 if (!isset($composesession)) {
273 sqsession_register(0,'composesession');
276 if (!isset($session) ||
(isset($newmessage) && $newmessage)) {
277 sqsession_unregister('composesession');
278 $session = "$composesession" +
1;
279 $composesession = $session;
280 sqsession_register($composesession,'composesession');
282 if (!isset($compose_messages)) {
283 $compose_messages = array();
285 if (!isset($compose_messages[$session]) ||
($compose_messages[$session] == NULL)) {
286 /* if (!array_key_exists($session, $compose_messages)) { /* We can only do this in PHP >= 4.1 */
287 $composeMessage = new Message();
288 $rfc822_header = new Rfc822Header();
289 $composeMessage->rfc822_header
= $rfc822_header;
290 $composeMessage->reply_rfc822_header
= '';
291 $compose_messages[$session] = $composeMessage;
292 sqsession_register($compose_messages,'compose_messages');
294 $composeMessage=$compose_messages[$session];
297 if (!isset($mailbox) ||
$mailbox == '' ||
($mailbox == 'None')) {
303 * Set $default_charset to correspond with the user's selection
304 * of language interface.
307 $composeMessage=$compose_messages[$session];
308 if (! deliverMessage($composeMessage, true)) {
309 showInputForm($session);
312 unset($compose_messages[$session]);
313 $draft_message = _("Draft Email Saved");
314 /* If this is a resumed draft, then delete the original */
315 if(isset($delete_draft)) {
316 Header("Location: delete_message.php?mailbox=" . urlencode($draft_folder) .
317 "&message=$delete_draft&sort=$sort&startMessage=1&saved_draft=yes");
321 if ($compose_new_win == '1') {
322 Header("Location: compose.php?saved_draft=yes&session=$composesession");
326 Header("Location: right_main.php?mailbox=$draft_folder&sort=$sort".
327 "&startMessage=1¬e=".urlencode($draft_message));
335 if (isset($_FILES['attachfile']) &&
336 $_FILES['attachfile']['tmp_name'] &&
337 $_FILES['attachfile']['tmp_name'] != 'none') {
338 $AttachFailure = saveAttachedFiles($session);
340 if (checkInput(false) && !isset($AttachFailure)) {
341 if ($mailbox == "All Folders") {
342 /* We entered compose via the search results page */
343 $mailbox="INBOX"; /* Send 'em to INBOX, that's safe enough */
345 $urlMailbox = urlencode (trim($mailbox));
346 if (! isset($passed_id)) {
350 * Set $default_charset to correspond with the user's selection
351 * of language interface.
355 * This is to change all newlines to \n
356 * We'll change them to \r\n later (in the sendMessage function)
358 $body = str_replace("\r\n", "\n", $body);
359 $body = str_replace("\r", "\n", $body);
362 * Rewrap $body so that no line is bigger than $editor_size
363 * This should only really kick in the sqWordWrap function
364 * if the browser doesn't support "VIRTUAL" as the wrap type.
366 $body = explode("\n", $body);
368 foreach ($body as $line) {
369 if( $line <> '-- ' ) {
370 $line = rtrim($line);
372 if (strlen($line) <= $editor_size +
1) {
373 $newBody .= $line . "\n";
375 sqWordWrap($line, $editor_size);
376 $newBody .= $line . "\n";
380 do_hook('compose_send');
381 $composeMessage=$compose_messages[$session];
383 $Result = deliverMessage($composeMessage);
385 showInputForm($session);
388 unset($compose_messages[$session]);
389 if ( isset($delete_draft)) {
390 Header("Location: delete_message.php?mailbox=" . urlencode( $draft_folder ).
391 "&message=$delete_draft&sort=$sort&startMessage=1&mail_sent=yes");
394 if ($compose_new_win == '1') {
396 Header("Location: compose.php?mail_sent=yes");
399 Header("Location: right_main.php?mailbox=$urlMailbox&sort=$sort".
403 if ($compose_new_win == '1') {
404 compose_Header($color, $mailbox);
407 displayPageHeader($color, $mailbox);
409 if (isset($AttachFailure)) {
410 plain_error_message(_("Could not move/copy file. File not attached"),
414 showInputForm($session);
415 /* sqimap_logout($imapConnection); */
417 } elseif (isset($html_addr_search_done)) {
418 if ($compose_new_win == '1') {
419 compose_Header($color, $mailbox);
422 displayPageHeader($color, $mailbox);
425 if (isset($send_to_search) && is_array($send_to_search)) {
426 foreach ($send_to_search as $k => $v) {
427 if (substr($k, 0, 1) == 'T') {
433 elseif (substr($k, 0, 1) == 'C') {
439 elseif (substr($k, 0, 1) == 'B') {
441 $send_to_bcc .= ', ';
447 showInputForm($session);
448 } elseif (isset($html_addr_search)) {
449 if (isset($_FILES['attachfile']) &&
450 $_FILES['attachfile']['tmp_name'] &&
451 $_FILES['attachfile']['tmp_name'] != 'none') {
452 if(saveAttachedFiles($session)) {
453 plain_error_message(_("Could not move/copy file. File not attached"), $color);
457 * I am using an include so as to elminiate an extra unnecessary
458 * click. If you can think of a better way, please implement it.
460 include_once('./addrbook_search_html.php');
461 } elseif (isset($attach)) {
462 if (saveAttachedFiles($session)) {
463 plain_error_message(_("Could not move/copy file. File not attached"), $color);
465 if ($compose_new_win == '1') {
466 compose_Header($color, $mailbox);
469 displayPageHeader($color, $mailbox);
471 showInputForm($session);
473 elseif (isset($sigappend)) {
474 $idents = getPref($data_dir, $username, 'identities', 0);
476 if ($identity == 'default') {
481 $signature = getSig($data_dir, $username, $no);
483 $body .= "\n\n".($prefix_sig==true?
"-- \n":'').$signature;
484 if ($compose_new_win == '1') {
485 compose_Header($color, $mailbox);
487 displayPageHeader($color, $mailbox);
489 showInputForm($session);
490 } elseif (isset($do_delete)) {
491 if ($compose_new_win == '1') {
492 compose_Header($color, $mailbox);
495 displayPageHeader($color, $mailbox);
498 if (isset($delete) && is_array($delete)) {
499 $composeMessage = $compose_messages[$session];
500 foreach($delete as $index) {
501 $attached_file = $composeMessage->entities
[$index]->att_local_name
;
502 unlink ($attached_file);
503 unset ($composeMessage->entities
[$index]);
505 $new_entities = array();
506 foreach ($composeMessage->entities
as $entity) {
507 $new_entities[] = $entity;
509 $composeMessage->entities
= $new_entities;
510 $compose_messages[$session] = $composeMessage;
511 sqsession_register($compose_messages, 'compose_messages');
513 showInputForm($session);
516 * This handles the default case as well as the error case
517 * (they had the same code) --> if (isset($smtpErrors))
520 if ($compose_new_win == '1') {
521 compose_Header($color, $mailbox);
523 displayPageHeader($color, $mailbox);
528 if (!isset($passed_ent_id)) {
531 if (!isset($passed_id)) {
534 if (!isset($mailbox)) {
537 if (!isset($action)) {
541 $values = newMail($mailbox,$passed_id,$passed_ent_id, $action, $session);
543 /* in case the origin is not read_body.php */
544 if (isset($send_to)) {
545 $values['send_to'] = $send_to;
547 if (isset($send_to_cc)) {
548 $values['send_to_cc'] = $send_to_cc;
550 if (isset($send_to_bcc)) {
551 $values['send_to_bcc'] = $send_to_bcc;
553 showInputForm($session, $values);
558 /**************** Only function definitions go below *************/
561 /* This function is used when not sending or adding attachments */
562 function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $session='') {
563 global $editor_size, $default_use_priority, $body,
564 $use_signature, $composesession, $data_dir, $username,
565 $username, $key, $imapServerAddress, $imapPort, $compose_messages,
568 $send_to = $send_to_cc = $send_to_bcc = $subject = $identity = '';
572 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
575 sqimap_mailbox_select($imapConnection, $mailbox);
576 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
579 if ($passed_ent_id) {
580 /* redefine the messsage in case of message/rfc822 */
581 $message = $message->getEntity($passed_ent_id);
582 /* message is an entity which contains the envelope and type0=message
583 * and type1=rfc822. The actual entities are childs from
584 * $message->entities[0]. That's where the encoding and is located
587 $entities = $message->entities
[0]->findDisplayEntity
588 (array(), $alt_order = array('text/plain'));
589 if (!count($entities)) {
590 $entities = $message->entities
[0]->findDisplayEntity
591 (array(), $alt_order = array('text/plain','html/plain'));
593 $orig_header = $message->rfc822_header
; /* here is the envelope located */
594 /* redefine the message for picking up the attachments */
595 $message = $message->entities
[0];
598 $entities = $message->findDisplayEntity (array(), $alt_order = array('text/plain'));
599 if (!count($entities)) {
600 $entities = $message->findDisplayEntity (array(), $alt_order = array('text/plain','html/plain'));
602 $orig_header = $message->rfc822_header
;
605 $encoding = $message->header
->encoding
;
606 $type0 = $message->type0
;
607 $type1 = $message->type1
;
608 foreach ($entities as $ent) {
609 $unencoded_bodypart = mime_fetch_body($imapConnection, $passed_id, $ent);
610 $body_part_entity = $message->getEntity($ent);
611 $bodypart = decodeBody($unencoded_bodypart,
612 $body_part_entity->header
->encoding
);
613 if ($type1 == 'html') {
614 $bodypart = str_replace(array(' ','>','<'),array(' ','<','>'),$bodypart);
615 $bodypart = strip_tags($bodypart);
619 if ($default_use_priority) {
620 $mailprio = substr($orig_header->priority
,0,1);
627 //ClearAttachments($session);
630 $idents = getPref($data_dir, $username, 'identities');
631 $from_o = $orig_header->from
;
632 if (is_object($from_o)) {
633 $orig_from = $from_o->getAddress();
637 $identities = array();
638 if (!empty($idents) && $idents > 1) {
639 $identities[] = '"'. getPref($data_dir, $username, 'full_name')
640 . '" <' . getPref($data_dir, $username, 'email_address') . '>';
641 for ($i = 1; $i < $idents; $i++
) {
642 $enc_from_name = '"'.
643 getPref($data_dir, $username, 'full_name' . $i) .
645 getPref($data_dir, $username, 'email_address' . $i) . '>';
646 if ($enc_from_name == $orig_from && $i) {
650 $identities[] = $enc_from_name;
652 $identity_match = $orig_header->findAddress($identities);
653 if ($identity_match) {
654 $identity = $identity_match;
660 $use_signature = FALSE;
661 $send_to = decodeHeader($orig_header->getAddr_s('to'),false,true);
662 $send_to_cc = decodeHeader($orig_header->getAddr_s('cc'),false,true);
663 $send_to_bcc = decodeHeader($orig_header->getAddr_s('bcc'),false,true);
664 $subject = decodeHeader($orig_header->subject
,false,true);
665 $body_ary = explode("\n", $body);
666 $cnt = count($body_ary) ;
668 for ($i=0; $i < $cnt; $i++
) {
669 if (!ereg("^[>\\s]*$", $body_ary[$i]) ||
!$body_ary[$i]) {
670 sqWordWrap($body_ary[$i], $editor_size );
671 $body .= $body_ary[$i] . "\n";
673 unset($body_ary[$i]);
676 $composeMessage = getAttachments($message, $composeMessage, $passed_id, $entities, $imapConnection);
678 case ('edit_as_new'):
679 $send_to = decodeHeader($orig_header->getAddr_s('to'),false,true);
680 $send_to_cc = decodeHeader($orig_header->getAddr_s('cc'),false,true);
681 $send_to_bcc = decodeHeader($orig_header->getAddr_s('bcc'),false,true);
682 $subject = decodeHeader($orig_header->subject
,false,true);
683 $mailprio = $orig_header->priority
;
685 $composeMessage = getAttachments($message, $composeMessage, $passed_id, $entities, $imapConnection);
690 $subject = decodeHeader($orig_header->subject
,false,true);
691 if ((substr(strtolower($subject), 0, 4) != 'fwd:') &&
692 (substr(strtolower($subject), 0, 5) != '[fwd:') &&
693 (substr(strtolower($subject), 0, 6) != '[ fwd:')) {
694 $subject = '[Fwd: ' . $subject . ']';
696 $body = getforwardHeader($orig_header) . $body;
698 $composeMessage = getAttachments($message, $composeMessage, $passed_id, $entities, $imapConnection);
699 $body = "\n" . $body;
701 case ('forward_as_attachment'):
702 $composeMessage = getMessage_RFC822_Attachment($message, $composeMessage, $passed_id, $passed_ent_id, $imapConnection);
706 $send_to_cc = replyAllString($orig_header);
707 $send_to_cc = decodeHeader($send_to_cc,false,true);
709 $send_to = $orig_header->reply_to
;
710 if (is_array($send_to) && count($send_to)) {
711 $send_to = $orig_header->getAddr_s('reply_to');
712 } else if (is_object($send_to)) { /* unnessecarry, just for falesafe purpose */
713 $send_to = $orig_header->getAddr_s('reply_to');
715 $send_to = $orig_header->getAddr_s('from');
717 $send_to = decodeHeader($send_to,false,true);
718 $subject = decodeHeader($orig_header->subject
,false,true);
719 $subject = str_replace('"', "'", $subject);
720 $subject = trim($subject);
721 if (substr(strtolower($subject), 0, 3) != 're:') {
722 $subject = 'Re: ' . $subject;
724 /* this corrects some wrapping/quoting problems on replies */
725 $rewrap_body = explode("\n", $body);
726 $from = (is_array($orig_header->from
)) ?
$orig_header->from
[0] : $orig_header->from
;
729 $cnt = count($rewrap_body);
730 for ($i=0;$i<$cnt;$i++
) {
731 sqWordWrap($rewrap_body[$i], ($editor_size));
732 if (preg_match("/^(>+)/", $rewrap_body[$i], $matches)) {
734 $body .= '>' . str_replace("\n", "\n>$gt ", rtrim($rewrap_body[$i])) ."\n";
736 $body .= '> ' . str_replace("\n", "\n> ", rtrim($rewrap_body[$i])) . "\n";
738 unset($rewrap_body[$i]);
740 $body = getReplyCitation($from) . $body;
741 $composeMessage->reply_rfc822_header
= $orig_header;
747 $compose_messages[$session] = $composeMessage;
748 sqsession_register($compose_messages, 'compose_messages');
749 session_write_close();
750 sqimap_logout($imapConnection);
752 $ret = array( 'send_to' => $send_to,
753 'send_to_cc' => $send_to_cc,
754 'send_to_bcc' => $send_to_bcc,
755 'subject' => $subject,
756 'mailprio' => $mailprio,
758 'identity' => $identity );
761 } /* function newMail() */
763 function getAttachments($message, &$composeMessage, $passed_id, $entities, $imapConnection) {
764 global $attachment_dir, $username, $data_dir, $squirrelmail_language;
765 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
766 if (!count($message->entities
) ||
767 ($message->type0
== 'message' && $message->type1
== 'rfc822')) {
768 if ( !in_array($message->entity_id
, $entities) && $message->entity_id
) {
769 switch ($message->type0
) {
771 if ($message->type1
== 'rfc822') {
772 $filename = $message->rfc822_header
->subject
.'.eml';
773 if ($filename == "") {
774 $filename = "untitled-".$message->entity_id
.'.eml';
777 $filename = $message->getFilename();
781 $filename = $message->getFilename();
784 $filename = decodeHeader($filename);
785 if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
786 function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
787 $filename = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $filename);
789 $localfilename = GenerateRandomString(32, '', 7);
790 $full_localfilename = "$hashed_attachment_dir/$localfilename";
791 while (file_exists($full_localfilename)) {
792 $localfilename = GenerateRandomString(32, '', 7);
793 $full_localfilename = "$hashed_attachment_dir/$localfilename";
795 $message->att_local_name
= $full_localfilename;
796 if (!$message->mime_header
) { /* temporary hack */
797 $message->mime_header
= $message->header
;
800 $composeMessage->addEntity($message);
802 /* Write Attachment to file */
803 $fp = fopen ("$hashed_attachment_dir/$localfilename", 'wb');
804 fputs($fp, decodeBody(mime_fetch_body($imapConnection,
805 $passed_id, $message->entity_id
),
806 $message->header
->encoding
));
810 for ($i=0, $entCount=count($message->entities
); $i<$entCount;$i++
) {
811 $composeMessage=getAttachments($message->entities
[$i], $composeMessage, $passed_id, $entities, $imapConnection);
814 return $composeMessage;
817 function getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
818 $passed_ent_id='', $imapConnection) {
819 global $attachments, $attachment_dir, $username, $data_dir, $uid_support;
820 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
821 if (!$passed_ent_id) {
822 $body_a = sqimap_run_command($imapConnection,
823 'FETCH '.$passed_id.' RFC822',
824 TRUE, $response, $readmessage,
827 $body_a = sqimap_run_command($imapConnection,
828 'FETCH '.$passed_id.' BODY['.$passed_ent_id.']',
829 TRUE, $response, $readmessage, $uid_support);
830 $message = $message->parent
;
832 if ($response = 'OK') {
833 $subject = encodeHeader($message->rfc822_header
->subject
);
834 array_shift($body_a);
835 $body = implode('', $body_a) . "\r\n";
837 $localfilename = GenerateRandomString(32, 'FILE', 7);
838 $full_localfilename = "$hashed_attachment_dir/$localfilename";
840 $fp = fopen( $full_localfilename, 'w');
843 $composeMessage->initAttachment('message/rfc822',$subject.'.eml',
844 $full_localfilename);
846 return $composeMessage;
849 function showInputForm ($session, $values=false) {
850 global $send_to, $send_to_cc, $body,
851 $passed_body, $color, $use_signature, $signature, $prefix_sig,
852 $editor_size, $attachments, $subject, $newmail,
853 $use_javascript_addr_book, $send_to_bcc, $passed_id, $mailbox,
854 $from_htmladdr_search, $location_of_buttons, $attachment_dir,
855 $username, $data_dir, $identity, $draft_id, $delete_draft,
856 $mailprio, $default_use_mdn, $mdn_user_support, $compose_new_win,
857 $saved_draft, $mail_sent, $sig_first, $edit_as_new, $action,
858 $username, $compose_messages, $composesession, $default_charset;
860 $composeMessage = $compose_messages[$session];
863 $send_to = $values['send_to'];
864 $send_to_cc = $values['send_to_cc'];
865 $send_to_bcc = $values['send_to_bcc'];
866 $subject = $values['subject'];
867 $mailprio = $values['mailprio'];
868 $body = $values['body'];
869 $identity = (int) $values['identity'];
872 if ($use_javascript_addr_book) {
873 echo "\n". '<SCRIPT LANGUAGE=JavaScript><!--' . "\n" .
874 'function open_abook() { ' . "\n" .
875 ' var nwin = window.open("addrbook_popup.php","abookpopup",' .
876 '"width=670,height=300,resizable=yes,scrollbars=yes");' . "\n" .
877 ' if((!nwin.opener) && (document.windows != null))' . "\n" .
878 ' nwin.opener = document.windows;' . "\n" .
880 '// --></SCRIPT>' . "\n\n";
883 echo "\n" . '<FORM name=compose action="compose.php" METHOD=POST ' .
884 'ENCTYPE="multipart/form-data"';
885 do_hook("compose_form");
889 if ($action == 'draft') {
890 echo '<input type="hidden" name="delete_draft" value="' . $passed_id . "\">\n";
892 if (isset($delete_draft)) {
893 echo '<input type="hidden" name="delete_draft" value="' . $delete_draft. "\">\n";
895 if (isset($session)) {
896 echo '<input type="hidden" name="session" value="' . $session . "\">\n";
899 if (isset($passed_id)) {
900 echo '<input type="hidden" name="passed_id" value="' . $passed_id . "\">\n";
903 if ($saved_draft == 'yes') {
904 echo '<BR><CENTER><B>'. _("Draft Saved").'</CENTER></B>';
906 if ($mail_sent == 'yes') {
907 echo '<BR><CENTER><B>'. _("Your Message has been sent").'</CENTER></B>';
909 echo '<TABLE ALIGN=center CELLSPACING=0 BORDER=0>' . "\n";
910 if ($compose_new_win == '1') {
911 echo '<TABLE ALIGN=CENTER BGCOLOR="'.$color[0].'" WIDTH="100%" BORDER=0>'."\n" .
912 ' <TR><TD></TD>'. html_tag( 'td', '', 'right' ) . '<INPUT TYPE="BUTTON" NAME="Close" onClick="return self.close()" VALUE='._("Close").'></TD></TR>'."\n";
914 if ($location_of_buttons == 'top') {
915 showComposeButtonRow();
918 $idents = getPref($data_dir, $username, 'identities', 0);
920 echo ' <TR>' . "\n" .
921 html_tag( 'td', '', 'right', $color[4], 'WIDTH="10%"' ) .
922 _("From:") . '</TD>' . "\n" .
923 html_tag( 'td', '', 'left', $color[4], 'WIDTH="90%"' ) .
924 ' <select name=identity>' . "\n" .
925 ' <option value=default>' .
926 htmlspecialchars(getPref($data_dir, $username, 'full_name'));
927 $em = getPref($data_dir, $username, 'email_address');
929 echo htmlspecialchars(' <' . $em . '>') . "\n";
931 for ($i = 1; $i < $idents; $i ++
) {
932 echo '<option value="' . $i . '"';
933 if (isset($identity) && $identity == $i) {
936 echo '>' . htmlspecialchars(getPref($data_dir, $username,
938 $em = getPref($data_dir, $username, 'email_address' . $i);
940 echo htmlspecialchars(' <' . $em . '>') . "\n";
944 echo '</select>' . "\n" .
948 echo ' <TR>' . "\n" .
949 html_tag( 'td', '', 'right', $color[4], 'WIDTH="10%"' ) .
950 _("To:") . '</TD>' . "\n" .
951 html_tag( 'td', '', 'left', $color[4], 'WIDTH="90%"' ) .
952 ' <INPUT TYPE=text NAME="send_to" VALUE="' .
953 $send_to . '" SIZE=60><BR>' . "\n" .
957 html_tag( 'td', '', 'right', $color[4] ) .
958 _("CC:") . '</TD>' . "\n" .
959 html_tag( 'td', '', 'left', $color[4] ) .
960 ' <INPUT TYPE=text NAME="send_to_cc" SIZE=60 VALUE="' .
961 $send_to_cc . '"><BR>' . "\n" .
965 html_tag( 'td', '', 'right', $color[4] ) .
966 _("BCC:") . '</TD>' . "\n" .
967 html_tag( 'td', '', 'left', $color[4] ) .
968 ' <INPUT TYPE=text NAME="send_to_bcc" VALUE="' .
969 $send_to_bcc . '" SIZE=60><BR>' . "\n" .
973 html_tag( 'td', '', 'right', $color[4] ) .
974 _("Subject:") . '</TD>' . "\n" .
975 html_tag( 'td', '', 'left', $color[4] ) . "\n";
976 echo ' <INPUT TYPE=text NAME=subject SIZE=60 VALUE="' .
977 $subject . '">' . "\n" .
981 if ($location_of_buttons == 'between') {
982 showComposeButtonRow();
985 if ($compose_new_win == '1') {
986 echo ' <TR>' . "\n" .
987 ' <TD BGCOLOR="' . $color[0] . '" COLSPAN=2 ALIGN=CENTER>' . "\n" .
988 ' <TEXTAREA NAME=body ROWS=20 COLS="' .
989 $editor_size . '" WRAP="VIRTUAL">';
992 echo ' <TR>' . "\n" .
993 ' <TD BGCOLOR="' . $color[4] . '" COLSPAN=2>' . "\n" .
994 ' <TEXTAREA NAME=body ROWS=20 COLS="' .
995 $editor_size . '" WRAP="VIRTUAL">';
997 if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) {
999 if ($identity == 'default') {
1004 $signature = getSig($data_dir, $username, $no);
1007 if ($sig_first == '1') {
1008 if ($default_charset == 'iso-2022-jp') {
1009 echo "\n\n".($prefix_sig==true?
"-- \n":'').mb_convert_encoding($signature, 'EUC-JP');
1011 echo "\n\n".($prefix_sig==true?
"-- \n":'').decodeHeader($signature,false);
1013 echo "\n\n".decodeHeader($body,false,true);
1016 echo "\n\n".decodeHeader($body,false,true);
1017 if ($default_charset == 'iso-2022-jp') {
1018 echo "\n\n".($prefix_sig==true?
"-- \n":'').mb_convert_encoding($signature, 'EUC-JP');
1020 echo "\n\n".($prefix_sig==true?
"-- \n":'').decodeHeader($signature,false,true);
1025 echo decodeHeader($body,false,true);
1027 echo '</TEXTAREA><BR>' . "\n" .
1032 if ($location_of_buttons == 'bottom') {
1033 showComposeButtonRow();
1035 echo ' <TR>' . "\n" .
1036 html_tag( 'td', '', 'right', '', 'COLSPAN=2' ) . "\n" .
1037 ' <INPUT TYPE=SUBMIT NAME=send VALUE="' . _("Send") . '">' . "\n" .
1038 ' <BR><BR>' . "\n" .
1043 /* This code is for attachments */
1044 if ((bool) ini_get('file_uploads')) {
1045 echo ' <TR>' . "\n" .
1046 ' <TD COLSPAN=2>' . "\n" .
1047 ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.
1048 ' border="0" bgcolor="'.$color[9].'">' . "\n" .
1051 ' <table width="100%" cellpadding="3" cellspacing="0" align="center"'.
1052 ' border="0">' . "\n" .
1054 html_tag( 'td', '', 'right', '', 'VALIGN=MIDDLE' ) .
1055 _("Attach:") . '</TD>' . "\n" .
1056 html_tag( 'td', '', 'left', '', 'VALIGN=MIDDLE' ) .
1057 ' <INPUT NAME="attachfile" SIZE=48 TYPE="file">' . "\n" .
1058 ' <input type="submit" name="attach"' .
1059 ' value="' . _("Add") .'">' . "\n" .
1065 if ($composeMessage->entities
) {
1066 foreach ($composeMessage->entities
as $key => $attachment) {
1067 $attached_file = $attachment->att_local_name
;
1068 if ($attachment->att_local_name ||
$attachment->body_part
) {
1069 $attached_filename = decodeHeader($attachment->mime_header
->getParameter('name'));
1070 $type = $attachment->mime_header
->type0
.'/'.
1071 $attachment->mime_header
->type1
;
1073 $s_a[] = '<table bgcolor="'.$color[0].
1074 '" border="0"><tr><td><input type="checkbox" name="delete[]" value="' .
1075 $key . "\"></td><td>\n" . $attached_filename .
1076 '</td><td>-</td><td> ' . $type . '</td><td>('.
1077 show_readable_size( filesize( $attached_file ) ) . ')</td></tr></table>'."\n";
1082 foreach ($s_a as $s) {
1083 echo '<tr>' . html_tag( 'td', '', 'left', $color[0], 'colspan="2"' ) . $s .'</td></tr>';
1085 echo '<tr><td colspan="2"><input type="submit" name="do_delete" value="' .
1086 _("Delete selected attachments") . "\">\n" .
1089 echo ' </table>' . "\n" .
1092 ' </TABLE>' . "\n" .
1095 } // End of file_uploads if-block
1096 /* End of attachment code */
1097 if ($compose_new_win == '1') {
1098 echo '</TABLE>'."\n";
1101 echo '</TABLE>' . "\n" .
1102 '<input type="hidden" name="username" value="'. $username . "\">\n" .
1103 '<input type=hidden name=action value="' . $action . "\">\n" .
1104 '<INPUT TYPE=hidden NAME=mailbox VALUE="' . htmlspecialchars($mailbox) .
1107 store the complete ComposeMessages array in a hidden input value
1108 so we can restore them in case of a session timeout.
1110 echo '<input type=hidden name=restoremessages value="' . urlencode(serialize($compose_messages)) . "\">\n";
1111 echo '<input type=hidden name=composesession value="' . $composesession . "\">\n";
1112 echo '<input type=hidden name=querystring value="' . $_SERVER['QUERY_STRING'] . "\">\n";
1114 if (!(bool) ini_get('file_uploads')) {
1115 /* File uploads are off, so we didn't show that part of the form.
1116 To avoid bogus bug reports, tell the user why. */
1117 echo 'Because PHP file uploads are turned off, you can not attach files ';
1118 echo "to this message. Please see your system administrator for details.\r\n";
1122 do_hook('compose_bottom');
1123 echo '</BODY></HTML>' . "\n";
1127 function showComposeButtonRow() {
1128 global $use_javascript_addr_book, $save_as_draft,
1129 $default_use_priority, $mailprio, $default_use_mdn,
1130 $request_mdn, $request_dr,
1131 $data_dir, $username;
1133 echo ' <TR>' . "\n" .
1134 ' <TD></TD>' . "\n" .
1136 if ($default_use_priority) {
1137 if(!isset($mailprio)) {
1140 echo ' ' . _("Priority") .': <select name="mailprio">'.
1141 '<option value="1"'.($mailprio=='1'?
' selected':'').'>'. _("High") .'</option>'.
1142 '<option value="3"'.($mailprio=='3'?
' selected':'').'>'. _("Normal") .'</option>'.
1143 '<option value="5"'.($mailprio=='5'?
' selected':'').'>'. _("Low").'</option>'.
1146 $mdn_user_support=getPref($data_dir, $username, 'mdn_user_support',$default_use_mdn);
1147 if ($default_use_mdn) {
1148 if ($mdn_user_support) {
1149 echo ' ' . _("Receipt") .': '.
1150 '<input type="checkbox" name="request_mdn" value=1'.
1151 ($request_mdn=='1'?
' checked':'') .'>'. _("On Read").
1152 ' <input type="checkbox" name="request_dr" value=1'.
1153 ($request_dr=='1'?
' checked':'') .'>'. _("On Delivery");
1157 echo ' </TD>' . "\n" .
1160 ' <TD></TD>' . "\n" .
1162 ' <INPUT TYPE=SUBMIT NAME="sigappend" VALUE="' . _("Signature") . '">' . "\n";
1163 if ($use_javascript_addr_book) {
1164 echo " <SCRIPT LANGUAGE=JavaScript><!--\n document.write(\"".
1165 " <input type=button value=\\\""._("Addresses").
1166 "\\\" onclick='javascript:open_abook();'>\");".
1167 " // --></SCRIPT><NOSCRIPT>\n".
1168 " <input type=submit name=\"html_addr_search\" value=\"".
1169 _("Addresses")."\">".
1172 echo ' <input type=submit name="html_addr_search" value="'.
1173 _("Addresses").'">' . "\n";
1176 if ($save_as_draft) {
1177 echo ' <input type="submit" name ="draft" value="' . _("Save Draft") . "\">\n";
1180 echo ' <INPUT TYPE=submit NAME=send VALUE="'. _("Send") . '">' . "\n";
1181 do_hook('compose_button_row');
1183 echo ' </TD>' . "\n" .
1187 function checkInput ($show) {
1189 * I implemented the $show variable because the error messages
1190 * were getting sent before the page header. So, I check once
1191 * using $show=false, and then when i'm ready to display the error
1192 * message, show=true
1194 global $body, $send_to, $send_to_bcc, $subject, $color;
1196 if ($send_to == '' && $send_to_bcc == '') {
1198 plain_error_message(_("You have not filled in the \"To:\" field."), $color);
1203 } /* function checkInput() */
1206 /* True if FAILURE */
1207 function saveAttachedFiles($session) {
1208 global $_FILES, $attachment_dir, $attachments, $username,
1209 $data_dir, $compose_messages;
1211 /* get out of here if no file was attached at all */
1212 if (! is_uploaded_file($_FILES['attachfile']['tmp_name']) ) {
1216 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
1217 $localfilename = GenerateRandomString(32, '', 7);
1218 $full_localfilename = "$hashed_attachment_dir/$localfilename";
1219 while (file_exists($full_localfilename)) {
1220 $localfilename = GenerateRandomString(32, '', 7);
1221 $full_localfilename = "$hashed_attachment_dir/$localfilename";
1224 // FIXME: we SHOULD prefer move_uploaded_file over rename because
1225 // m_u_f works better with restricted PHP installes (safe_mode, open_basedir)
1226 if (!@rename
($_FILES['attachfile']['tmp_name'], $full_localfilename)) {
1227 if (!@move_uploaded_file
($_FILES['attachfile']['tmp_name'],$full_localfilename)) {
1231 $message = $compose_messages[$session];
1232 $type = strtolower($_FILES['attachfile']['type']);
1233 $name = $_FILES['attachfile']['name'];
1234 $message->initAttachment($type, $name, $full_localfilename);
1235 $compose_messages[$session] = $message;
1238 function ClearAttachments($composeMessage) {
1239 if ($composeMessage->att_local_name
) {
1240 $attached_file = $composeMessage->att_local_name
;
1241 if (file_exists($attached_file)) {
1242 unlink($attached_file);
1245 for ($i=0, $entCount=count($composeMessage->entities
);$i< $entCount; ++
$i) {
1246 ClearAttachments($composeMessage->entities
[$i]);
1253 /* temporary function to make use of the deliver class.
1254 In the future the responsable backend should be automaticly loaded
1255 and conf.pl should show a list of available backends.
1256 The message also should be constructed by the message class.
1259 function deliverMessage($composeMessage, $draft=false) {
1260 global $send_to, $send_to_cc, $send_to_bcc, $mailprio, $subject, $body,
1261 $username, $popuser, $usernamedata, $identity, $data_dir,
1262 $request_mdn, $request_dr, $default_charset, $color, $useSendmail,
1264 global $imapServerAddress, $imapPort, $sent_folder, $key;
1266 $rfc822_header = $composeMessage->rfc822_header
;
1268 $abook = addressbook_init(false, true);
1269 $rfc822_header->to
= $rfc822_header->parseAddress($send_to,true, array(), '', $domain, array(&$abook,'lookup'));
1270 $rfc822_header->cc
= $rfc822_header->parseAddress($send_to_cc,true,array(), '',$domain, array(&$abook,'lookup'));
1271 $rfc822_header->bcc
= $rfc822_header->parseAddress($send_to_bcc,true, array(), '',$domain, array(&$abook,'lookup'));
1272 $rfc822_header->priority
= $mailprio;
1273 $rfc822_header->subject
= $subject;
1274 $special_encoding='';
1275 if (strtolower($default_charset) == 'iso-2022-jp') {
1276 if (mb_detect_encoding($body) == 'ASCII') {
1277 $special_encoding = '8bit';
1279 $body = mb_convert_encoding($body, 'JIS');
1280 $special_encoding = '7bit';
1283 $composeMessage->setBody($body);
1285 if (ereg("^([^@%/]+)[@%/](.+)$", $username, $usernamedata)) {
1286 $popuser = $usernamedata[1];
1287 $domain = $usernamedata[2];
1288 unset($usernamedata);
1290 $popuser = $username;
1293 if (isset($identity) && $identity != 'default') {
1294 $from_mail = getPref($data_dir, $username,'email_address' . $identity);
1295 $full_name = getPref($data_dir, $username,'full_name' . $identity);
1296 $reply_to = getPref($data_dir, $username,'reply_to' . $identity);
1298 $from_mail = getPref($data_dir, $username, 'email_address');
1299 $full_name = getPref($data_dir, $username, 'full_name');
1300 $reply_to = getPref($data_dir, $username,'reply_to');
1303 $from_mail = "$popuser@$domain";
1306 $rfc822_header->from
= $rfc822_header->parseAddress($from_mail,true);
1308 $from = $rfc822_header->from
[0];
1309 if (!$from->host
) $from->host
= $domain;
1310 $full_name_encoded = encodeHeader($full_name);
1311 if ($full_name_encoded != $full_name) {
1312 $from_addr = $full_name_encoded .' <'.$from->mailbox
.'@'.$from->host
.'>';
1314 $from_addr = '"'.$full_name .'" <'.$from->mailbox
.'@'.$from->host
.'>';
1316 $rfc822_header->from
= $rfc822_header->parseAddress($from_addr,true);
1319 $rfc822_header->reply_to
= $rfc822_header->parseAddress($reply_to,true);
1321 /* Receipt: On Read */
1322 if (isset($request_mdn) && $request_mdn) {
1323 $rfc822_header->dnt
= $rfc822_header->parseAddress($from_mail,true);
1325 /* Receipt: On Delivery */
1326 if (isset($request_dr) && $request_dr) {
1327 $rfc822_header->more_headers
['Return-Receipt-To'] = $from_mail;
1329 /* multipart messages */
1330 if (count($composeMessage->entities
)) {
1331 $message_body = new Message();
1332 $message_body->body_part
= $composeMessage->body_part
;
1333 $composeMessage->body_part
= '';
1334 $mime_header = new MessageHeader
;
1335 $mime_header->type0
= 'text';
1336 $mime_header->type1
= 'plain';
1337 if ($special_encoding) {
1338 $mime_header->encoding
= $special_encoding;
1340 $mime_header->encoding
= '8bit';
1342 if ($default_charset) {
1343 $mime_header->parameters
['charset'] = $default_charset;
1345 $message_body->mime_header
= $mime_header;
1346 array_unshift($composeMessage->entities
, $message_body);
1347 $content_type = new ContentType('multipart/mixed');
1349 $content_type = new ContentType('text/plain');
1351 if ($default_charset) {
1352 $content_type->properties
['charset']=$default_charset;
1355 $rfc822_header->content_type
= $content_type;
1356 $composeMessage->rfc822_header
= $rfc822_header;
1358 if (!$useSendmail && !$draft) {
1359 require_once(SM_PATH
. 'class/deliver/Deliver_SMTP.class.php');
1360 $deliver = new Deliver_SMTP();
1361 global $smtpServerAddress, $smtpPort, $pop_before_smtp, $smtp_auth_mech;
1363 if ($smtp_auth_mech == 'none') {
1367 global $key, $onetimepad;
1369 $pass = OneTimePadDecrypt($key, $onetimepad);
1372 $authPop = (isset($pop_before_smtp) && $pop_before_smtp) ?
true : false;
1373 $stream = $deliver->initStream($composeMessage,$domain,0,
1374 $smtpServerAddress, $smtpPort, $user, $pass, $authPop);
1375 } elseif (!$draft) {
1376 require_once(SM_PATH
. 'class/deliver/Deliver_SendMail.class.php');
1377 global $sendmail_path;
1378 $deliver = new Deliver_SendMail();
1379 $stream = $deliver->initStream($composeMessage,$sendmail_path);
1381 global $draft_folder;
1382 require_once(SM_PATH
. 'class/deliver/Deliver_IMAP.class.php');
1383 $imap_stream = sqimap_login($username, $key, $imapServerAddress,
1385 if (sqimap_mailbox_exists ($imap_stream, $draft_folder)) {
1386 require_once(SM_PATH
. 'class/deliver/Deliver_IMAP.class.php');
1387 $imap_deliver = new Deliver_IMAP();
1388 $length = $imap_deliver->mail($composeMessage);
1389 sqimap_append ($imap_stream, $draft_folder, $length);
1390 $imap_deliver->mail($composeMessage, $imap_stream);
1391 sqimap_append_done ($imap_stream, $draft_folder);
1392 sqimap_logout($imap_stream);
1393 unset ($imap_deliver);
1396 $msg = '<br>Error: '._("Draft folder")." $draft_folder" . ' does not exist.';
1397 plain_error_message($msg, $color);
1403 $length = $deliver->mail($composeMessage, $stream);
1404 $succes = $deliver->finalizeStream($stream);
1407 $msg = $deliver->dlv_msg
. '<br>' .
1408 _("Server replied: ") . $deliver->dlv_ret_nr
. ' '.
1409 $deliver->dlv_server_msg
;
1410 plain_error_message($msg, $color);
1413 $imap_stream = sqimap_login($username, $key, $imapServerAddress,
1415 if (sqimap_mailbox_exists ($imap_stream, $sent_folder)) {
1416 sqimap_append ($imap_stream, $sent_folder, $length);
1417 require_once(SM_PATH
. 'class/deliver/Deliver_IMAP.class.php');
1418 $imap_deliver = new Deliver_IMAP();
1419 $imap_deliver->mail($composeMessage, $imap_stream);
1420 sqimap_append_done ($imap_stream, $sent_folder);
1421 unset ($imap_deliver);
1423 global $passed_id, $mailbox, $action;
1424 ClearAttachments($composeMessage);
1425 if ($action == 'reply' ||
$action == 'reply_all') {
1426 sqimap_mailbox_select ($imap_stream, $mailbox);
1427 sqimap_messages_flag ($imap_stream, $passed_id, $passed_id, 'Answered', true);
1429 sqimap_logout($imap_stream);