Unify Email attachment values into a single array and fix a bug in the new buffer attachment feature
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 83b442f..9207fc9 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -81,9 +81,7 @@
 	protected $_cc_array		= array();
 	protected $_bcc_array		= array();
 	protected $_headers		= array();
-	protected $_attach_name		= array();
-	protected $_attach_type		= array();
-	protected $_attach_disp		= array();
+	protected $_attachments		= array();
 	protected $_protocols		= array('mail', 'sendmail', 'smtp');
 	protected $_base_charsets	= array('us-ascii', 'iso-2022-');	// 7-bit charsets (excluding language suffix)
 	protected $_bit_depths		= array('7bit', '8bit');
@@ -176,9 +174,7 @@
 
 		if ($clear_attachments !== FALSE)
 		{
-			$this->_attach_name = array();
-			$this->_attach_type = array();
-			$this->_attach_disp = array();
+			$this->_attachments = array();
 		}
 
 		return $this;
@@ -415,9 +411,12 @@
 	 */
 	public function attach($filename, $disposition = '', $newname = NULL, $mime = '')
 	{
-		$this->_attach_name[] = array($filename, $newname);
-		$this->_attach_disp[] = empty($disposition) ? 'attachment' : $disposition; // Can also be 'inline'  Not sure if it matters
-		$this->_attach_type[] = $mime;
+		$this->_attachments[] = array(
+			'name'		=> array($filename, $newname),
+			'disposition'	=> empty($disposition) ? 'attachment' : $disposition,  // Can also be 'inline'  Not sure if it matters
+			'type' 		=> $mime
+		);
+
 		return $this;
 	}
 
@@ -635,9 +634,9 @@
 	{
 		if ($this->mailtype === 'html')
 		{
-			return (count($this->_attach_name) === 0) ? 'html' : 'html-attach';
+			return (count($this->_attachments) === 0) ? 'html' : 'html-attach';
 		}
-		elseif	($this->mailtype === 'text' && count($this->_attach_name) > 0)
+		elseif	($this->mailtype === 'text' && count($this->_attachments) > 0)
 		{
 			return 'plain-attach';
 		}
@@ -1045,14 +1044,15 @@
 		}
 
 		$attachment = array();
-		for ($i = 0, $c = count($this->_attach_name), $z = 0; $i < $c; $i++)
+		for ($i = 0, $c = count($this->_attachments), $z = 0; $i < $c; $i++)
 		{
-			$filename = $this->_attach_name[$i][0];
-			$basename = is_null($this->_attach_name[$i][1]) ? basename($filename) : $this->_attach_name[$i][1];
-			$ctype = $this->_attach_type[$i];
+			$filename = $this->_attachments[$i]['name'][0];
+			$basename = is_null($this->_attachments[$i]['name'][1])
+				? basename($filename) : $this->_attachments[$i]['name'][1];
+			$ctype = $this->_attachments[$i]['type'];
 			$file_content = '';
 
-			if ($this->_attach_type[$i] === '')
+			if ($ctype === '')
 			{
 				if ( ! file_exists($filename))
 				{
@@ -1074,13 +1074,13 @@
 			}
 			else
 			{
-				$file_content =& $this->_attach_content[$i];
+				$file_content =& $this->_attachments[$i]['name'][0];
 			}
 
 			$attachment[$z++] = '--'.$this->_atc_boundary.$this->newline
 				.'Content-type: '.$ctype.'; '
 				.'name="'.$basename.'"'.$this->newline
-				.'Content-Disposition: '.$this->_attach_disp[$i].';'.$this->newline
+				.'Content-Disposition: '.$this->_attachments[$i]['disposition'].';'.$this->newline
 				.'Content-Transfer-Encoding: base64'.$this->newline;
 
 			$attachment[$z++] = chunk_split(base64_encode($file_content));