* - Send mail
* - Save As Draft
*
- * @copyright 1999-2011 The SquirrelMail Project Team
+ * @copyright 1999-2017 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package squirrelmail
require_once(SM_PATH . 'functions/addressbook.php');
require_once(SM_PATH . 'functions/forms.php');
require_once(SM_PATH . 'functions/identity.php');
+global $imap_stream_options; // in case not defined in config
/* --------------------- Get globals ------------------------------------- */
}
sqgetGlobalVar('session',$session, $SQ_GLOBAL);
sqgetGlobalVar('mailbox',$mailbox, $SQ_GLOBAL);
+sqgetGlobalVar('identity',$orig_identity, $SQ_GLOBAL);
if(!sqgetGlobalVar('identity',$identity, $SQ_GLOBAL)) {
$identity=0;
}
// validate security token
//
- sm_validate_security_token($submitted_token, 3600, TRUE);
+ sm_validate_security_token($submitted_token, -1, TRUE);
/*
* Set $default_charset to correspond with the user's selection
$draft_message = _("Draft Email Saved");
/* If this is a resumed draft, then delete the original */
if(isset($delete_draft)) {
- $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, false);
+ $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, false, $imap_stream_options);
sqimap_mailbox_select($imap_stream, $draft_folder);
// force bypass_trash=true because message should be saved when deliverMessage() returns true.
// in current implementation of sqimap_msgs_list_flag() single message id can
// validate security token
//
- sm_validate_security_token($submitted_token, 3600, TRUE);
+ sm_validate_security_token($submitted_token, -1, TRUE);
if (isset($_FILES['attachfile']) &&
$_FILES['attachfile']['tmp_name'] &&
/* if it is resumed draft, delete draft message */
if ( isset($delete_draft)) {
- $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, false);
+ $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, false, $imap_stream_options);
sqimap_mailbox_select($imap_stream, $draft_folder);
// bypass_trash=true because message should be saved when deliverMessage() returns true.
// in current implementation of sqimap_msgs_list_flag() single message id can
// validate security token
//
- sm_validate_security_token($submitted_token, 3600, TRUE);
+ sm_validate_security_token($submitted_token, -1, TRUE);
if ($compose_new_win == '1') {
compose_Header($color, $mailbox);
// validate security token
//
- sm_validate_security_token($submitted_token, 3600, TRUE);
+ sm_validate_security_token($submitted_token, -1, TRUE);
if ($compose_new_win == '1') {
compose_Header($color, $mailbox);
// validate security token
//
- sm_validate_security_token($submitted_token, 3600, TRUE);
+ sm_validate_security_token($submitted_token, -1, TRUE);
$signature = $idents[$identity]['signature'];
// validate security token
//
- sm_validate_security_token($submitted_token, 3600, TRUE);
+ sm_validate_security_token($submitted_token, -1, TRUE);
if ($compose_new_win == '1') {
compose_Header($color, $mailbox);
if (isset($subject)) {
$values['subject'] = $subject;
}
+ if (isset($mailprio)) {
+ $values['mailprio'] = $mailprio;
+ }
+ if (isset($orig_identity)) {
+ $values['identity'] = $orig_identity;
+ }
showInputForm($session, $values);
}
function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $session='') {
global $editor_size, $default_use_priority, $body, $idents,
$use_signature, $data_dir, $username,
- $key, $imapServerAddress, $imapPort,
+ $key, $imapServerAddress, $imapPort, $imap_stream_options,
$composeMessage, $body_quote, $request_mdn, $request_dr,
$mdn_user_support, $languages, $squirrelmail_language,
- $default_charset;
+ $default_charset, $do_not_reply_to_self;
/*
* Set $default_charset to correspond with the user's selection
if ($passed_id) {
$imapConnection = sqimap_login($username, false, $imapServerAddress,
- $imapPort, 0);
+ $imapPort, 0, $imap_stream_options);
sqimap_mailbox_select($imapConnection, $mailbox);
$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
if (count($idents) > 1) {
foreach($idents as $nr=>$data) {
$enc_from_name = '"'.$data['full_name'].'" <'. $data['email_address'].'>';
- if(strtolower($enc_from_name) == strtolower($orig_from)) {
- $identity = $nr;
- // don't stop! need to build $identities array for idents match below
- //break;
- }
$identities[] = $enc_from_name;
}
$identity_match = $orig_header->findAddress($identities);
- if ($identity_match) {
+ if ($identity_match !== FALSE) {
$identity = $identity_match;
}
}
}
$send_to = decodeHeader($send_to,false,false,true);
$send_to = str_replace('""', '"', $send_to);
+
+
+ // If user doesn't want replies to her own messages
+ // going back to herself (instead send again to the
+ // original recipient of the message being replied to),
+ // then iterate through identities, checking if the TO
+ // field is one of them (if the reply is to ourselves)
+ //
+ // Note we don't bother if the original message doesn't
+ // have anything in the TO field itself (because that's
+ // what we use if we change the recipient to be that of
+ // the previous message)
+ //
+ if ($do_not_reply_to_self && !empty($orig_header->to)) {
+
+ $orig_to = '';
+
+ foreach($idents as $id) {
+
+ if (!empty($id['email_address'])
+ && strpos($send_to, $id['email_address']) !== FALSE) {
+
+ // if this is a reply-all, the original recipient
+ // is already in the CC field, so we can just blank
+ // the recipient (TO field) (as long as the CC field
+ // isn't empty that is)... but then move the CC into
+ // the TO, so TO isn't empty
+ //
+ if ($action == 'reply_all' && !empty($send_to_cc)) {
+ $orig_to = $send_to_cc;
+ $send_to_cc = '';
+ break;
+ }
+
+ $orig_to = $orig_header->to;
+ if (is_array($orig_to) && count($orig_to)) {
+ $orig_to = $orig_header->getAddr_s('to', ',', FALSE, TRUE);
+ } else if (is_object($orig_to)) { /* unneccesarry, just for failsafe purpose */
+ $orig_to = $orig_header->getAddr_s('to', ',', FALSE, TRUE);
+ } else {
+ $orig_to = '';
+ }
+ $orig_to = decodeHeader($orig_to,false,false,true);
+ $orig_to = str_replace('""', '"', $orig_to);
+
+ break;
+ }
+ }
+
+ // if the reply was addressed back to ourselves,
+ // we will send it to the TO of the previous message
+ //
+ if (!empty($orig_to)) {
+
+ $send_to = $orig_to;
+
+ // in this case, we also want to reset the FROM
+ // identity as well (it should match the original
+ // *FROM* header instead of TO or CC)
+ //
+ if (count($idents) > 1) {
+ $identity = '';
+ foreach($idents as $i => $id) {
+ if (!empty($id['email_address'])
+ && strpos($orig_from, $id['email_address']) !== FALSE) {
+ $identity = $i;
+ break;
+ }
+ }
+ }
+
+ }
+
+ }
+
+
$subject = decodeHeader($orig_header->subject,false,false,true);
$subject = str_replace('"', "'", $subject);
$subject = trim($subject);
// to do; SquirrelMail itself will add the final "return true".
// Onsubmit text is enclosed inside of double quotes, so plugins
// need to quote accordingly.
+ //
+ // Also, plugin authors should try to retain compatibility with
+ // the Compose Extras plugin by resetting its compose submit
+ // counter when preventing form submit. Use this code:
+ // if (your-code-here) { submit_count = 0; return false; }
+ //
if (checkForJavascript()) {
if (empty($compose_onsubmit))
$compose_onsubmit = array();
$oTemplate->assign('identity_def', $identity);
$oTemplate->assign('input_onfocus', 'onfocus="'.join(' ', $onfocus_array).'"');
- $oTemplate->assign('to', htmlspecialchars($send_to));
- $oTemplate->assign('cc', htmlspecialchars($send_to_cc));
- $oTemplate->assign('bcc', htmlspecialchars($send_to_bcc));
- $oTemplate->assign('subject', htmlspecialchars($subject));
+ $oTemplate->assign('to', sm_encode_html_special_chars($send_to));
+ $oTemplate->assign('cc', sm_encode_html_special_chars($send_to_cc));
+ $oTemplate->assign('bcc', sm_encode_html_special_chars($send_to_bcc));
+ $oTemplate->assign('subject', sm_encode_html_special_chars($subject));
// access keys...
//
} else {
$body_str = "\n\n".($prefix_sig==true? "-- \n":'').decodeHeader($signature,false,false);
}
- $body_str .= "\n\n".htmlspecialchars(decodeHeader($body,false,false));
+ $body_str .= "\n\n".sm_encode_html_special_chars(decodeHeader($body,false,false));
} else {
- $body_str = "\n\n".htmlspecialchars(decodeHeader($body,false,false));
+ $body_str = "\n\n".sm_encode_html_special_chars(decodeHeader($body,false,false));
// FIXME: test is specific to ja_JP translation implementation. See above comments.
if ($default_charset == 'iso-2022-jp') {
$body_str .= "\n\n".($prefix_sig==true? "-- \n":'').mb_convert_encoding($signature, 'EUC-JP');
}
}
} else {
- $body_str = htmlspecialchars(decodeHeader($body,false,false));
+ $body_str = sm_encode_html_special_chars(decodeHeader($body,false,false));
}
$oTemplate->assign('editor_width', (int)$editor_size);
$username, $identity, $idents, $data_dir,
$request_mdn, $request_dr, $default_charset, $useSendmail,
$domain, $action, $default_move_to_sent, $move_to_sent,
- $imapServerAddress, $imapPort, $sent_folder, $key;
+ $imapServerAddress, $imapPort, $imap_stream_options, $sent_folder, $key;
$rfc822_header = $composeMessage->rfc822_header;
$reply_to = '';
$reply_to = $idents[$identity]['reply_to'];
+ if ($reply_to && strpos($reply_to, '@') === FALSE)
+ $reply_to .= '@' . $domain;
$from_addr = build_from_header($identity);
$rfc822_header->from = $rfc822_header->parseAddress($from_addr,true);
it over to deliver; plugin authors note that $composeMessage
is sent and modified by reference since 1.5.2 */
do_hook('compose_send', $composeMessage);
+//TODO: need to migrate to the following, but it neessitates changes in existing plugins, since the args are now an array
+ //$temp = array(&$composeMessage, &$draft);
+ //do_hook('compose_send', $temp);
if (!$useSendmail && !$draft) {
require_once(SM_PATH . 'class/deliver/Deliver_SMTP.class.php');
$deliver = new Deliver_SMTP();
- global $smtpServerAddress, $smtpPort, $pop_before_smtp, $pop_before_smtp_host;
+ global $smtpServerAddress, $smtpPort, $smtp_stream_options, $pop_before_smtp, $pop_before_smtp_host;
$authPop = (isset($pop_before_smtp) && $pop_before_smtp) ? true : false;
if (empty($pop_before_smtp_host)) $pop_before_smtp_host = $smtpServerAddress;
get_smtp_user($user, $pass);
$stream = $deliver->initStream($composeMessage,$domain,0,
- $smtpServerAddress, $smtpPort, $user, $pass, $authPop, $pop_before_smtp_host);
+ $smtpServerAddress, $smtpPort, $user, $pass, $authPop, $pop_before_smtp_host, $smtp_stream_options);
} elseif (!$draft) {
require_once(SM_PATH . 'class/deliver/Deliver_SendMail.class.php');
global $sendmail_path, $sendmail_args;
} elseif ($draft) {
global $draft_folder;
$imap_stream = sqimap_login($username, false, $imapServerAddress,
- $imapPort, 0);
+ $imapPort, 0, $imap_stream_options);
if (sqimap_mailbox_exists ($imap_stream, $draft_folder)) {
require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php');
$imap_deliver = new Deliver_IMAP();
$composeMessage->purgeAttachments();
return $success;
} else {
- $msg = '<br />'.sprintf(_("Error: Draft folder %s does not exist."), htmlspecialchars($draft_folder));
+ $msg = '<br />'.sprintf(_("Error: Draft folder %s does not exist."), sm_encode_html_special_chars($draft_folder));
plain_error_message($msg);
return false;
}
}
if (!$success) {
// $deliver->dlv_server_msg is not always server's reply
- $msg = _("Message not sent.") . "<br />\n" .
- $deliver->dlv_msg;
+ $msg = _("Message not sent.")
+ . "<br />\n"
+ . (isset($deliver->dlv_msg) ? $deliver->dlv_msg : '');
if (!empty($deliver->dlv_server_msg)) {
// add 'server replied' part only when it is not empty.
// Delivery error can be generated by delivery class itself
- $msg.='<br />' .
- _("Server replied:") . ' ' . $deliver->dlv_ret_nr . ' ' .
- nl2br(htmlspecialchars($deliver->dlv_server_msg));
+ $msg .= '<br />'
+ . _("Server replied:") . ' '
+ . (isset($deliver->dlv_ret_nr) ? $deliver->dlv_ret_nr . ' ' : '')
+ . nl2br(sm_encode_html_special_chars($deliver->dlv_server_msg));
}
plain_error_message($msg);
} else {
unset ($deliver);
- $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
+ $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
// mark as replied or forwarded if applicable