config.php was not loaded before plugin.php, but that's needed to make
[squirrelmail.git] / src / compose.php
index 468b262dc95f3dfba5bdb202bde61a0805c4ed36..4f610ca5d710f0b37eddbd09c5f2bd0dbac0be9a 100644 (file)
@@ -11,7 +11,7 @@
  *    - Send mail
  *    - Save As Draft
  *
- * @copyright © 1999-2005 The SquirrelMail Project Team
+ * @copyright © 1999-2006 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -24,7 +24,7 @@
 define('SM_PATH','../');
 
 /* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
+include_once(SM_PATH . 'include/validate.php');
 require_once(SM_PATH . 'functions/global.php');
 require_once(SM_PATH . 'functions/imap.php');
 require_once(SM_PATH . 'functions/date.php');
@@ -467,7 +467,7 @@ if ($send) {
             exit();
         }
         unset($compose_messages[$session]);
-        
+
         /* if it is resumed draft, delete draft message */
         if ( isset($delete_draft)) {
             $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, false);
@@ -1025,7 +1025,7 @@ function showInputForm ($session, $values=false) {
         $username, $data_dir, $identity, $idents, $delete_draft,
         $mailprio, $compose_new_win, $saved_draft, $mail_sent, $sig_first,
         $username, $compose_messages, $composesession, $default_charset,
-        $compose_onsubmit;
+        $compose_onsubmit, $oTemplate;
 
     if (checkForJavascript()) {
         $onfocus = ' onfocus="alreadyFocused=true;"';
@@ -1070,8 +1070,8 @@ function showInputForm ($session, $values=false) {
 
     // Plugins that use compose_form hook can add an array entry
     // to the globally scoped $compose_onsubmit; we add them up
-    // here and format the form tag's full onsubmit handler.  
-    // Each plugin should use "return false" if they need to 
+    // here and format the form tag's full onsubmit handler.
+    // Each plugin should use "return false" if they need to
     // stop form submission but otherwise should NOT use "return
     // true" to give other plugins the chance to do what they need
     // to do; SquirrelMail itself will add the final "return true".
@@ -1079,21 +1079,21 @@ function showInputForm ($session, $values=false) {
     // need to quote accordingly.
     if (checkForJavascript()) {
         $onsubmit_text = ' onsubmit="';
-        if (empty($compose_onsubmit)) 
+        if (empty($compose_onsubmit))
             $compose_onsubmit = array();
-        else if (!is_array($compose_onsubmit)) 
+        else if (!is_array($compose_onsubmit))
             $compose_onsubmit = array($compose_onsubmit);
 
         foreach ($compose_onsubmit as $text) {
             $text = trim($text);
-            if (substr($text, -1) != ';' && substr($text, -1) != '}') 
+            if (substr($text, -1) != ';' && substr($text, -1) != '}')
                 $text .= '; ';
             $onsubmit_text .= $text;
         }
 
         echo $onsubmit_text . ' return true;"';
     }
-    
+
 
     echo ">\n";
 
@@ -1340,7 +1340,7 @@ function showInputForm ($session, $values=false) {
     }
 
     do_hook('compose_bottom');
-    echo '</body></html>' . "\n";
+    $oTemplate->display('footer.tpl');
 }
 
 
@@ -1608,8 +1608,8 @@ function deliverMessage($composeMessage, $draft=false) {
                 $smtpServerAddress, $smtpPort, $user, $pass, $authPop);
     } elseif (!$draft) {
         require_once(SM_PATH . 'class/deliver/Deliver_SendMail.class.php');
-        global $sendmail_path;
-        $deliver = new Deliver_SendMail();
+        global $sendmail_path, $sendmail_args;
+        $deliver = new Deliver_SendMail(array('sendmail_args'=>$sendmail_args));
         $stream = $deliver->initStream($composeMessage,$sendmail_path);
     } elseif ($draft) {
         global $draft_folder;
@@ -1628,7 +1628,7 @@ function deliverMessage($composeMessage, $draft=false) {
             $composeMessage->purgeAttachments();
             return $length;
         } else {
-            $msg  = '<br />'.sprintf(_("Error: Draft folder %s does not exist."), $draft_folder);
+            $msg  = '<br />'.sprintf(_("Error: Draft folder %s does not exist."), htmlspecialchars($draft_folder));
             plain_error_message($msg, $color);
             return false;
         }
@@ -1639,6 +1639,7 @@ function deliverMessage($composeMessage, $draft=false) {
         $success = $deliver->finalizeStream($stream);
     }
     if (!$success) {
+        // $deliver->dlv_server_msg is not always server's reply
         $msg  = $deliver->dlv_msg . '<br />' .
             _("Server replied:") . ' ' . $deliver->dlv_ret_nr . ' ' .
             $deliver->dlv_server_msg;