From 9284452553108fbc4182305857b86901d402fe4b Mon Sep 17 00:00:00 2001
From: Klaus Leithoff <kl@stylite.de>
Date: Tue, 20 Apr 2010 10:02:36 +0000
Subject: [PATCH] original EncodeFile uses is_readable. this fails with files
 stored in vfs in webusers context. use fopen instead, as old function
 (version 2.1) did

---
 phpgwapi/inc/class.phpmailer.inc.php | 46 +++++++++++++++-------------
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/phpgwapi/inc/class.phpmailer.inc.php b/phpgwapi/inc/class.phpmailer.inc.php
index 141cc1393c..2a7399d8dd 100644
--- a/phpgwapi/inc/class.phpmailer.inc.php
+++ b/phpgwapi/inc/class.phpmailer.inc.php
@@ -1491,27 +1491,31 @@ class PHPMailer {
    * @return string
    */
   private function EncodeFile($path, $encoding = 'base64') {
-    try {
-      if (!is_readable($path)) {
-        throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
-      }
-      if (function_exists('get_magic_quotes')) {
-        function get_magic_quotes() {
-          return false;
-        }
-      }
-      if (PHP_VERSION < 6) {
-        $magic_quotes = get_magic_quotes_runtime();
-        set_magic_quotes_runtime(0);
-      }
-      $file_buffer  = file_get_contents($path);
-      $file_buffer  = $this->EncodeString($file_buffer, $encoding);
-      if (PHP_VERSION < 6) { set_magic_quotes_runtime($magic_quotes); }
-      return $file_buffer;
-    } catch (Exception $e) {
-      $this->SetError($e->getMessage());
-      return '';
-    }
+	try {
+		if (!@$fd = fopen($path,'rb')) {
+			throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
+		}
+		if (function_exists('get_magic_quotes')) {
+			function get_magic_quotes() {
+				return false;
+			}
+		}
+		if (PHP_VERSION < 6) {
+			$magic_quotes = get_magic_quotes_runtime();
+			set_magic_quotes_runtime(0);
+		}
+		$file_buffer  = file_get_contents($path);
+		fclose($fd);
+		$file_buffer  = $this->EncodeString($file_buffer, $encoding);
+		if (PHP_VERSION < 6) 
+		{
+			set_magic_quotes_runtime($magic_quotes);
+		}
+		return $file_buffer;
+	} catch (Exception $e) {
+		$this->SetError($e->getMessage());
+		return '';
+	}
   }
 
   /**