summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-01-12 15:06:14 +0100
committerAndrey Andreev <narf@devilix.net>2014-01-12 15:06:14 +0100
commit3559af1723920007598e5dd44abbb9f581879a36 (patch)
tree9214e69b82b642b2d8d2df8757767a6434e50f9e /system/libraries
parent4e6c5281a3258b3ff530a43580d1b8dc8e34dd59 (diff)
parent1dbdf72c555d0ea4d7c526e56e79472331eedc2a (diff)
Merge pull request #2808 from melounek/filename_as_url
attach files by absolute url
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Email.php18
1 files changed, 9 insertions, 9 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 739b76ccb..7e80ffbca 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -710,39 +710,39 @@ class CI_Email {
/**
* 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))