X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fcompose.php;h=685a9706a2c1c77a789dd735c9381ba69d1987bf;hb=af5de065345739645f9010a5671ea35622b19af2;hp=9acb9163a1152743faf50e6cb9a37362f4e002f8;hpb=0fdb0aa1fadc8a897622a53ca3338a704cb66588;p=squirrelmail.git diff --git a/src/compose.php b/src/compose.php index 9acb9163..685a9706 100644 --- a/src/compose.php +++ b/src/compose.php @@ -154,7 +154,7 @@ if ( sqgetGlobalVar('mailtodata', $mailtodata, SQ_GET) ) { unset($mailtodata,$mtdata, $trtable); } -/* Location (For HTTP 1.1 Header("Location: ...") redirects) */ +/* Location (For HTTP 1.1 header("Location: ...") redirects) */ $location = get_location(); /* Identities (fetch only once) */ $idents = get_identities(); @@ -441,7 +441,7 @@ if ($draft) { if ($compose_new_win == '1') { if ( !isset($pageheader_sent) || !$pageheader_sent ) { - Header("Location: $location/compose.php?saved_draft=yes&session=$composesession"); + header("Location: $location/compose.php?saved_draft=yes&session=$composesession"); } else { //FIXME: DON'T ECHO HTML FROM CORE! echo '


drnt) ? '1' : '0'; /* remember the references and in-reply-to headers in case of an reply */ +//FIXME: it would be better to fiddle with headers inside of the message object or possibly when delivering the message to its destination (drafts folder?); is this possible? $composeMessage->rfc822_header->more_headers['References'] = $orig_header->references; $composeMessage->rfc822_header->more_headers['In-Reply-To'] = $orig_header->in_reply_to; // rewrap the body to clean up quotations and line lengths @@ -1421,8 +1423,8 @@ function saveAttachedFiles($session) { // m_u_f works better with restricted PHP installs (safe_mode, open_basedir), // if that doesn't work, try a simple rename. - if (!@move_uploaded_file($_FILES['attachfile']['tmp_name'],$fullpath)) { - if (!@rename($_FILES['attachfile']['tmp_name'], $fullpath)) { + if (!sq_call_function_suppress_errors('move_uploaded_file', array($_FILES['attachfile']['tmp_name'], $fullpath))) { + if (!sq_call_function_suppress_errors('rename', array($_FILES['attachfile']['tmp_name'], $fullpath))) { return true; } } @@ -1467,8 +1469,18 @@ function getByteSize($ini_size) { * In the future the responsible backend should be automaticly loaded * and conf.pl should show a list of available backends. * The message also should be constructed by the message class. + * + * @param object $composeMessage The message being sent. Please note + * that it is passed by reference and + * will be returned modified, with additional + * headers, such as Message-ID, Date, In-Reply-To, + * References, and so forth. + * + * @return boolean FALSE if delivery failed, or some non-FALSE value + * upon success. + * */ -function deliverMessage($composeMessage, $draft=false) { +function deliverMessage(&$composeMessage, $draft=false) { global $send_to, $send_to_cc, $send_to_bcc, $mailprio, $subject, $body, $username, $identity, $idents, $data_dir, $request_mdn, $request_dr, $default_charset, $useSendmail, @@ -1511,7 +1523,8 @@ function deliverMessage($composeMessage, $draft=false) { } /* Receipt: On Delivery */ - if (isset($request_dr) && $request_dr) { + if (!empty($request_dr)) { +//FIXME: it would be better to fiddle with headers inside of the message object or possibly when delivering the message to its destination; is this possible? $rfc822_header->more_headers['Return-Receipt-To'] = $from->mailbox.'@'.$from->domain; } elseif (isset($rfc822_header->more_headers['Return-Receipt-To'])) { unset($rfc822_header->more_headers['Return-Receipt-To']); @@ -1588,20 +1601,16 @@ function deliverMessage($composeMessage, $draft=false) { $stream = $deliver->initStream($composeMessage,$sendmail_path); } elseif ($draft) { global $draft_folder; - require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php'); $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0); if (sqimap_mailbox_exists ($imap_stream, $draft_folder)) { require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php'); $imap_deliver = new Deliver_IMAP(); - $length = $imap_deliver->mail($composeMessage, 0, $reply_id, $reply_ent_id); - sqimap_append ($imap_stream, $draft_folder, $length); - $imap_deliver->mail($composeMessage, $imap_stream, $reply_id, $reply_ent_id); - sqimap_append_done ($imap_stream, $draft_folder); + $success = $imap_deliver->mail($composeMessage, $imap_stream, $reply_id, $reply_ent_id, $draft_folder); sqimap_logout($imap_stream); unset ($imap_deliver); $composeMessage->purgeAttachments(); - return $length; + return $success; } else { $msg = '
'.sprintf(_("Error: Draft folder %s does not exist."), htmlspecialchars($draft_folder)); plain_error_message($msg); @@ -1610,7 +1619,7 @@ function deliverMessage($composeMessage, $draft=false) { } $success = false; if ($stream) { - $length = $deliver->mail($composeMessage, $stream, $reply_id, $reply_ent_id); + $deliver->mail($composeMessage, $stream, $reply_id, $reply_ent_id); $success = $deliver->finalizeStream($stream); } if (!$success) { @@ -1627,48 +1636,13 @@ function deliverMessage($composeMessage, $draft=false) { plain_error_message($msg); } else { unset ($deliver); - $move_to_sent = getPref($data_dir,$username,'move_to_sent'); $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0); - /* Move to sent code */ - if (isset($default_move_to_sent) && ($default_move_to_sent != 0)) { - $svr_allow_sent = true; - } else { - $svr_allow_sent = false; - } - if (isset($sent_folder) && (($sent_folder != '') || ($sent_folder != 'none')) - && sqimap_mailbox_exists( $imap_stream, $sent_folder)) { - $fld_sent = true; - } else { - $fld_sent = false; - } + // mark as replied or forwarded if applicable + // + global $what, $iAccount, $startMessage, $passed_id, $mailbox; - if ((isset($move_to_sent) && ($move_to_sent != 0)) || (!isset($move_to_sent))) { - $lcl_allow_sent = true; - } else { - $lcl_allow_sent = false; - } - - global $passed_id, $mailbox; - if (($fld_sent && $svr_allow_sent && !$lcl_allow_sent) || ($fld_sent && $lcl_allow_sent)) { - if ($action == 'reply' || $action == 'reply_all') { - $save_reply_with_orig=getPref($data_dir,$username,'save_reply_with_orig'); - if ($save_reply_with_orig) { - $sent_folder = $mailbox; - } - } - sqimap_append ($imap_stream, $sent_folder, $length); - require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php'); - $imap_deliver = new Deliver_IMAP(); - $imap_deliver->mail($composeMessage, $imap_stream, $reply_id, $reply_ent_id); - sqimap_append_done ($imap_stream, $sent_folder); - unset ($imap_deliver); - } - - global $what, $iAccount, $startMessage; - - $composeMessage->purgeAttachments(); if ($action=='reply' || $action=='reply_all' || $action=='forward' || $action=='forward_as_attachment') { require(SM_PATH . 'functions/mailbox_display.php'); $aMailbox = sqm_api_mailbox_select($imap_stream, $iAccount, $mailbox,array('setindex' => $what, 'offset' => $startMessage),array()); @@ -1713,8 +1687,50 @@ function deliverMessage($composeMessage, $draft=false) { sqsession_register($mailbox_cache,'mailbox_cache'); } - sqimap_logout($imap_stream); } + + + // move to sent folder + // + $move_to_sent = getPref($data_dir,$username,'move_to_sent'); + if (isset($default_move_to_sent) && ($default_move_to_sent != 0)) { + $svr_allow_sent = true; + } else { + $svr_allow_sent = false; + } + + if (isset($sent_folder) && (($sent_folder != '') || ($sent_folder != 'none')) + && sqimap_mailbox_exists( $imap_stream, $sent_folder)) { + $fld_sent = true; + } else { + $fld_sent = false; + } + + if ((isset($move_to_sent) && ($move_to_sent != 0)) || (!isset($move_to_sent))) { + $lcl_allow_sent = true; + } else { + $lcl_allow_sent = false; + } + + if (($fld_sent && $svr_allow_sent && !$lcl_allow_sent) || ($fld_sent && $lcl_allow_sent)) { + if ($action == 'reply' || $action == 'reply_all') { + $save_reply_with_orig=getPref($data_dir,$username,'save_reply_with_orig'); + if ($save_reply_with_orig) { + $sent_folder = $mailbox; + } + } + require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php'); + $imap_deliver = new Deliver_IMAP(); + $imap_deliver->mail($composeMessage, $imap_stream, $reply_id, $reply_ent_id, $sent_folder); + unset ($imap_deliver); + } + + + // final cleanup + // + $composeMessage->purgeAttachments(); + sqimap_logout($imap_stream); + } return $success; }