summaryrefslogtreecommitdiffstats
path: root/system/libraries/Email.php
diff options
context:
space:
mode:
authorPetr Heralecky <petr@heralecky.cz>2014-01-10 15:21:18 +0100
committerPetr Heralecky <petr@heralecky.cz>2014-01-10 15:21:18 +0100
commit232ea658e1f31d6c82a9ed9dae1bb3b292b6eb24 (patch)
treeb43af407a839f641aec241573f6c7f7823e8588a /system/libraries/Email.php
parentc809726558cc5364713e49c7404e43989203c4af (diff)
attach files by absolute url
Diffstat (limited to 'system/libraries/Email.php')
-rw-r--r--system/libraries/Email.php20
1 files changed, 10 insertions, 10 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 739b76ccb..71edc3b41 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 $src can be 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($src, $disposition = '', $newname = NULL, $mime = '')
{
if ($mime === '')
{
- if ( ! file_exists($filename))
+ if (strpos($src,'http://')!==0 && ! file_exists($src) )
{
- $this->_set_error_message('lang:email_attachment_missing', $filename);
+ $this->_set_error_message('lang:email_attachment_missing', $src);
return FALSE;
}
- if ( ! $fp = fopen($filename, FOPEN_READ))
+ if ( ! $fp = @fopen($src, FOPEN_READ))
{
- $this->_set_error_message('lang:email_attachment_unreadable', $filename);
+ $this->_set_error_message('lang:email_attachment_unreadable', $src);
return FALSE;
}
-
+
$file_content = stream_get_contents($fp);
- $mime = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION));
+ $mime = $this->_mime_types(pathinfo($src, PATHINFO_EXTENSION));
fclose($fp);
}
else
{
- $file_content =& $filename; // buffered file
+ $file_content =& $src; // buffered file
}
$this->_attachments[] = array(
- 'name' => array($filename, $newname),
+ 'name' => array($src, $newname),
'disposition' => empty($disposition) ? 'attachment' : $disposition, // Can also be 'inline' Not sure if it matters
'type' => $mime,
'content' => chunk_split(base64_encode($file_content))