X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Fcompose.php;h=fd7e07cc1ea25c3290a70cd5dd10ef8f010891ff;hp=4195fb39bb6d452bf50e23dc9960c9c2d3756edc;hb=f360843cf1f56607a191ce731088c7be209ddeb5;hpb=4dfb9db7846ff1440499380fed1ef430a63ba46e diff --git a/src/compose.php b/src/compose.php index 4195fb39..fd7e07cc 100644 --- a/src/compose.php +++ b/src/compose.php @@ -3,7 +3,7 @@ /** * compose.php * - * Copyright (c) 1999-2002 The SquirrelMail Project Team + * Copyright (c) 1999-2003 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * * This code sends a mail. @@ -28,6 +28,7 @@ require_once(SM_PATH . 'functions/mime.php'); require_once(SM_PATH . 'functions/plugin.php'); require_once(SM_PATH . 'functions/display_messages.php'); require_once(SM_PATH . 'class/deliver/Deliver.class.php'); +require_once(SM_PATH . 'functions/addressbook.php'); /* --------------------- Get globals ------------------------------------- */ $username = $_SESSION['username']; @@ -104,7 +105,7 @@ $key = $_COOKIE['key']; function replyAllString($header) { global $include_self_reply_all, $username, $data_dir; - $excl_arr = array(); + $excl_ar = array(); /** * 1) Remove the addresses we'll be sending the message 'to' */ @@ -117,16 +118,16 @@ function replyAllString($header) { * TO list) only if $include_self_reply_all is turned off */ if (!$include_self_reply_all) { - $email_address = trim(getPref($data_dir, $username, 'email_address')); + $email_address = strtolower(trim(getPref($data_dir, $username, 'email_address'))); $excl_ar[$email_address] = ''; - $idents = getPref($data_dir, $username, 'identities'); if ($idents != '' && $idents > 1) { + $first_id = false; for ($i = 1; $i < $idents; $i ++) { $cur_email_address = getPref($data_dir, $username, 'email_address' . $i); - $cur_email_address = strtolower($cur_email_address); - $excl_ar[$cur_email_address] = ''; + $cur_email_address = strtolower(trim($cur_email_address)); + $excl_ar[$cur_email_address] = ''; } } } @@ -142,9 +143,9 @@ function replyAllString($header) { $url_replytoallcc = ''; foreach( $url_replytoall_ar as $email => $personal) { if ($personal) { - $url_replytoallcc .= ", \"$personal\" <$email>"; + $url_replytoallcc .= ", \"$personal\" <$email>"; } else { - $url_replytoallcc .= ', '. $email; + $url_replytoallcc .= ', '. $email; } } $url_replytoallcc = substr($url_replytoallcc,2); @@ -182,23 +183,20 @@ function getforwardHeader($orig_header) { } /* ----------------------------------------------------------------------- */ -/* OLD: should be adapted to composeMessage */ - /* * If the session is expired during a post this restores the compose session * vars. */ -//$session_expired = false; -sqsession_unregister('session_expired_post'); -if (false && session_is_registered('session_expired_post')) { - global $session_expired_post, $session_expired; +if (sqsession_is_registered('session_expired_post')) { + $session_expired_post = $_SESSION['session_expired_post']; /* * extra check for username so we don't display previous post data from * another user during this session. */ if ($session_expired_post['username'] != $username) { + unset($session_expired_post); sqsession_unregister('session_expired_post'); - sqsession_unregister('session_expired'); + session_write_close(); } else { foreach ($session_expired_post as $postvar => $val) { if (isset($val)) { @@ -207,17 +205,20 @@ if (false && session_is_registered('session_expired_post')) { $$postvar = ''; } } + $compose_messages = unserialize(urldecode($restoremessages)); + sqsession_register($compose_messages,'compose_messages'); + sqsession_register($composesession,'composesession'); if (isset($send)) { unset($send); } $session_expired = true; } + unset($session_expired_post); sqsession_unregister('session_expired_post'); - sqsession_unregister('session_expired'); + session_write_close(); if (!isset($mailbox)) { $mailbox = ''; } - if ($compose_new_win == '1') { compose_Header($color, $mailbox); } else { @@ -237,7 +238,6 @@ if (!isset($session) || (isset($newmessage) && $newmessage)) { $composesession = $session; sqsession_register($composesession,'composesession'); } - if (!isset($compose_messages)) { $compose_messages = array(); } @@ -264,10 +264,11 @@ if ($draft) { */ set_my_charset(); $composeMessage=$compose_messages[$session]; - if (! sendMessage($composeMessage, true)) { + if (! deliverMessage($composeMessage, true)) { showInputForm($session); exit(); } else { + unset($compose_messages[$session]); $draft_message = _("Draft Email Saved"); /* If this is a resumed draft, then delete the original */ if(isset($delete_draft)) { @@ -296,6 +297,10 @@ if ($send) { $AttachFailure = saveAttachedFiles($session); } if (checkInput(false) && !isset($AttachFailure)) { + if ($mailbox == "All Folders") { + /* We entered compose via the search results page */ + $mailbox="INBOX"; /* Send 'em to INBOX, that's safe enough */ + } $urlMailbox = urlencode (trim($mailbox)); if (! isset($passed_id)) { $passed_id = 0; @@ -333,17 +338,20 @@ if ($send) { $body = $newBody; do_hook('compose_send'); $composeMessage=$compose_messages[$session]; - $Result = sendMessage($composeMessage); + + $Result = deliverMessage($composeMessage); if (! $Result) { showInputForm($session); exit(); } + unset($compose_messages[$session]); if ( isset($delete_draft)) { Header("Location: delete_message.php?mailbox=" . urlencode( $draft_folder ). "&message=$delete_draft&sort=$sort&startMessage=1&mail_sent=yes"); exit(); } if ($compose_new_win == '1') { + Header("Location: compose.php?mail_sent=yes"); } else { @@ -460,7 +468,6 @@ elseif (isset($sigappend)) { $composeMessage->entities = $new_entities; $compose_messages[$session] = $composeMessage; sqsession_register($compose_messages, 'compose_messages'); -// setPref($data_dir, $username, 'attachments', serialize($attachments)); } showInputForm($session); } else { @@ -585,19 +592,25 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se } else { $orig_from = ''; } + $identities = array(); if (!empty($idents) && $idents > 1) { - for ($i = 1; $i < $idents; $i++) { - $enc_from_name = '"'. - getPref($data_dir, - $username, - 'full_name' . $i) . - '" <' . getPref($data_dir, $username, - 'email_address' . $i) . '>'; - if ($enc_from_name == $orig_from) { + $identities[] = '"'. getPref($data_dir, $username, 'full_name') + . '" <' . getPref($data_dir, $username, 'email_address') . '>'; + for ($i = 1; $i < $idents; $i++) { + $enc_from_name = '"'. + getPref($data_dir, $username, 'full_name' . $i) . + '" <' . + getPref($data_dir, $username, 'email_address' . $i) . '>'; + if ($enc_from_name == $orig_from && $i) { $identity = $i; break; } + $identities[] = $enc_from_name; } + $identity_match = $orig_header->findAddress($identities); + if ($identity_match) { + $identity = $identity_match; + } } switch ($action) { @@ -642,6 +655,7 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se $body = getforwardHeader($orig_header) . $body; sqUnWordWrap($body); $composeMessage = getAttachments($message, $composeMessage, $passed_id, $entities, $imapConnection); + $body = "\n" . $body; break; case ('forward_as_attachment'): $composeMessage = getMessage_RFC822_Attachment($message, $composeMessage, $passed_id, $passed_ent_id, $imapConnection); @@ -651,9 +665,11 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se $send_to_cc = replyAllString($orig_header); case ('reply'): $send_to = $orig_header->reply_to; - if (is_object($send_to)) { - $send_to = decodeHeader($send_to->getAddr_s('reply_to')); - } else { + if (is_array($send_to) && count($send_to)) { + $send_to = decodeHeader($orig_header->getAddr_s('reply_to')); + } else if (is_object($send_to)) { /* unnessecarry, just for falesafe purpose */ + $send_to = decodeHeader($orig_header->getAddr_s('reply_to')); + } else { $send_to = decodeHeader($orig_header->getAddr_s('from')); } $subject = decodeHeader($orig_header->subject); @@ -664,19 +680,18 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se } /* this corrects some wrapping/quoting problems on replies */ $rewrap_body = explode("\n", $body); - - $from = (is_array($orig_header->from)) ? - $orig_header->from[0] : $orig_header->from; + $from = (is_array($orig_header->from)) ? + $orig_header->from[0] : $orig_header->from; $body = getReplyCitation($from->getAddress(false)); - + sqUnWordWrap($body); $cnt = count($rewrap_body); for ($i=0;$i<$cnt;$i++) { -// sqWordWrap($rewrap_body[$i], ($editor_size - 2)); + sqWordWrap($rewrap_body[$i], ($editor_size)); if (preg_match("/^(>+)/", $rewrap_body[$i], $matches)) { $gt = $matches[1]; - $body .= '>' . str_replace("\n", "\n$gt ", $rewrap_body[$i]) ."\n"; + $body .= '>' . str_replace("\n", "\n>$gt ", rtrim($rewrap_body[$i])) ."\n"; } else { - $body .= '> ' . $rewrap_body[$i] . "\n"; + $body .= '> ' . str_replace("\n", "\n> ", rtrim($rewrap_body[$i])) . "\n"; } unset($rewrap_body[$i]); } @@ -687,7 +702,7 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se } $compose_messages[$session] = $composeMessage; sqsession_register($compose_messages, 'compose_messages'); - + session_write_close(); sqimap_logout($imapConnection); } $ret = array( 'send_to' => $send_to, @@ -797,7 +812,7 @@ function showInputForm ($session, $values=false) { $username, $data_dir, $identity, $draft_id, $delete_draft, $mailprio, $default_use_mdn, $mdn_user_support, $compose_new_win, $saved_draft, $mail_sent, $sig_first, $edit_as_new, $action, - $username, $compose_messages; + $username, $compose_messages, $composesession, $default_charset; $composeMessage = $compose_messages[$session]; @@ -809,7 +824,7 @@ function showInputForm ($session, $values=false) { $subject = $values['subject']; $mailprio = $values['mailprio']; $body = $values['body']; - $identity = $values['identity']; + $identity = (int) $values['identity']; } if ($use_javascript_addr_book) { @@ -862,12 +877,11 @@ function showInputForm ($session, $values=false) { if ($idents > 1) { echo ' ' . "\n" . ' ' . - "\n" . - _("From:") . - ' ' . "\n" . - '' . "\n" . + '