Now setting charset also in headers when sending mail.
authorgustavf <gustavf@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 2 Apr 2000 17:58:53 +0000 (17:58 +0000)
committergustavf <gustavf@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 2 Apr 2000 17:58:53 +0000 (17:58 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@377 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/mime.php
functions/smtp.php

index ecbc6abcf217047c0cfd5e3986afa34e64b77222..ac0ad3061933a35323ca753882699a955e9742e5 100644 (file)
          return ($string);
    }
 
          return ($string);
    }
 
+   // Encode a string according to RFC 1522 for use in headers if it
+   // contains 8-bit characters
+   function encodeHeader ($string) {
+      global $default_charset;
+
+      // Encode only if the string contains 8-bit characters
+      if (ereg("[\200-\377]", $string)) {
+         $newstring = "=?$default_charset?Q?";
+         $newstring .= str_replace(" ", "_", $string);
+         
+         while (ereg("([\200-\377])", $newstring, $regs)) {
+            $replace = $regs[1];
+            $insert = "=" . bin2hex($replace);
+            $newstring = str_replace($replace, $insert, $newstring);
+         }
+
+         $newstring .= "?=";
+
+         return $newstring;
+      }
+
+      return $string;
+   }
+
 ?>
 ?>
index 04e92bf0e050717688167f3e7977c327fcfbc0f0..24570bec4b18aecbfea899dd34ec1e44e8ace9f1 100644 (file)
             $from = "<$from_addr>";
          else
             $from = $from . " <$from_addr>";
             $from = "<$from_addr>";
          else
             $from = $from . " <$from_addr>";
+
+         /* Encoding 8-bit characters */
+         $subject = encodeHeader($subject);
+         $from = encodeHeader($from);
          
          /* This creates an RFC 822 date */
          $date = date("D, j M Y H:i:s ", mktime()) . timezone();
          
          /* This creates an RFC 822 date */
          $date = date("D, j M Y H:i:s ", mktime()) . timezone();