Merge pull request #2815 from fredemmott/fix-hhvm

Don't throw in mock autoloader
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 739b76c..7e80ffb 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -710,39 +710,39 @@
 	/**
 	 * Assign file attachments
 	 *
-	 * @param	string	$filename
+	 * @param	string	$file	Can be local path, URL or buffered content
 	 * @param	string	$disposition = 'attachment'
 	 * @param	string	$newname = NULL
 	 * @param	string	$mime = ''
 	 * @return	CI_Email
 	 */
-	public function attach($filename, $disposition = '', $newname = NULL, $mime = '')
+	public function attach($file, $disposition = '', $newname = NULL, $mime = '')
 	{
 		if ($mime === '')
 		{
-			if ( ! file_exists($filename))
+			if (strpos($file, '://') === FALSE && ! file_exists($file))
 			{
-				$this->_set_error_message('lang:email_attachment_missing', $filename);
+				$this->_set_error_message('lang:email_attachment_missing', $file);
 				return FALSE;
 			}
 
-			if ( ! $fp = fopen($filename, FOPEN_READ))
+			if ( ! $fp = @fopen($file, FOPEN_READ))
 			{
-				$this->_set_error_message('lang:email_attachment_unreadable', $filename);
+				$this->_set_error_message('lang:email_attachment_unreadable', $file);
 				return FALSE;
 			}
 
 			$file_content = stream_get_contents($fp);
-			$mime = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION));
+			$mime = $this->_mime_types(pathinfo($file, PATHINFO_EXTENSION));
 			fclose($fp);
 		}
 		else
 		{
-			$file_content =& $filename; // buffered file
+			$file_content =& $file; // buffered file
 		}
 
 		$this->_attachments[] = array(
-			'name'		=> array($filename, $newname),
+			'name'		=> array($file, $newname),
 			'disposition'	=> empty($disposition) ? 'attachment' : $disposition,  // Can also be 'inline'  Not sure if it matters
 			'type'		=> $mime,
 			'content'	=> chunk_split(base64_encode($file_content))
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 5da7070..43e7be4 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -334,6 +334,7 @@
 
       -  Added a custom filename parameter to ``attach()`` as ``$this->email->attach($filename, $disposition, $newname)``.
       -  Added possibility to send attachment as buffer string in ``attach()`` as ``$this->email->attach($buffer, $disposition, $newname, $mime)``.
+      -  Added possibility to attach remote files by passing a URL.
       -  Added method ``attachment_cid()`` to enable embedding inline attachments into HTML.
       -  Added dsn (delivery status notification) option.
       -  Renamed method ``_set_header()`` to ``set_header()`` and made it public to enable adding custom headers.
diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst
index 8e38003..86f440a 100644
--- a/user_guide_src/source/libraries/email.rst
+++ b/user_guide_src/source/libraries/email.rst
@@ -259,6 +259,10 @@
 
 	$this->email->attach('image.jpg', 'inline');
 
+You can use URL::
+
+	$this->email->attach('http://example.com/filename.pdf');
+
 If you'd like to use a custom file name, you can use the third paramater::
 
 	$this->email->attach('filename.pdf', 'attachment', 'report.pdf');