X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fcompose.php;h=fef9c415234caa710a3d87def48a1651e2977d1d;hb=cab6eaead684217015f561e18b5f6c8f1a22cbf5;hp=bc63fba71f4ecd797df02e369602a10fbcd22512;hpb=52cf8e76f6a56a61e426a27e08ad8498be67b6ed;p=squirrelmail.git diff --git a/src/compose.php b/src/compose.php index bc63fba7..fef9c415 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']; @@ -117,7 +118,7 @@ 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) { @@ -125,7 +126,7 @@ function replyAllString($header) { for ($i = 1; $i < $idents; $i ++) { $cur_email_address = getPref($data_dir, $username, 'email_address' . $i); - $cur_email_address = strtolower($cur_email_address); + $cur_email_address = strtolower(trim($cur_email_address)); $excl_ar[$cur_email_address] = ''; } } @@ -218,7 +219,6 @@ if (sqsession_is_registered('session_expired_post')) { if (!isset($mailbox)) { $mailbox = ''; } - if ($compose_new_win == '1') { compose_Header($color, $mailbox); } else { @@ -297,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; @@ -808,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, $composesession; + $username, $compose_messages, $composesession, $default_charset; $composeMessage = $compose_messages[$session]; @@ -820,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) { @@ -949,8 +953,17 @@ function showInputForm ($session, $values=false) { $editor_size . '" WRAP="VIRTUAL">'; } if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) { + if ($idents > 1) { + if ($identity == 'default') { + $no = 'g'; + } else { + $no = $identity; + } + $signature = getSig($data_dir, $username, $no); + } + if ($sig_first == '1') { - if ($charset == 'iso-2022-jp') { + if ($default_charset == 'iso-2022-jp') { echo "\n\n".($prefix_sig==true? "-- \n":'').mb_convert_encoding($signature, 'EUC-JP'); } else { echo "\n\n".($prefix_sig==true? "-- \n":'').htmlspecialchars($signature); @@ -959,7 +972,7 @@ function showInputForm ($session, $values=false) { } else { echo "\n\n".htmlspecialchars($body); - if ($charset == 'iso-2022-jp') { + if ($default_charset == 'iso-2022-jp') { echo "\n\n".($prefix_sig==true? "-- \n":'').mb_convert_encoding($signature, 'EUC-JP'); }else{ echo "\n\n".($prefix_sig==true? "-- \n":'').htmlspecialchars($signature); @@ -985,6 +998,7 @@ function showInputForm ($session, $values=false) { } /* This code is for attachments */ + if ((bool) ini_get('file_uploads')) { echo ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n"; - + } // End of file_uploads if-block /* End of attachment code */ if ($compose_new_win == '1') { echo '
'."\n"; } + echo '' . "\n" . '\n" . '\n" . @@ -1051,6 +1066,14 @@ function showInputForm ($session, $values=false) { echo '\n"; echo '\n"; echo ''; + if (!(bool) ini_get('file_uploads')) { + /* File uploads are off, so we didn't show that part of the form. + To avoid bogus bug reports, tell the user why. */ + echo 'Because PHP file uploads are turned off, you can not attach files '; + echo "to this message. Please see your system administrator for details.\r\n"; + } + + do_hook('compose_bottom'); echo '' . "\n"; } @@ -1153,16 +1176,12 @@ function saveAttachedFiles($session) { $full_localfilename = "$hashed_attachment_dir/$localfilename"; } + // FIXME: we SHOULD prefer move_uploaded_file over rename because + // m_u_f works better with restricted PHP installes (safe_mode, open_basedir) if (!@rename($_FILES['attachfile']['tmp_name'], $full_localfilename)) { - if (function_exists("move_uploaded_file")) { if (!@move_uploaded_file($_FILES['attachfile']['tmp_name'],$full_localfilename)) { return true; } - } else { - if (!@copy($_FILES['attachfile']['tmp_name'], $full_localfilename)) { - return true; - } - } } $message = $compose_messages[$session]; $type = strtolower($_FILES['attachfile']['type']); @@ -1235,9 +1254,12 @@ function deliverMessage($composeMessage, $draft=false) { global $imapServerAddress, $imapPort, $sent_folder, $key; $rfc822_header = $composeMessage->rfc822_header; - $rfc822_header->to = $rfc822_header->parseAddress($send_to,true, array(), '', $domain); - $rfc822_header->cc = $rfc822_header->parseAddress($send_to_cc,true,array(), '',$domain); - $rfc822_header->bcc = $rfc822_header->parseAddress($send_to_bcc,true, array(), '',$domain); + + $abook = addressbook_init(false, true); + + $rfc822_header->to = $rfc822_header->parseAddress($send_to,true, array(), '', $domain, array(&$abook,'lookup')); + $rfc822_header->cc = $rfc822_header->parseAddress($send_to_cc,true,array(), '',$domain, array(&$abook,'lookup')); + $rfc822_header->bcc = $rfc822_header->parseAddress($send_to_bcc,true, array(), '',$domain, array(&$abook,'lookup')); $rfc822_header->priority = $mailprio; $rfc822_header->subject = $subject; $special_encoding=''; @@ -1276,7 +1298,7 @@ function deliverMessage($composeMessage, $draft=false) { if ($full_name) { $from = $rfc822_header->from[0]; if (!$from->host) $from->host = $domain; - $from_addr = $full_name .' <'.$from->mailbox.'@'.$from->host.'>'; + $from_addr = '"'.$full_name .'" <'.$from->mailbox.'@'.$from->host.'>'; $rfc822_header->from = $rfc822_header->parseAddress($from_addr,true); } if ($reply_to) { @@ -1322,18 +1344,20 @@ function deliverMessage($composeMessage, $draft=false) { if (!$useSendmail && !$draft) { require_once(SM_PATH . 'class/deliver/Deliver_SMTP.class.php'); $deliver = new Deliver_SMTP(); - global $smtpServerAddress, $smtpPort, $use_authenticated_smtp, $pop_before_smtp; - if ($use_authenticated_smtp) { - global $key, $onetimepad; - $user = $username; - $pass = OneTimePadDecrypt($key, $onetimepad); + global $smtpServerAddress, $smtpPort, $pop_before_smtp, $smtp_auth_mech; + + if ($smtp_auth_mech == 'none') { + $user = ''; + $pass = ''; } else { - $user = ''; - $pass = ''; + global $key, $onetimepad; + $user = $username; + $pass = OneTimePadDecrypt($key, $onetimepad); } + $authPop = (isset($pop_before_smtp) && $pop_before_smtp) ? true : false; $stream = $deliver->initStream($composeMessage,$domain,0, - $smtpServerAddress, $smtpPort, $authPop); + $smtpServerAddress, $smtpPort, $user, $pass, $authPop); } elseif (!$draft) { require_once(SM_PATH . 'class/deliver/Deliver_SendMail.class.php'); global $sendmail_path; @@ -1366,7 +1390,9 @@ function deliverMessage($composeMessage, $draft=false) { $succes = $deliver->finalizeStream($stream); } if (!$succes) { - $msg = $deliver->dlv_msg . '
Server replied: '.$deliver->dlv_ret_nr; + $msg = $deliver->dlv_msg . '
' . + _("Server replied: ") . $deliver->dlv_ret_nr . ' '. + $deliver->dlv_server_msg; plain_error_message($msg, $color); } else { unset ($deliver);