diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-05-02 12:27:30 +0200 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-05-02 12:27:30 +0200 |
commit | 14aa3178e12f285bed006511902e50aaae69bada (patch) | |
tree | a33410e21a5de095070fc5cc6d14b2649954e0a7 /system/libraries/Email.php | |
parent | 3ea6b1fd8fb0492d84c4879e039d11713c9f39a5 (diff) | |
parent | 963c96c5507ceb8b5c3de50d0ab959d21dcc8cd1 (diff) |
Merge upstream branch
Diffstat (limited to 'system/libraries/Email.php')
-rw-r--r-- | system/libraries/Email.php | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 8f383c939..103c3cb25 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -407,11 +407,11 @@ class CI_Email { * @param string * @return object */ - public function attach($filename, $disposition = '', $newname = NULL) + public function attach($filename, $disposition = '', $newname = NULL, $mime = '') { $this->_attach_name[] = array($filename, $newname); - $this->_attach_type[] = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)); $this->_attach_disp[] = empty($disposition) ? 'attachment' : $disposition; // Can also be 'inline' Not sure if it matters + $this->_attach_type[] = $mime; return $this; } @@ -1049,29 +1049,39 @@ class CI_Email { $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]; + $file_content = ''; - if ( ! file_exists($filename)) + if ($this->_attach_type[$i] == '') { - $this->_set_error_message('lang:email_attachment_missing', $filename); - return FALSE; - } + if ( ! file_exists($filename)) + { + $this->_set_error_message('lang:email_attachment_missing', $filename); + return FALSE; + } + + $file = filesize($filename) +1; + if ( ! $fp = fopen($filename, FOPEN_READ)) + { + $this->_set_error_message('lang:email_attachment_unreadable', $filename); + return FALSE; + } + + $ctype = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)); + $file_content = fread($fp, $file); + fclose($fp); + } + else + { + $file_content =& $this->_attach_content[$i]; + } $attachment[$z++] = "--".$this->_atc_boundary.$this->newline . "Content-type: ".$ctype."; " . "name=\"".$basename."\"".$this->newline . "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline . "Content-Transfer-Encoding: base64".$this->newline; - $file = filesize($filename) +1; - - if ( ! $fp = fopen($filename, FOPEN_READ)) - { - $this->_set_error_message('lang:email_attachment_unreadable', $filename); - return FALSE; - } - - $attachment[$z++] = chunk_split(base64_encode(fread($fp, $file))); - fclose($fp); + $attachment[$z++] = chunk_split(base64_encode($file_content)); } $body .= implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--"; @@ -1881,6 +1891,7 @@ class CI_Email { 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'css' => 'text/css', + 'ics' => 'text/calendar', 'html' => 'text/html', 'htm' => 'text/html', 'shtml' => 'text/html', |