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();
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 ' <br><br><div style="text-align: center;"><a href="' . $location
exit();
} else {
if ( !isset($pageheader_sent) || !$pageheader_sent ) {
- Header("Location: $location/right_main.php?mailbox=" . urlencode($draft_folder) .
+ header("Location: $location/right_main.php?mailbox=" . urlencode($draft_folder) .
"&startMessage=1¬e=".urlencode($draft_message));
} else {
//FIXME: DON'T ECHO HTML FROM CORE!
// NOTE: this hook changed in 1.5.2 from sending $Result and
// $composeMessage as args #2 and #3 to being in an array
// under arg #2
- do_hook('compose_send_after', $temp=array(&$Result, &$composeMessage, &$mail_sent));
+ $temp = array(&$Result, &$composeMessage, &$mail_sent);
+ do_hook('compose_send_after', $temp);
if (! $Result) {
showInputForm($session);
exit();
if ($compose_new_win == '1') {
if ( !isset($pageheader_sent) || !$pageheader_sent ) {
- Header("Location: $location/compose.php?mail_sent=$mail_sent");
+ header("Location: $location/compose.php?mail_sent=$mail_sent");
} else {
//FIXME: DON'T ECHO HTML FROM CORE!
echo ' <br><br><div style="text-align: center;"><a href="' . $location
exit();
} else {
if ( !isset($pageheader_sent) || !$pageheader_sent ) {
- Header("Location: $location/right_main.php?mailbox=$urlMailbox".
+ header("Location: $location/right_main.php?mailbox=$urlMailbox".
"&startMessage=$startMessage&mail_sent=$mail_sent");
} else {
//FIXME: DON'T ECHO HTML FROM CORE!
$request_dr = $mdn_user_support && !empty($orig_header->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
if ($filename == "") {
$filename = "untitled-".$message->entity_id;
}
- $filename .= '.msg';
+ $filename .= '.eml';
} else {
$filename = $message->getFilename();
}
$fp = fopen($hashed_attachment_dir . '/' . $localfilename, 'wb');
fwrite ($fp, $body);
fclose($fp);
- $composeMessage->initAttachment('message/rfc822',$subject.'.msg',
+ $composeMessage->initAttachment('message/rfc822',$subject.'.eml',
$localfilename);
}
return $composeMessage;
// 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;
}
}
* 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,
}
/* 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']);
$rfc822_header->content_type = $content_type;
$composeMessage->rfc822_header = $rfc822_header;
+ if ($action == 'reply' || $action == 'reply_all') {
+ global $passed_id, $passed_ent_id;
+ $reply_id = $passed_id;
+ $reply_ent_id = $passed_ent_id;
+ } else {
+ $reply_id = '';
+ $reply_ent_id = '';
+ }
/* Here you can modify the message structure just before we hand
it over to deliver; plugin authors note that $composeMessage
$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);
- sqimap_append ($imap_stream, $draft_folder, $length);
- $imap_deliver->mail($composeMessage, $imap_stream);
- 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 = '<br />'.sprintf(_("Error: Draft folder %s does not exist."), htmlspecialchars($draft_folder));
plain_error_message($msg);
}
$success = false;
if ($stream) {
- $length = $deliver->mail($composeMessage, $stream);
+ $deliver->mail($composeMessage, $stream, $reply_id, $reply_ent_id);
$success = $deliver->finalizeStream($stream);
}
if (!$success) {
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;
- }
-
- 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);
- sqimap_append_done ($imap_stream, $sent_folder);
- unset ($imap_deliver);
- }
-
- global $what, $iAccount, $startMessage;
+ // mark as replied or forwarded if applicable
+ //
+ global $what, $iAccount, $startMessage, $passed_id, $mailbox;
- $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());
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, $imap_stream);
+ unset ($imap_deliver);
+ }
+
+
+ // final cleanup
+ //
+ $composeMessage->purgeAttachments();
+ sqimap_logout($imap_stream);
+
}
return $success;
}