forgot table tag
[squirrelmail.git] / functions / smtp.php
index f1837c8b949a2c487876ead84f1600d197cf3a7d..830b14ec36e393b2c557df6ae960e386dada297b 100644 (file)
@@ -12,9 +12,9 @@
  * $Id$
  */
 
-require_once('../functions/addressbook.php');
-require_once('../functions/plugin.php');
-require_once('../functions/prefs.php');
+require_once(SM_PATH . 'functions/addressbook.php');
+require_once(SM_PATH . 'functions/plugin.php');
+require_once(SM_PATH . 'functions/prefs.php');
 
 global $username, $popuser, $domain;
 
@@ -193,8 +193,8 @@ function attachFiles ($fp, $session, $rn="\r\n", $checkdot = false) {
                     if (substr($tmp, $tmp_length - strlen($rn), strlen($rn)) != $rn) {
                         if ($fp) {
                             fputs($fp, $rn);
-                           $length += strlen($rn);
                         }
+                       $length += strlen($rn);
                     }
 
 
@@ -279,14 +279,28 @@ function timezone () {
 
 /* Print all the needed RFC822 headers */
 function write822Header ($fp, $t, $c, $b, $subject, $body, $more_headers, $session, $rn="\r\n") {
-    global $REMOTE_ADDR, $SERVER_NAME, $REMOTE_PORT;
-    global $data_dir, $username, $popuser, $domain, $version, $useSendmail;
-    global $default_charset, $HTTP_VIA, $HTTP_X_FORWARDED_FOR;
-    global $REMOTE_HOST, $identity;
+    global $data_dir, $username, $popuser, $domain, $version, $useSendmail,
+        $default_charset, $identity, $_SERVER;
 
     /* Storing the header to make sure the header is the same
      * everytime the header is printed.
      */
+
+    /* get those globals */
+    $REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
+    $SERVER_NAME = $_SERVER['SERVER_NAME'];
+    $REMOTE_PORT = $_SERVER['REMOTE_PORT'];
+
+    if(isset($_SERVER['REMOTE_HOST'])) {
+        $REMOTE_HOST = $_SERVER['REMOTE_HOST'];
+    }
+    if(isset($_SERVER['HTTP_VIA'])) {
+        $HTTP_VIA = $_SERVER['HTTP_VIA'];
+    }
+    if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+        $HTTP_X_FORWARDED_FOR = $_SERVER['HTTP_X_FORWARDED_FOR'];
+    }
+
     static $header, $headerlength, $headerrn;
     
     if ($header == '') {
@@ -787,14 +801,14 @@ function errorCheck($line, $smtpConnection, $verbose = false) {
     }
 
     if ($status == 0) {
-        include_once('../functions/page_header.php');
+        include_once(SM_PATH . 'functions/page_header.php');
         if ($compose_new_win == '1') {
             compose_Header($color, 'None');
         }
         else {
             displayPageHeader($color, 'None');
         }
-        include_once('../functions/display_messages.php');
+        include_once(SM_PATH . 'functions/display_messages.php');
         $lines = nl2br(htmlspecialchars($lines));
         $msg  = $message . "<br>\nServer replied: $lines";
         plain_error_message($msg, $color);
@@ -960,17 +974,16 @@ function createPriorityHeaders($prio) {
     $prio_headers['X-Priority'] = $prio;
 
     switch($prio) {
-    case 1: $prio_headers['Importance'] = 'High';
-        $prio_headers['X-MSMail-Priority'] = 'High';
+    case 1: 
+        $prio_headers['Importance'] = 'High';
         break;
 
-    case 3: $prio_headers['Importance'] = 'Normal';
-        $prio_headers['X-MSMail-Priority'] = 'Normal';
+    case 3: 
+        $prio_headers['Importance'] = 'Normal';
         break;
 
     case 5:
         $prio_headers['Importance'] = 'Low';
-        $prio_headers['X-MSMail-Priority'] = 'Low';
         break;
     }
     return  $prio_headers;