* - Save As Draft
*
* $Id$
+ * @package squirrelmail
*/
-/* Path for SquirrelMail required files. */
+/** Path for SquirrelMail required files. */
define('SM_PATH','../');
/* SquirrelMail required files. */
sqgetGlobalVar('ent_num',$ent_num);
sqgetGlobalVar('saved_draft',$saved_draft);
sqgetGlobalVar('delete_draft',$delete_draft);
-sqgetGlobalVar('startmessage',$startMessage);
+sqgetGlobalVar('startMessage',$startMessage);
/** POST VARS */
sqgetGlobalVar('sigappend', $sigappend, SQ_POST);
$url_replytoallcc = '';
foreach( $url_replytoall_ar as $email => $personal) {
if ($personal) {
+ // if personal name contains address separator then surround
+ // the personal name with double quotes.
+ if (strpos($personal,',') !== false) {
+ $personal = '"'.$personal.'"';
+ }
$url_replytoallcc .= ", $personal <$email>";
} else {
$url_replytoallcc .= ', '. $email;
showInputForm($session);
exit();
}
- unset($compose_messages[$session]);
+ unset($compose_messages[$session]);
if ( isset($delete_draft)) {
Header("Location: $location/delete_message.php?mailbox=" . urlencode( $draft_folder ).
"&message=$delete_draft&sort=$sort&startMessage=1&mail_sent=yes");
}
else {
Header("Location: $location/right_main.php?mailbox=$urlMailbox&sort=$sort".
- "&startMessage=$startMessage");
+ "&startMessage=$startMessage&mail_sent=yes");
}
} else {
if ($compose_new_win == '1') {
/**************** Only function definitions go below *************/
+function getforwardSubject($subject)
+{
+ if ((substr(strtolower($subject), 0, 4) != 'fwd:') &&
+ (substr(strtolower($subject), 0, 5) != '[fwd:') &&
+ (substr(strtolower($subject), 0, 6) != '[ fwd:')) {
+ $subject = '[Fwd: ' . $subject . ']';
+ }
+ return $subject;
+}
/* This function is used when not sending or adding attachments */
function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $session='') {
$use_signature, $composesession, $data_dir, $username,
$username, $key, $imapServerAddress, $imapPort, $compose_messages,
$composeMessage;
- global $languages, $squirrelmail_language;
+ global $languages, $squirrelmail_language, $default_charset;
$send_to = $send_to_cc = $send_to_bcc = $subject = $identity = '';
$mailprio = 3;
$bodypart = decodeBody($unencoded_bodypart,
$body_part_entity->header->encoding);
if ($type1 == 'html') {
- $bodypart = str_replace(array(' ','>','<'),array(' ','<','>'),$bodypart);
+ $bodypart = str_replace(array(' ','>','<'),array(' ','<','>'),$bodypart);
$bodypart = strip_tags($bodypart);
}
if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
$bodypart = $languages[$squirrelmail_language]['XTRA_CODE']('decode', $bodypart);
}
}
+
+ if (isset($body_part_entity->header->parameters['charset'])) {
+ $actual = $body_part_entity->header->parameters['charset'];
+ } else {
+ $actual = 'us-ascii';
+ }
+
+ if ( $actual && is_conversion_safe($actual) && $actual != $default_charset){
+ $bodypart = charset_decode($actual,$bodypart);
+ }
+
$body .= $bodypart;
}
if ($default_use_priority) {
break;
case ('forward'):
$send_to = '';
- $subject = decodeHeader($orig_header->subject,false,true);
- if ((substr(strtolower($subject), 0, 4) != 'fwd:') &&
- (substr(strtolower($subject), 0, 5) != '[fwd:') &&
- (substr(strtolower($subject), 0, 6) != '[ fwd:')) {
- $subject = '[Fwd: ' . $subject . ']';
- }
+ $subject = getforwardSubject(decodeHeader($orig_header->subject,false,true));
$body = getforwardHeader($orig_header) . $body;
sqUnWordWrap($body);
$composeMessage = getAttachments($message, $composeMessage, $passed_id, $entities, $imapConnection);
$body = "\n" . $body;
break;
case ('forward_as_attachment'):
+ $subject = getforwardSubject(decodeHeader($orig_header->subject,false,true));
$composeMessage = getMessage_RFC822_Attachment($message, $composeMessage, $passed_id, $passed_ent_id, $imapConnection);
$body = '';
break;
case ('reply_all'):
- $send_to_cc = replyAllString($orig_header);
- $send_to_cc = decodeHeader($send_to_cc,false,true);
- case ('reply'):
- $send_to = $orig_header->reply_to;
- if (is_array($send_to) && count($send_to)) {
- $send_to = $orig_header->getAddr_s('reply_to');
- } else if (is_object($send_to)) { /* unnessecarry, just for falesafe purpose */
- $send_to = $orig_header->getAddr_s('reply_to');
+ if(isset($orig_header->mail_followup_to) && $orig_header->mail_followup_to) {
+ $send_to = $orig_header->getAddr_s('mail_followup_to');
} else {
- $send_to = $orig_header->getAddr_s('from');
+ $send_to_cc = replyAllString($orig_header);
+ $send_to_cc = decodeHeader($send_to_cc,false,true);
+ }
+ case ('reply'):
+ // skip this if send_to was already set right above here
+ if(!$send_to) {
+ $send_to = $orig_header->reply_to;
+ if (is_array($send_to) && count($send_to)) {
+ $send_to = $orig_header->getAddr_s('reply_to');
+ } else if (is_object($send_to)) { /* unneccesarry, just for failsafe purpose */
+ $send_to = $orig_header->getAddr_s('reply_to');
+ } else {
+ $send_to = $orig_header->getAddr_s('from');
+ }
}
$send_to = decodeHeader($send_to,false,true);
$subject = decodeHeader($orig_header->subject,false,true);
/* 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;
- sqUnWordWrap($body);
+ sqUnWordWrap($body); // unwrap and then reset it?!
$body = '';
- $cnt = count($rewrap_body);
- for ($i=0;$i<$cnt;$i++) {
- sqWordWrap($rewrap_body[$i], ($editor_size));
- if (preg_match("/^(>+)/", $rewrap_body[$i], $matches)) {
+ $strip_sigs = getPref($data_dir, $username, 'strip_sigs');
+ foreach ($rewrap_body as $line) {
+ if ($strip_sigs && substr($line,0,3) == '-- ') {
+ break;
+ }
+ sqWordWrap($line, ($editor_size));
+ if (preg_match("/^(>+)/", $line, $matches)) {
$gt = $matches[1];
- $body .= '>' . str_replace("\n", "\n>$gt ", rtrim($rewrap_body[$i])) ."\n";
+ $body .= '>' . str_replace("\n", "\n>$gt ", rtrim($line)) ."\n";
} else {
- $body .= '> ' . str_replace("\n", "\n> ", rtrim($rewrap_body[$i])) . "\n";
+ $body .= '> ' . str_replace("\n", "\n> ", rtrim($line)) . "\n";
}
- unset($rewrap_body[$i]);
}
$body = getReplyCitation($from) . $body;
$composeMessage->reply_rfc822_header = $orig_header;
switch ($message->type0) {
case 'message':
if ($message->type1 == 'rfc822') {
- $filename = $message->rfc822_header->subject.'.eml';
+ $filename = $message->rfc822_header->subject;
if ($filename == "") {
- $filename = "untitled-".$message->entity_id.'.eml';
+ $filename = "untitled-".$message->entity_id;
}
+ $filename .= '.msg';
} else {
$filename = $message->getFilename();
}
$filename = $message->getFilename();
break;
}
- $filename = decodeHeader($filename);
+ $filename = str_replace(' ', ' ', decodeHeader($filename));
if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
$filename = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $filename);
$fp = fopen($full_localfilename, 'w');
fwrite ($fp, $body);
fclose($fp);
- $composeMessage->initAttachment('message/rfc822',$subject.'.eml',
+ $composeMessage->initAttachment('message/rfc822',$subject.'.msg',
$full_localfilename);
}
return $composeMessage;
echo '<BR><CENTER><B>'. _("Draft Saved").'</CENTER></B>';
}
if ($mail_sent == 'yes') {
- echo '<BR><CENTER><B>'. _("Your Message has been sent").'</CENTER></B>';
+ echo '<BR><CENTER><B>'. _("Your Message has been sent.").'</CENTER></B>';
}
echo '<table align="center" cellspacing="0" border="0">' . "\n";
if ($compose_new_win == '1') {
if ($compose_new_win == '1') {
echo ' <TR>' . "\n" .
' <TD BGCOLOR="' . $color[0] . '" COLSPAN=2 ALIGN=CENTER>' . "\n" .
- ' <TEXTAREA NAME=body ROWS=20 COLS="' .
+ ' <TEXTAREA NAME=body ID=body ROWS=20 COLS="' .
$editor_size . '" WRAP="VIRTUAL">';
}
else {
echo ' <TR>' . "\n" .
' <TD BGCOLOR="' . $color[4] . '" COLSPAN=2>' . "\n" .
- ' <TEXTAREA NAME=body ROWS=20 COLS="' .
+ ' <TEXTAREA NAME=body ID=body ROWS=20 COLS="' .
$editor_size . '" WRAP="VIRTUAL">';
}
ClearAttachments($composeMessage);
if ($action == 'reply' || $action == 'reply_all') {
sqimap_mailbox_select ($imap_stream, $mailbox);
- sqimap_messages_flag ($imap_stream, $passed_id, $passed_id, 'Answered', true);
+ sqimap_messages_flag ($imap_stream, $passed_id, $passed_id, 'Answered', false);
}
sqimap_logout($imap_stream);
}