Commits

Anonymous committed 232414a

bugfix multiple attachments + easier implementation of attachment by file pointer

  • Participants
  • Parent commits 9e391d1

Comments (0)

Files changed (1)

system/libraries/Email.php

 	var	$_attach_name	= array();
 	var	$_attach_type	= array();
 	var	$_attach_disp	= array();
-	var	$_attach_fp  	= array();
+	var	$_attach_fp		= array();
 	var	$_protocols		= array('mail', 'sendmail', 'smtp');
 	var	$_base_charsets	= array('us-ascii', 'iso-2022-');	// 7-bit charsets (excluding language suffix)
 	var	$_bit_depths	= array('7bit', '8bit');
 			$this->_attach_name = array();
 			$this->_attach_type = array();
 			$this->_attach_disp = array();
-			$this->_attach_fp   = array();
+			$this->_attach_fp = array();
 		}
 
 		return $this;
 		$this->_attach_name[] = $filename;
 		$this->_attach_type[] = $this->_mime_types(next(explode('.', basename($filename))));
 		$this->_attach_disp[] = $disposition; // Can also be 'inline'  Not sure if it matters
-		$this->_attach_fp[]   = $fp; // a file pointer in read only mode
+		$this->_attach_fp[] = $fp; // a file pointer in read only mode
 		return $this;
 	}
 
 			$filename = $this->_attach_name[$i];
 			$basename = basename($filename);
 			$ctype = $this->_attach_type[$i];
-			$fp    = $this->_attach_fp[$i];
+			$fp = $this->_attach_fp[$i];
 
 			if ( is_null($fp) && ! file_exists($filename))
 			{
 				return FALSE;
 			}
 
-      $chunklen = 76;
-      $end = "\r\n";
+			$str = '';
+			while (!feof($fp))
+			{
+				$str .= fread($fp, 32768);
+			}
 
-      $z++;
-      $attachment[$z] = '';
-      while (!feof($fp))
-      {
-        $attachment[$z] .= base64_encode(fread($fp, $chunklen)) . $end;
-      }
+			$attachment[$z++] = chunk_split(base64_encode($str));
 			fclose($fp);
+			unset($str);
 		}
 
 		$body .= implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";