* @package squirrelmail
*/
+/** This is the read_body page */
+define('PAGE_NAME', 'read_body');
+
/**
* Include the SquirrelMail initialization file.
*/
in_array('\\*',$aFlags,true) ) ;
}
-function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
- global $username, $attachment_dir, $popuser, $username, $color,
- $squirrelmail_language, $default_charset,
- $languages, $useSendmail, $domain, $sent_folder;
+function SendMDN ( $mailbox, $passed_id, $message, $imapConnection) {
+ global $squirrelmail_language, $default_charset, $default_move_to_sent,
+ $languages, $useSendmail, $domain, $sent_folder, $username,
+ $data_dir;
sqgetGlobalVar('SERVER_NAME', $SERVER_NAME, SQ_SERVER);
}
$rfc822_header->content_type = $content_type;
$rfc822_header->to[] = $header->dnt;
- $rfc822_header->subject = _("Read:") . ' ' . encodeHeader($header->subject);
-
- // Patch #793504 Return Receipt Failing with <@> from Tim Craig (burny_md)
- // This merely comes from compose.php and only happens when there is no
- // email_addr specified in user's identity (which is the startup config)
- if (ereg("^([^@%/]+)[@%/](.+)$", $username, $usernamedata)) {
- $popuser = $usernamedata[1];
- $domain = $usernamedata[2];
- unset($usernamedata);
- } else {
- $popuser = $username;
- }
+ $rfc822_header->subject = _("Read:") . ' ' . decodeHeader($header->subject,true,false);
- $reply_to = '';
- $ident = get_identities();
- if(!isset($identity)) $identity = 0;
- $full_name = $ident[$identity]['full_name'];
- $from_mail = $ident[$identity]['email_address'];
- $from_addr = '"'.$full_name.'" <'.$from_mail.'>';
- $reply_to = $ident[$identity]['reply_to'];
-
- if (!$from_mail) {
- $from_mail = "$popuser@$domain";
- $from_addr = $from_mail;
+ $idents = get_identities();
+ $needles = array();
+ if ($header->to) {
+ foreach ($header->to as $message_to) {
+ $needles[] = $message_to->mailbox.'@'.$message_to->host;
+ }
}
+ $identity = find_identity($needles);
+ $from_addr = build_from_header($identity);
+ $reply_to = isset($idents[$identity]['reply_to']) ? $idents[$identity]['reply_to'] : '';
+ // FIXME: this must actually be the envelope address of the orginal message,
+ // but do we have that information? For now the first identity is our best guess.
+ $final_recipient = $idents[0]['email_address'];
+
$rfc822_header->from = $rfc822_header->parseAddress($from_addr,true);
if ($reply_to) {
$rfc822_header->reply_to = $rfc822_header->parseAddress($reply_to,true);
if ($original_recipient != '') {
$report .= "Original-Recipient : $original_recipient\r\n";
}
- $final_recipient = $sender;
$report .= "Final-Recipient: rfc822; $final_recipient\r\n" .
"Original-Message-ID : $original_message_id\r\n" .
"Disposition: manual-action/MDN-sent-manually; displayed\r\n";
} else {
require_once(SM_PATH . 'class/deliver/Deliver_SMTP.class.php');
$deliver = new Deliver_SMTP();
- global $smtpServerAddress, $smtpPort, $pop_before_smtp;
+ global $smtpServerAddress, $smtpPort, $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);
+ $smtpServerAddress, $smtpPort, $user, $pass, $authPop, $pop_before_smtp_host);
}
$success = false;
if ($stream) {
- $length = $deliver->mail($composeMessage, $stream);
+ $deliver->mail($composeMessage, $stream);
$success = $deliver->finalizeStream($stream);
}
if (!$success) {
- $msg = _("Message not sent.") . "<br />\n" .
+ $msg = _("Message not sent.") . "\n" .
$deliver->dlv_msg;
if (! empty($deliver->dlv_server_msg)) {
- $msg.= '<br />' .
+ $msg.= "\n" .
_("Server replied:") . ' ' . $deliver->dlv_ret_nr . ' ' .
nl2br(htmlspecialchars($deliver->dlv_server_msg));
}
- plain_error_message($msg, $color);
+ plain_error_message($msg);
} else {
unset ($deliver);
- if (sqimap_mailbox_exists ($imapConnection, $sent_folder)) {
- $sid = sqimap_append ($imapConnection, $sent_folder, $length);
+
+ // 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( $imapConnection, $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)) {
+ $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, $imapConnection);
- sqimap_append_done ($imapConnection, $sent_folder);
+ $imap_deliver->mail($composeMessage, $imapConnection, 0, 0, $imapConnection, $sent_folder);
unset ($imap_deliver);
}
}
}
function formatRecipientString($recipients, $item ) {
- global $show_more_cc, $show_more, $show_more_bcc,
+ global $show_more, $show_more_cc, $show_more_bcc,
$PHP_SELF, $oTemplate;
$string = '';
$a = array();
foreach ($recipients as $r) {
$a[] = array(
- 'Name' => htmlspecialchars($r->getAddress(false)),
+ // note: decodeHeader is htmlsafe by default
+ 'Name' => decodeHeader($r->getAddress(false)),
'Email' => htmlspecialchars($r->getEmail()),
- 'Full' => htmlspecialchars($r->getAddress(true))
+ 'Full' => decodeHeader($r->getAddress(true))
);
}
$oTemplate->assign('xmailer', decodeHeader($header->xmailer));
$env[_("Mailer")] = $oTemplate->fetch('read_xmailer.tpl');
}
+
+ // this is used for both mdn and also general use for plugins, etc
+ $oTemplate->assign('first_time_reading', $FirstTimeSee);
+
if ($default_use_mdn) {
if ($mdn_user_support) {
if ($header->dnt) {
$mdn_url = set_url_var($mdn_url, 'sendreceipt', 1);
$oTemplate->assign('read_receipt_sent', $message->is_mdnsent);
- $oTemplate->assign('first_time_reading', $FirstTimeSee);
$oTemplate->assign('send_receipt_href', $mdn_url);
$env[_("Read Receipt")] = $oTemplate->fetch('read_handle_receipt.tpl');
/**
* Format message toolbar
*
- * @param string $mailbox Name of current mailbox
+ * @param array $aMailbox Current mailbox information array
* @param int $passed_id UID of current message
* @param int $passed_ent_id Id of entity within message
* @param object $message Current message object
$urlMailbox = urlencode($mailbox);
- $msgs_url = $base_uri . 'src/';
-
// Create Prev & Next links
// Handle nested entities first (i.e. Mime Attach parts)
$prev_href = $next_href = $up_href = $del_href = $del_prev_href = $del_next_href = '';
}
}
- // Start with Search Results or Message List link.
- $list_xtra = "?where=read_body.php&what=$what&mailbox=" . $urlMailbox.
- "&startMessage=$startMessage";
- $msg_list_href = $base_uri .'src/right_main.php'. $list_xtra;
- $search_href = $where=='search.php' ? $base_uri .'src/search.php?'.$list_xtra : '';
+ $msg_list_href = get_message_list_uri($aMailbox['NAME'], $startMessage, $what);
+ if ($where == 'search.php')
+ $search_href = str_replace('read_body.php', 'search.php', $msg_list_href);
+ else
+ $search_href = '';
$comp_uri = $base_uri.'src/compose.php' .
'?passed_id=' . $passed_id .
function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
global $base_uri, $where, $what, $show_html_default,
- $oTemplate, $download_href,
+ $oTemplate, $download_href, $PHP_SELF,
$unsafe_image_toggle_href, $unsafe_image_toggle_text;
$urlMailbox = urlencode($mailbox);
}
$url = $base_uri.'src/view_header.php?'.$query_string;
-
- // Build the printer friend link
- /* hackydiehack */
- if( !sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET) ) {
- $view_unsafe_images = false;
- } else {
- $view_unsafe_images = true;
- }
- $pf_params = '?passed_ent_id=' . $urlPassed_ent_id .
- '&mailbox=' . $urlMailbox .
- '&passed_id=' . $urlPassed_id .
- '&view_unsafe_images='. (bool) $view_unsafe_images .
- '&show_html_default=' . $show_html_default;
$links = array();
$links[] = array (
'URL' => $url,
'Text' => _("View Full Header")
);
- $links[] = array (
- 'URL' => $pf_params,
- 'Text' => _("View Printable Version")
+
+ if ( checkForJavaScript() ) {
+ $links[] = array (
+ 'URL' => 'javascript:printThis();',
+ 'Text' => _("Print"),
);
+ } else {
+ $links[] = array (
+ 'URL' => set_url_var($PHP_SELF, 'print', '1'),
+ 'Text' => _("Print"),
+ 'Target' => '_blank'
+ );
+ }
+
$links[] = array (
'URL' => $download_href,
'Text' => _("Download this as a file")
} else {
$view_unsafe_images = 0;
}
+
/**
* Retrieve mailbox cache
*/
sqgetGlobalVar('mailbox_cache',$mailbox_cache,SQ_SESSION);
/* end of get globals */
-global $sqimap_capabilities, $lastTargetMailbox;
$imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
$aMailbox = sqm_api_mailbox_select($imapConnection, $iAccount, $mailbox,array('setindex' => $what, 'offset' => $startMessage),array());
} else {
$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
$FirstTimeSee = !$message->is_seen;
- $message->is_seen = true;
- $aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message;
}
+
+/**
+ * update message seen status and put in cache
+ */
+$message->is_seen = true;
+$aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message;
+
if (isset($passed_ent_id) && $passed_ent_id) {
$message = $message->getEntity($passed_ent_id);
if ($message->type0 != 'message' && $message->type1 != 'rfc822') {
if (isset($sendreceipt)) {
if ( !$message->is_mdnsent ) {
- $final_recipient = '';
- if ((isset($identity)) && ($identity != 0)) //Main identity
- $final_recipient = trim(getPref($data_dir, $username, 'email_address' . $identity, '' ));
- if ($final_recipient == '' )
- $final_recipient = trim(getPref($data_dir, $username, 'email_address', '' ));
$supportMDN = ServerMDNSupport($aMailbox["PERMANENTFLAGS"]);
- if ( SendMDN( $mailbox, $passed_id, $final_recipient, $message, $imapConnection ) > 0 && $supportMDN ) {
+ if ( SendMDN( $mailbox, $passed_id, $message, $imapConnection ) > 0 && $supportMDN ) {
ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id);
$message->is_mdnsent = true;
$aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message;
/* End of block for handling incoming url vars */
/***********************************************/
+$oTemplate->assign('aAttribs', array('class' => 'entity_sep'));
+$hr = $oTemplate->fetch('horizontal_rule.tpl');
$messagebody = '';
do_hook('read_body_top', $null);
if ($show_html_default == 1) {
for ($i = 0; $i < $cnt; $i++) {
$messagebody .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox);
if ($i != $cnt-1) {
- $messagebody .= '<hr />';
+ $messagebody .= $hr;
}
}
sqsession_register($mailbox_cache,'mailbox_cache');
$_SESSION['mailbox_cache'] = $mailbox_cache;
+// message list URI is used in page header when on read_body
+$oTemplate->assign('message_list_href', get_message_list_uri($aMailbox['NAME'], $startMessage, $what));
+
displayPageHeader($color, $mailbox,'','');
-formatMenuBar($aMailbox, $passed_id, $passed_ent_id, $message,false);
+
+/* this is the non-javascript version of printer friendly */
+if ( sqgetGlobalVar('print', $print, SQ_GET) ) {
+ $oTemplate->display('read_message_print.tpl');
+} else {
+ formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message,false);
+}
formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
$oTemplate->assign('message_body', $messagebody);
$oTemplate->display('read_display_images_inline.tpl');
}
-formatMenuBar($aMailbox, $passed_id, $passed_ent_id, $message, false, FALSE);
+formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, false, FALSE);
do_hook('read_body_bottom', $null);
sqimap_logout($imapConnection);
$oTemplate->display('footer.tpl');
-?>