From 50814099c41321e74b7aa7a451f23890fa7d20a1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 12:36:12 +0200 Subject: Switch private properties in the Email class to protected --- system/libraries/Email.php | 49 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 922107e9f..027ec0adb 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -64,30 +64,31 @@ class CI_Email { public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo. public $bcc_batch_mode = FALSE; // TRUE/FALSE Turns on/off Bcc batch feature public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch - private $_safe_mode = FALSE; - private $_subject = ""; - private $_body = ""; - private $_finalbody = ""; - private $_alt_boundary = ""; - private $_atc_boundary = ""; - private $_header_str = ""; - private $_smtp_connect = ""; - private $_encoding = "8bit"; - private $_IP = FALSE; - private $_smtp_auth = FALSE; - private $_replyto_flag = FALSE; - private $_debug_msg = array(); - private $_recipients = array(); - private $_cc_array = array(); - private $_bcc_array = array(); - private $_headers = array(); - private $_attach_name = array(); - private $_attach_type = array(); - private $_attach_disp = array(); - private $_protocols = array('mail', 'sendmail', 'smtp'); - private $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix) - private $_bit_depths = array('7bit', '8bit'); - private $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)'); + + protected $_safe_mode = FALSE; + protected $_subject = ''; + protected $_body = ''; + protected $_finalbody = ''; + protected $_alt_boundary = ''; + protected $_atc_boundary = ''; + protected $_header_str = ''; + protected $_smtp_connect = ''; + protected $_encoding = '8bit'; + protected $_IP = FALSE; + protected $_smtp_auth = FALSE; + protected $_replyto_flag = FALSE; + protected $_debug_msg = array(); + protected $_recipients = array(); + protected $_cc_array = array(); + protected $_bcc_array = array(); + protected $_headers = array(); + protected $_attach_name = array(); + protected $_attach_type = array(); + protected $_attach_disp = 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'); + protected $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)'); /** -- cgit v1.2.3-24-g4f1b From 081c946bf049a013aaeab4dc726cdbbe20473eb2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 12:58:11 +0200 Subject: Remove access lines and fix method description blocks in the Email class --- system/libraries/Email.php | 109 +++++++++++---------------------------------- 1 file changed, 25 insertions(+), 84 deletions(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 027ec0adb..898effeb6 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Email Class * @@ -90,7 +88,6 @@ class CI_Email { protected $_bit_depths = array('7bit', '8bit'); protected $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)'); - /** * Constructor - Sets Email Preferences * @@ -116,7 +113,6 @@ class CI_Email { /** * Initialize preferences * - * @access public * @param array * @return void */ @@ -151,9 +147,8 @@ class CI_Email { /** * Initialize the Email Data * - * @access public * @param bool - * @return void + * @return object */ public function clear($clear_attachments = FALSE) { @@ -186,10 +181,9 @@ class CI_Email { /** * Set FROM * - * @access public * @param string * @param string - * @return void + * @return object */ public function from($from, $name = '') { @@ -229,10 +223,9 @@ class CI_Email { /** * Set Reply-to * - * @access public * @param string * @param string - * @return void + * @return object */ public function reply_to($replyto, $name = '') { @@ -267,9 +260,8 @@ class CI_Email { /** * Set Recipients * - * @access public * @param string - * @return void + * @return object */ public function to($to) { @@ -305,9 +297,8 @@ class CI_Email { /** * Set CC * - * @access public * @param string - * @return void + * @return object */ public function cc($cc) { @@ -334,10 +325,9 @@ class CI_Email { /** * Set BCC * - * @access public * @param string * @param string - * @return void + * @return object */ public function bcc($bcc, $limit = '') { @@ -372,9 +362,8 @@ class CI_Email { /** * Set Email Subject * - * @access public * @param string - * @return void + * @return object */ public function subject($subject) { @@ -388,9 +377,8 @@ class CI_Email { /** * Set Body * - * @access public * @param string - * @return void + * @return object */ public function message($body) { @@ -415,9 +403,8 @@ class CI_Email { /** * Assign file attachments * - * @access public * @param string - * @return void + * @return object */ public function attach($filename, $disposition = '', $newname = NULL) { @@ -432,7 +419,6 @@ class CI_Email { /** * Add a Header Item * - * @access protected * @param string * @param string * @return void @@ -447,7 +433,6 @@ class CI_Email { /** * Convert a String to an Array * - * @access protected * @param string * @return array */ @@ -473,9 +458,8 @@ class CI_Email { /** * Set Multipart Value * - * @access public * @param string - * @return void + * @return object */ public function set_alt_message($str = '') { @@ -488,9 +472,8 @@ class CI_Email { /** * Set Mailtype * - * @access public * @param string - * @return void + * @return object */ public function set_mailtype($type = 'text') { @@ -503,9 +486,8 @@ class CI_Email { /** * Set Wordwrap * - * @access public * @param bool - * @return void + * @return object */ public function set_wordwrap($wordwrap = TRUE) { @@ -518,9 +500,8 @@ class CI_Email { /** * Set Protocol * - * @access public * @param string - * @return void + * @return object */ public function set_protocol($protocol = 'mail') { @@ -533,9 +514,8 @@ class CI_Email { /** * Set Priority * - * @access public - * @param integer - * @return void + * @param int + * @return object */ public function set_priority($n = 3) { @@ -554,9 +534,8 @@ class CI_Email { /** * Set Newline Character * - * @access public * @param string - * @return void + * @return object */ public function set_newline($newline = "\n") { @@ -569,9 +548,8 @@ class CI_Email { /** * Set CRLF * - * @access public * @param string - * @return void + * @return object */ public function set_crlf($crlf = "\n") { @@ -584,7 +562,6 @@ class CI_Email { /** * Set Message Boundary * - * @access protected * @return void */ protected function _set_boundaries() @@ -598,7 +575,6 @@ class CI_Email { /** * Get the Message ID * - * @access protected * @return string */ protected function _get_message_id() @@ -613,7 +589,6 @@ class CI_Email { /** * Get Mail Protocol * - * @access protected * @param bool * @return string */ @@ -633,7 +608,6 @@ class CI_Email { /** * Get Mail Encoding * - * @access protected * @param bool * @return string */ @@ -660,7 +634,6 @@ class CI_Email { /** * Get content type (text/html/attachment) * - * @access protected * @return string */ protected function _get_content_type() @@ -688,7 +661,6 @@ class CI_Email { /** * Set RFC 822 Date * - * @access protected * @return string */ protected function _set_date() @@ -706,7 +678,6 @@ class CI_Email { /** * Mime message * - * @access protected * @return string */ protected function _get_mime_message() @@ -719,7 +690,6 @@ class CI_Email { /** * Validate Email Address * - * @access public * @param string * @return bool */ @@ -748,7 +718,6 @@ class CI_Email { /** * Email Validation * - * @access public * @param string * @return bool */ @@ -762,7 +731,6 @@ class CI_Email { /** * Clean Extended Email Address: Joe Smith * - * @access public * @param string * @return string */ @@ -793,7 +761,6 @@ class CI_Email { * If the user hasn't specified his own alternative message * it creates one by stripping the HTML * - * @access protected * @return string */ protected function _get_alt_message() @@ -819,9 +786,8 @@ class CI_Email { /** * Word Wrap * - * @access public * @param string - * @param integer + * @param int * @return string */ public function word_wrap($str, $charlim = '') @@ -912,8 +878,6 @@ class CI_Email { /** * Build final headers * - * @access protected - * @param string * @return string */ protected function _build_headers() @@ -930,7 +894,6 @@ class CI_Email { /** * Write Headers as a string * - * @access protected * @return void */ protected function _write_headers() @@ -965,7 +928,6 @@ class CI_Email { /** * Build Final Body and attachments * - * @access protected * @return void */ protected function _build_message() @@ -1132,9 +1094,8 @@ class CI_Email { * Prepares string for Quoted-Printable Content-Transfer-Encoding * Refer to RFC 2045 http://www.ietf.org/rfc/rfc2045.txt * - * @access protected * @param string - * @param integer + * @param int * @return string */ protected function _prep_quoted_printable($str, $charlim = '') @@ -1217,10 +1178,9 @@ class CI_Email { * Performs "Q Encoding" on a string for use in email headers. It's related * but not identical to quoted-printable, so it has its own method * - * @access public - * @param str - * @param bool // set to TRUE for processing From: headers - * @return str + * @param string + * @param bool set to TRUE for processing From: headers + * @return string */ protected function _prep_q_encoding($str, $from = FALSE) { @@ -1286,7 +1246,6 @@ class CI_Email { /** * Send Email * - * @access public * @return bool */ public function send() @@ -1319,10 +1278,9 @@ class CI_Email { // -------------------------------------------------------------------- /** - * Batch Bcc Send. Sends groups of BCCs in batches + * Batch Bcc Send. Sends groups of BCCs in batches * - * @access public - * @return bool + * @return void */ public function batch_bcc_send() { @@ -1377,7 +1335,6 @@ class CI_Email { /** * Unwrap special elements * - * @access protected * @return void */ protected function _unwrap_specials() @@ -1390,7 +1347,6 @@ class CI_Email { /** * Strip line-breaks via callback * - * @access protected * @return string */ protected function _remove_nl_callback($matches) @@ -1408,7 +1364,6 @@ class CI_Email { /** * Spool mail to the mail server * - * @access protected * @return bool */ protected function _spool_email() @@ -1430,7 +1385,6 @@ class CI_Email { /** * Send using mail() * - * @access protected * @return bool */ protected function _send_with_mail() @@ -1452,7 +1406,6 @@ class CI_Email { /** * Send using Sendmail * - * @access protected * @return bool */ protected function _send_with_sendmail() @@ -1485,7 +1438,6 @@ class CI_Email { /** * Send using SMTP * - * @access protected * @return bool */ protected function _send_with_smtp() @@ -1554,7 +1506,6 @@ class CI_Email { /** * SMTP Connect * - * @access protected * @param string * @return string */ @@ -1598,7 +1549,6 @@ class CI_Email { /** * Send SMTP command * - * @access protected * @param string * @param string * @return string @@ -1671,7 +1621,6 @@ class CI_Email { /** * SMTP Authenticate * - * @access protected * @return bool */ protected function _smtp_authenticate() @@ -1725,7 +1674,6 @@ class CI_Email { /** * Send SMTP data * - * @access protected * @return bool */ protected function _send_data($data) @@ -1744,7 +1692,6 @@ class CI_Email { /** * Get SMTP data * - * @access protected * @return string */ protected function _get_smtp_data() @@ -1769,7 +1716,6 @@ class CI_Email { /** * Get Hostname * - * @access protected * @return string */ protected function _get_hostname() @@ -1782,7 +1728,6 @@ class CI_Email { /** * Get IP * - * @access protected * @return string */ protected function _get_ip() @@ -1824,7 +1769,6 @@ class CI_Email { /** * Get Debug Message * - * @access public * @return string */ public function print_debugger() @@ -1848,9 +1792,8 @@ class CI_Email { /** * Set Message * - * @access protected * @param string - * @return string + * @return void */ protected function _set_error_message($msg, $val = '') { @@ -1872,7 +1815,6 @@ class CI_Email { /** * Mime Types * - * @access protected * @param string * @return string */ @@ -1971,7 +1913,6 @@ class CI_Email { } } -// END CI_Email class /* End of file Email.php */ /* Location: ./system/libraries/Email.php */ -- cgit v1.2.3-24-g4f1b From 76f15c9bb3004e6da99dd273c34ef3b92a23c17f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 13:05:07 +0200 Subject: Switch ANDs to &&, || to OR in the Email class --- system/libraries/Email.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 898effeb6..f1b18ab4f 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -101,7 +101,7 @@ class CI_Email { } else { - $this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE; + $this->_smtp_auth = ! ($this->smtp_user == '' && $this->smtp_pass == ''); $this->_safe_mode = (bool) @ini_get("safe_mode"); } @@ -136,7 +136,7 @@ class CI_Email { } $this->clear(); - $this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE; + $this->_smtp_auth = ! ($this->smtp_user == '' && $this->smtp_pass == ''); $this->_safe_mode = (bool) @ini_get("safe_mode"); return $this; @@ -553,7 +553,7 @@ class CI_Email { */ public function set_crlf($crlf = "\n") { - $this->crlf = ($crlf !== "\n" AND $crlf !== "\r\n" AND $crlf !== "\r") ? "\n" : $crlf; + $this->crlf = ($crlf !== "\n" && $crlf !== "\r\n" && $crlf !== "\r") ? "\n" : $crlf; return $this; } @@ -932,7 +932,7 @@ class CI_Email { */ protected function _build_message() { - if ($this->wordwrap === TRUE AND $this->mailtype !== 'html') + if ($this->wordwrap === TRUE && $this->mailtype !== 'html') { $this->_body = $this->word_wrap($this->_body); } @@ -1255,9 +1255,9 @@ class CI_Email { $this->reply_to($this->_headers['From']); } - if (( ! isset($this->_recipients) AND ! isset($this->_headers['To'])) AND - ( ! isset($this->_bcc_array) AND ! isset($this->_headers['Bcc'])) AND - ( ! isset($this->_headers['Cc']))) + if ( ! isset($this->_recipients) && ! isset($this->_headers['To']) + && ! isset($this->_bcc_array) && ! isset($this->_headers['Bcc']) + && ! isset($this->_headers['Cc'])) { $this->_set_error_message('lang:email_no_recipients'); return FALSE; @@ -1265,13 +1265,12 @@ class CI_Email { $this->_build_headers(); - if ($this->bcc_batch_mode AND count($this->_bcc_array) > $this->bcc_batch_size) + if ($this->bcc_batch_mode && count($this->_bcc_array) > $this->bcc_batch_size) { return $this->batch_bcc_send(); } $this->_build_message(); - return $this->_spool_email(); } @@ -1630,7 +1629,7 @@ class CI_Email { return TRUE; } - if ($this->smtp_user == "" AND $this->smtp_pass == "") + if ($this->smtp_user == '' && $this->smtp_pass == '') { $this->_set_error_message('lang:email_no_smtp_unpw'); return FALSE; @@ -1737,13 +1736,13 @@ class CI_Email { return $this->_IP; } - $cip = (isset($_SERVER['HTTP_CLIENT_IP']) AND $_SERVER['HTTP_CLIENT_IP'] != "") ? $_SERVER['HTTP_CLIENT_IP'] : FALSE; - $rip = (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR'] != "") ? $_SERVER['REMOTE_ADDR'] : FALSE; + $cip = ( ! empty($_SERVER['HTTP_CLIENT_IP'])) ? $_SERVER['HTTP_CLIENT_IP'] : FALSE; + $rip = ( ! empty($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : FALSE; if ($cip) $this->_IP = $cip; elseif ($rip) $this->_IP = $rip; else { - $fip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND $_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE; + $fip = ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE; if ($fip) { $this->_IP = $fip; @@ -1800,7 +1799,7 @@ class CI_Email { $CI =& get_instance(); $CI->lang->load('email'); - if (substr($msg, 0, 5) !== 'lang:' || FALSE === ($line = $CI->lang->line(substr($msg, 5)))) + if (substr($msg, 0, 5) !== 'lang:' OR FALSE === ($line = $CI->lang->line(substr($msg, 5)))) { $this->_debug_msg[] = str_replace('%s', $val, $msg)."
"; } -- cgit v1.2.3-24-g4f1b From 59c5b537cb5880930f9a8d518659c75cd66f41b0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Mar 2012 14:09:51 +0200 Subject: Some other minor improvements to the Email library --- system/libraries/Email.php | 148 ++++++++++++++++++++------------------------- 1 file changed, 67 insertions(+), 81 deletions(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index f1b18ab4f..c8a5b41af 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -38,29 +38,29 @@ */ class CI_Email { - public $useragent = "CodeIgniter"; - public $mailpath = "/usr/sbin/sendmail"; // Sendmail path - public $protocol = "mail"; // mail/sendmail/smtp - public $smtp_host = ""; // SMTP Server. Example: mail.earthlink.net - public $smtp_user = ""; // SMTP Username - public $smtp_pass = ""; // SMTP Password - public $smtp_port = "25"; // SMTP Port - public $smtp_timeout = 5; // SMTP Timeout in seconds - public $smtp_crypto = ""; // SMTP Encryption. Can be null, tls or ssl. - public $wordwrap = TRUE; // TRUE/FALSE Turns word-wrap on/off - public $wrapchars = "76"; // Number of characters to wrap at. - public $mailtype = "text"; // text/html Defines email formatting - public $charset = "utf-8"; // Default char set: iso-8859-1 or us-ascii - public $multipart = "mixed"; // "mixed" (in the body) or "related" (separate) - public $alt_message = ''; // Alternative message for HTML emails - public $validate = FALSE; // TRUE/FALSE. Enables email validation - public $priority = "3"; // Default priority (1 - 5) - public $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822) - public $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers, + public $useragent = 'CodeIgniter'; + public $mailpath = '/usr/sbin/sendmail'; // Sendmail path + public $protocol = 'mail'; // mail/sendmail/smtp + public $smtp_host = ''; // SMTP Server. Example: mail.earthlink.net + public $smtp_user = ''; // SMTP Username + public $smtp_pass = ''; // SMTP Password + public $smtp_port = 25; // SMTP Port + public $smtp_timeout = 5; // SMTP Timeout in seconds + public $smtp_crypto = ''; // SMTP Encryption. Can be null, tls or ssl. + public $wordwrap = TRUE; // TRUE/FALSE Turns word-wrap on/off + public $wrapchars = 76; // Number of characters to wrap at. + public $mailtype = 'text'; // text/html Defines email formatting + public $charset = 'utf-8'; // Default char set: iso-8859-1 or us-ascii + public $multipart = 'mixed'; // "mixed" (in the body) or "related" (separate) + public $alt_message = ''; // Alternative message for HTML emails + public $validate = FALSE; // TRUE/FALSE. Enables email validation + public $priority = 3; // Default priority (1 - 5) + public $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822) + public $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers, // even on the receiving end think they need to muck with CRLFs, so using "\n", while // distasteful, is the only thing that seems to work for all environments. public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo. - public $bcc_batch_mode = FALSE; // TRUE/FALSE Turns on/off Bcc batch feature + public $bcc_batch_mode = FALSE; // TRUE/FALSE - Turns on/off Bcc batch feature public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch protected $_safe_mode = FALSE; @@ -102,10 +102,10 @@ class CI_Email { else { $this->_smtp_auth = ! ($this->smtp_user == '' && $this->smtp_pass == ''); - $this->_safe_mode = (bool) @ini_get("safe_mode"); + $this->_safe_mode = (bool) @ini_get('safe_mode'); } - log_message('debug', "Email Class Initialized"); + log_message('debug', 'Email Class Initialized'); } // -------------------------------------------------------------------- @@ -137,7 +137,7 @@ class CI_Email { $this->clear(); $this->_smtp_auth = ! ($this->smtp_user == '' && $this->smtp_pass == ''); - $this->_safe_mode = (bool) @ini_get("safe_mode"); + $this->_safe_mode = (bool) @ini_get('safe_mode'); return $this; } @@ -152,11 +152,11 @@ class CI_Email { */ public function clear($clear_attachments = FALSE) { - $this->_subject = ""; - $this->_body = ""; - $this->_finalbody = ""; - $this->_header_str = ""; - $this->_replyto_flag = FALSE; + $this->_subject = ''; + $this->_body = ''; + $this->_finalbody = ''; + $this->_header_str = ''; + $this->_replyto_flag = FALSE; $this->_recipients = array(); $this->_cc_array = array(); $this->_bcc_array = array(); @@ -187,7 +187,7 @@ class CI_Email { */ public function from($from, $name = '') { - if (preg_match( '/\<(.*)\>/', $from, $match)) + if (preg_match('/\<(.*)\>/', $from, $match)) { $from = $match[1]; } @@ -229,7 +229,7 @@ class CI_Email { */ public function reply_to($replyto, $name = '') { - if (preg_match( '/\<(.*)\>/', $replyto, $match)) + if (preg_match('/\<(.*)\>/', $replyto, $match)) { $replyto = $match[1]; } @@ -275,17 +275,17 @@ class CI_Email { if ($this->_get_protocol() !== 'mail') { - $this->_set_header('To', implode(", ", $to)); + $this->_set_header('To', implode(', ', $to)); } switch ($this->_get_protocol()) { - case 'smtp' : + case 'smtp': $this->_recipients = $to; break; - case 'sendmail' : - case 'mail' : - $this->_recipients = implode(", ", $to); + case 'sendmail': + case 'mail': + $this->_recipients = implode(', ', $to); break; } @@ -310,7 +310,7 @@ class CI_Email { $this->validate_email($cc); } - $this->_set_header('Cc', implode(", ", $cc)); + $this->_set_header('Cc', implode(', ', $cc)); if ($this->_get_protocol() === 'smtp') { @@ -351,7 +351,7 @@ class CI_Email { } else { - $this->_set_header('Bcc', implode(", ", $bcc)); + $this->_set_header('Bcc', implode(', ', $bcc)); } return $this; @@ -382,7 +382,7 @@ class CI_Email { */ public function message($body) { - $this->_body = rtrim(str_replace("\r", "", $body)); + $this->_body = rtrim(str_replace("\r", '', $body)); /* strip slashes only if magic quotes is ON if we do it with magic quotes OFF, it strips real, user-inputted chars. @@ -446,8 +446,7 @@ class CI_Email { } else { - $email = trim($email); - settype($email, "array"); + $email = (array) trim($email); } } return $email; @@ -505,7 +504,7 @@ class CI_Email { */ public function set_protocol($protocol = 'mail') { - $this->protocol = ( ! in_array($protocol, $this->_protocols, TRUE)) ? 'mail' : strtolower($protocol); + $this->protocol = in_array($protocol, $this->_protocols, TRUE) ? strtolower($protocol) : 'mail'; return $this; } @@ -519,13 +518,7 @@ class CI_Email { */ public function set_priority($n = 3) { - if ( ! is_numeric($n) OR $n < 1 OR $n > 5) - { - $this->priority = 3; - return; - } - - $this->priority = (int) $n; + $this->priority = preg_match('/^[1-5]$/', $n) ? (int) $n : 3; return $this; } @@ -566,8 +559,8 @@ class CI_Email { */ protected function _set_boundaries() { - $this->_alt_boundary = "B_ALT_".uniqid(''); // multipart/alternative - $this->_atc_boundary = "B_ATC_".uniqid(''); // attachment boundary + $this->_alt_boundary = 'B_ALT_'.uniqid(''); // multipart/alternative + $this->_atc_boundary = 'B_ATC_'.uniqid(''); // attachment boundary } // -------------------------------------------------------------------- @@ -580,8 +573,7 @@ class CI_Email { protected function _get_message_id() { $from = str_replace(array('>', '<'), '', $this->_headers['Return-Path']); - - return "<".uniqid('').strstr($from, '@').">"; + return '<'.uniqid('').strstr($from, '@').'>'; } // -------------------------------------------------------------------- @@ -590,12 +582,12 @@ class CI_Email { * Get Mail Protocol * * @param bool - * @return string + * @return mixed */ protected function _get_protocol($return = TRUE) { $this->protocol = strtolower($this->protocol); - $this->protocol = ( ! in_array($this->protocol, $this->_protocols, TRUE)) ? 'mail' : $this->protocol; + in_array($this->protocol, $this->_protocols, TRUE) OR $this->protocol = 'mail'; if ($return == TRUE) { @@ -613,7 +605,7 @@ class CI_Email { */ protected function _get_encoding($return = TRUE) { - $this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '8bit' : $this->_encoding; + in_array($this->_encoding, $this->_bit_depths) OR $this->_encoding = '8bit'; foreach ($this->_base_charsets as $charset) { @@ -665,12 +657,12 @@ class CI_Email { */ protected function _set_date() { - $timezone = date("Z"); + $timezone = date('Z'); $operator = (strncmp($timezone, '-', 1) === 0) ? '-' : '+'; $timezone = abs($timezone); $timezone = floor($timezone/3600) * 100 + ($timezone % 3600) / 60; - return sprintf("%s %s%04d", date("D, j M Y H:i:s"), $operator, $timezone); + return sprintf('%s %s%04d', date('D, j M Y H:i:s'), $operator, $timezone); } // -------------------------------------------------------------------- @@ -682,7 +674,7 @@ class CI_Email { */ protected function _get_mime_message() { - return "This is a multi-part message in MIME format.".$this->newline."Your email application may not support this format."; + return 'This is a multi-part message in MIME format.'.$this->newline.'Your email application may not support this format.'; } // -------------------------------------------------------------------- @@ -723,7 +715,7 @@ class CI_Email { */ public function valid_email($address) { - return (bool) preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address); + return (bool) preg_match('/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix', $address); } // -------------------------------------------------------------------- @@ -745,7 +737,7 @@ class CI_Email { foreach ($email as $addy) { - $clean_email[] = (preg_match( '/\<(.*)\>/', $addy, $match)) ? $match[1] : $addy; + $clean_email[] = preg_match('/\<(.*)\>/', $addy, $match) ? $match[1] : $addy; } return $clean_email; @@ -765,7 +757,7 @@ class CI_Email { */ protected function _get_alt_message() { - if ($this->alt_message != "") + if ($this->alt_message != '') { return $this->word_wrap($this->alt_message, '76'); } @@ -1165,9 +1157,7 @@ class CI_Email { } // get rid of extra CRLF tacked onto the end - $output = substr($output, 0, strlen($this->crlf) * -1); - - return $output; + return substr($output, 0, strlen($this->crlf) * -1); } // -------------------------------------------------------------------- @@ -1236,9 +1226,7 @@ class CI_Email { // wrap each line with the shebang, charset, and transfer encoding // the preceding space on successive lines is required for header "folding" - $str = trim(preg_replace('/^(.*)$/m', ' =?'.$this->charset.'?Q?$1?=', $str)); - - return $str; + return trim(preg_replace('/^(.*)$/m', ' =?'.$this->charset.'?Q?$1?=', $str)); } // -------------------------------------------------------------------- @@ -1283,24 +1271,22 @@ class CI_Email { */ public function batch_bcc_send() { - $float = $this->bcc_batch_size -1; - - $set = ""; - + $float = $this->bcc_batch_size - 1; + $set = ''; $chunk = array(); for ($i = 0, $c = count($this->_bcc_array); $i < $c; $i++) { if (isset($this->_bcc_array[$i])) { - $set .= ", ".$this->_bcc_array[$i]; + $set .= ', '.$this->_bcc_array[$i]; } if ($i == $float) { $chunk[] = substr($set, 1); $float += $this->bcc_batch_size; - $set = ""; + $set = ''; } if ($i === $c-1) @@ -1317,7 +1303,7 @@ class CI_Email { if ($this->protocol !== 'smtp') { - $this->_set_header('Bcc', implode(", ", $bcc)); + $this->_set_header('Bcc', implode(', ', $bcc)); } else { @@ -1719,7 +1705,7 @@ class CI_Email { */ protected function _get_hostname() { - return (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain'; + return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain'; } // -------------------------------------------------------------------- @@ -1755,7 +1741,7 @@ class CI_Email { $this->_IP = end($x); } - if ( ! preg_match( "/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $this->_IP)) + if ( ! preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $this->_IP)) { $this->_IP = '0.0.0.0'; } @@ -1782,8 +1768,7 @@ class CI_Email { } } - $msg .= "
".$this->_header_str."\n".htmlspecialchars($this->_subject)."\n".htmlspecialchars($this->_finalbody).'
'; - return $msg; + return $msg.'
'.$this->_header_str."\n".htmlspecialchars($this->_subject)."\n".htmlspecialchars($this->_finalbody).'
'; } // -------------------------------------------------------------------- @@ -1817,9 +1802,10 @@ class CI_Email { * @param string * @return string */ - protected function _mime_types($ext = "") + protected function _mime_types($ext = '') { - $mimes = array( 'hqx' => 'application/mac-binhex40', + $mimes = array( + 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'doc' => 'application/msword', 'bin' => 'application/macbinary', @@ -1908,7 +1894,7 @@ class CI_Email { 'eml' => 'message/rfc822' ); - return ( ! isset($mimes[strtolower($ext)])) ? "application/x-unknown-content-type" : $mimes[strtolower($ext)]; + return isset($mimes[strtolower($ext)]) ? $mimes[strtolower($ext)] : 'application/x-unknown-content-type'; } } -- cgit v1.2.3-24-g4f1b From 7fcc7bdf7eb9c65920b1e14f242e31e3d71d1fd0 Mon Sep 17 00:00:00 2001 From: Diogo Osório Date: Fri, 2 Mar 2012 16:54:52 +0000 Subject: #1080 - Check if the SMTP connection and authentication were successfull. --- system/libraries/Email.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index c8a5b41af..39a7059dd 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1359,6 +1359,7 @@ class CI_Email { if ( ! $this->$method()) { $this->_set_error_message('lang:email_send_failure_' . ($this->_get_protocol() === 'mail' ? 'phpmail' : $this->_get_protocol())); + return FALSE; } $this->_set_error_message('lang:email_sent', $this->_get_protocol()); @@ -1433,8 +1434,10 @@ class CI_Email { return FALSE; } - $this->_smtp_connect(); - $this->_smtp_authenticate(); + if ( !($this->_smtp_connect() && $this->_smtp_authenticate()) ) + { + return FALSE; + } $this->_send_command('from', $this->clean_email($this->_headers['From'])); -- cgit v1.2.3-24-g4f1b From 593f798a0b463f45e00a207e4fe4b8cc82dedc35 Mon Sep 17 00:00:00 2001 From: Diogo Osório Date: Fri, 2 Mar 2012 18:04:17 +0000 Subject: Made the code more readable, updated the changelog. --- system/libraries/Email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 39a7059dd..8d839d0c9 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1434,7 +1434,7 @@ class CI_Email { return FALSE; } - if ( !($this->_smtp_connect() && $this->_smtp_authenticate()) ) + if ( ! $this->_smtp_connect() OR ! $this->_smtp_authenticate()) { return FALSE; } -- cgit v1.2.3-24-g4f1b From 07c1ac830b4e98aa40f48baef3dd05fb68c0a836 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 9 Mar 2012 17:03:37 +0000 Subject: Bumped CodeIgniter's PHP requirement to 5.2.4. Yes I know PHP 5.4 just came out, and yes I know PHP 5.3 has lovely features, but there are plenty of corporate systems running on CodeIgniter and PHP 5.3 still is not widely supported enough. CodeIgniter is great for distributed applications, and this is the highest we can reasonably go without breaking support. PHP 5.3 will most likely happen in another year or so. Fingers crossed on that one anyway... --- system/libraries/Email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 8d839d0c9..f30fe40b6 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * -- cgit v1.2.3-24-g4f1b From 5688d58688318cecaf9decdde014635f3a27760f Mon Sep 17 00:00:00 2001 From: Matteo Mattei Date: Tue, 13 Mar 2012 19:29:29 +0100 Subject: Add support for buffer string email attachment. --- system/libraries/Email.php | 58 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 14 deletions(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index f30fe40b6..aec4957de 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -83,6 +83,8 @@ class CI_Email { protected $_attach_name = array(); protected $_attach_type = array(); protected $_attach_disp = array(); + protected $_attach_source = 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'); @@ -171,6 +173,8 @@ class CI_Email { $this->_attach_name = array(); $this->_attach_type = array(); $this->_attach_disp = array(); + $this->_attach_source = array(); + $this->_attach_content = array(); } return $this; @@ -411,6 +415,23 @@ class CI_Email { $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_source[] = 'file'; + return $this; + } + + /** + * Assign string attachments + * + * @param string + * @return object + */ + public function string_attach($str, $filename, $mime, $disposition = 'attachment') + { + $this->_attach_name[] = $filename; + $this->_attach_type[] = $mime; + $this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters + $this->_attach_source[] = 'string'; + $this->_attach_content[] = $str; return $this; } @@ -1048,29 +1069,38 @@ 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_source[$i] == 'file') { - $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; + } + + $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."--"; -- cgit v1.2.3-24-g4f1b From 5a98a3dda56f6167f8241a7bc7d1c8784d98ccf9 Mon Sep 17 00:00:00 2001 From: Matteo Mattei Date: Thu, 15 Mar 2012 12:00:44 +0100 Subject: Email class: move string_attach() to attach() and add documentation --- system/libraries/Email.php | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index aec4957de..df03eaaf6 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_source = 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) @@ -173,7 +172,6 @@ class CI_Email { $this->_attach_name = array(); $this->_attach_type = array(); $this->_attach_disp = array(); - $this->_attach_source = array(); $this->_attach_content = array(); } @@ -410,27 +408,11 @@ class CI_Email { * @param string * @return object */ - public function attach($filename, $disposition = '', $newname = NULL) + public function attach($filename, $str = '', $mime = '', $disposition = '', $newname = NULL) { $this->_attach_name[] = array($filename, $newname); - $this->_attach_type[] = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)); + $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_source[] = 'file'; - return $this; - } - - /** - * Assign string attachments - * - * @param string - * @return object - */ - public function string_attach($str, $filename, $mime, $disposition = 'attachment') - { - $this->_attach_name[] = $filename; - $this->_attach_type[] = $mime; - $this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters - $this->_attach_source[] = 'string'; $this->_attach_content[] = $str; return $this; } @@ -1071,7 +1053,7 @@ class CI_Email { $ctype = $this->_attach_type[$i]; $file_content = ''; - if($this->_attach_source[$i] == 'file') + if ($this->_attach_content[$i] === '') { if ( ! file_exists($filename)) { -- cgit v1.2.3-24-g4f1b From df59c687a2243142e6da9d7b904523a1b91ca09b Mon Sep 17 00:00:00 2001 From: Matteo Mattei Date: Thu, 15 Mar 2012 16:03:58 +0100 Subject: Email class: adjust documentation and make the code backward compatible --- system/libraries/Email.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index df03eaaf6..7320ea566 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -408,10 +408,10 @@ class CI_Email { * @param string * @return object */ - public function attach($filename, $str = '', $mime = '', $disposition = '', $newname = NULL) + public function attach($filename, $disposition = '', $str = '', $mime = '', $newname = NULL) { $this->_attach_name[] = array($filename, $newname); - $this->_attach_type[] = ($mime === '') ? $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)) : $mime; + $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; return $this; -- cgit v1.2.3-24-g4f1b From b455294bc404e41a65f8c9260837e76ee1cc9bda Mon Sep 17 00:00:00 2001 From: leandronf Date: Wed, 21 Mar 2012 23:54:26 -0300 Subject: (DSN) Delivery status notification feature --- system/libraries/Email.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index f30fe40b6..d870f9782 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -59,6 +59,7 @@ class CI_Email { public $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers, // even on the receiving end think they need to muck with CRLFs, so using "\n", while // distasteful, is the only thing that seems to work for all environments. + var $dsn = FALSE"; // Delivery Status Notification public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo. public $bcc_batch_mode = FALSE; // TRUE/FALSE - Turns on/off Bcc batch feature public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch @@ -1567,9 +1568,11 @@ class CI_Email { $resp = 250; break; case 'to' : - - $this->_send_data('RCPT TO:<'.$data.'>'); - + + if($this->dsn) + $this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data); + else + $this->_send_data('RCPT TO:<'.$data.'>'); $resp = 250; break; case 'data' : -- cgit v1.2.3-24-g4f1b From 7686c1208cf1b0d9e1f4e522fff8a4b4646b7a2d Mon Sep 17 00:00:00 2001 From: leandronf Date: Thu, 22 Mar 2012 08:07:31 -0300 Subject: Update system/libraries/Email.php --- system/libraries/Email.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index d870f9782..8f383c939 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -59,7 +59,7 @@ class CI_Email { public $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers, // even on the receiving end think they need to muck with CRLFs, so using "\n", while // distasteful, is the only thing that seems to work for all environments. - var $dsn = FALSE"; // Delivery Status Notification + public $dsn = FALSE; // Delivery Status Notification public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo. public $bcc_batch_mode = FALSE; // TRUE/FALSE - Turns on/off Bcc batch feature public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch @@ -1569,10 +1569,14 @@ class CI_Email { break; case 'to' : - if($this->dsn) + if ($this->dsn) + { $this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data); + } else + { $this->_send_data('RCPT TO:<'.$data.'>'); + } $resp = 250; break; case 'data' : -- cgit v1.2.3-24-g4f1b From c3b36f4c6b8e8b15c96d6653ebdf07c76eb57d9e Mon Sep 17 00:00:00 2001 From: Matteo Mattei Date: Mon, 26 Mar 2012 10:27:17 +0200 Subject: Centralize handling of attach() function for both real file and buffer string. Update documentation. --- system/libraries/Email.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'system/libraries/Email.php') 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); } -- cgit v1.2.3-24-g4f1b