summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/libraries/Email.php10
-rw-r--r--user_guide_src/source/libraries/email.rst20
2 files changed, 15 insertions, 15 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 7320ea566..7429035f8 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -83,7 +83,6 @@ class CI_Email {
protected $_attach_name = array();
protected $_attach_type = array();
protected $_attach_disp = array();
- protected $_attach_content = 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');
@@ -172,7 +171,6 @@ class CI_Email {
$this->_attach_name = array();
$this->_attach_type = array();
$this->_attach_disp = array();
- $this->_attach_content = array();
}
return $this;
@@ -408,12 +406,11 @@ class CI_Email {
* @param string
* @return object
*/
- public function attach($filename, $disposition = '', $str = '', $mime = '', $newname = NULL)
+ public function attach($filename, $disposition = '', $newname = NULL, $mime = '')
{
$this->_attach_name[] = array($filename, $newname);
- $this->_attach_type[] = ($mime == '') ? $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)) : $mime;
$this->_attach_disp[] = empty($disposition) ? 'attachment' : $disposition; // Can also be 'inline' Not sure if it matters
- $this->_attach_content[] = $str;
+ $this->_attach_type[] = $mime;
return $this;
}
@@ -1053,7 +1050,7 @@ class CI_Email {
$ctype = $this->_attach_type[$i];
$file_content = '';
- if ($this->_attach_content[$i] === '')
+ if ($this->_attach_type[$i] == '')
{
if ( ! file_exists($filename))
{
@@ -1069,6 +1066,7 @@ class CI_Email {
return FALSE;
}
+ $ctype = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION));
$file_content = fread($fp, $file);
fclose($fp);
}
diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst
index 2be50fd35..19c2706d9 100644
--- a/user_guide_src/source/libraries/email.rst
+++ b/user_guide_src/source/libraries/email.rst
@@ -228,18 +228,20 @@ use the function multiple times. For example::
$this->email->attach('/path/to/photo2.jpg');
$this->email->attach('/path/to/photo3.jpg');
-To use the default disposition (attachment), leave the second parameter blank.
-If you need to use a buffer string instead of a real (physical) file you can use the
-third and fourth parameters that are respectively the buffer and the mime-type::
+To use the default disposition (attachment), leave the second parameter blank,
+otherwise use a custom disposition::
- $this->email->attach('report.pdf', 'inline', $buffer, 'application/pdf');
+ $this->email->attach('image.jpg', 'inline');
-If you'd like to add a custom file name, you can use the fifth paramaters.
-Here's an example::
-
- $this->email->attach('/path/to/photo1.jpg', '', '', '', 'inline');
- $this->email->attach('/path/to/photo1.jpg', '', '', '', 'birthday.jpg');
+If you'd like to use a custom file name, you can use the third paramater::
+ $this->email->attach('filename.pdf', 'attachment', 'report.pdf');
+
+If you need to use a buffer string instead of a real - physical - file you can
+use the first parameter as buffer, the third parameter as file name and the fourth
+parameter as mime-type::
+
+ $this->email->attach($buffer, 'attachment', 'report.pdf', 'application/pdf');
$this->email->print_debugger()
-------------------------------