From e7c4c3211c05c7bde09dbdbac77647461f52bfdb Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Tue, 22 Jan 2008 18:16:39 +0000 Subject: fixed bug #3279 - removed iso-8859-1 from $this->_base_charsets, and altered _get_encoding() to check more broadly for 7bit character sets before deciding whether to set the encoding to 7-bit or 8-bit. --- system/libraries/Email.php | 47 ++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 6136a0501..25e59632f 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -36,13 +36,13 @@ class CI_Email { var $smtp_pass = ""; // SMTP Password var $smtp_port = "25"; // SMTP Port var $smtp_timeout = 5; // SMTP Timeout in seconds - var $wordwrap = TRUE; // true/false Turns word-wrap on/off + var $wordwrap = TRUE; // TRUE/FALSE Turns word-wrap on/off var $wrapchars = "76"; // Number of characters to wrap at. var $mailtype = "text"; // text/html Defines email formatting var $charset = "utf-8"; // Default char set: iso-8859-1 or us-ascii var $multipart = "mixed"; // "mixed" (in the body) or "related" (separate) var $alt_message = ''; // Alternative message for HTML emails - var $validate = FALSE; // true/false. Enables email validation + var $validate = FALSE; // TRUE/FALSE. Enables email validation var $priority = "3"; // Default priority (1 - 5) var $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822) @@ -50,8 +50,8 @@ class CI_Email { // 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 $bcc_batch_mode = FALSE; // true/false Turns on/off Bcc batch feature - var $bcc_batch_size = 200; // If bcc_batch_mode = true, sets max number of Bccs in each batch + var $bcc_batch_mode = FALSE; // TRUE/FALSE Turns on/off Bcc batch feature + var $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch var $_subject = ""; var $_body = ""; var $_finalbody = ""; @@ -73,7 +73,7 @@ class CI_Email { var $_attach_type = array(); var $_attach_disp = array(); var $_protocols = array('mail', 'sendmail', 'smtp'); - var $_base_charsets = array('iso-8859-1', 'us-ascii'); + var $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix) var $_bit_depths = array('7bit', '8bit'); var $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)'); @@ -282,7 +282,7 @@ class CI_Email { { if ($limit != '' && is_numeric($limit)) { - $this->bcc_batch_mode = true; + $this->bcc_batch_mode = TRUE; $this->bcc_batch_size = $limit; } @@ -538,12 +538,12 @@ class CI_Email { * @param bool * @return string */ - function _get_protocol($return = true) + function _get_protocol($return = TRUE) { $this->protocol = strtolower($this->protocol); $this->protocol = ( ! in_array($this->protocol, $this->_protocols, TRUE)) ? 'mail' : $this->protocol; - if ($return == true) + if ($return == TRUE) return $this->protocol; } @@ -556,15 +556,22 @@ class CI_Email { * @param bool * @return string */ - function _get_encoding($return = true) + function _get_encoding($return = TRUE) { - $this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '7bit' : $this->_encoding; + $this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '8bit' : $this->_encoding; - if ( ! in_array($this->charset, $this->_base_charsets, TRUE)) - $this->_encoding = "8bit"; + foreach ($this->_base_charsets as $charset) + { + if (strncmp($charset, $this->charset, strlen($charset)) == 0) + { + $this->_encoding = '7bit'; + } + } - if ($return == true) - return $this->_encoding; + if ($return == TRUE) + { + return $this->_encoding; + } } // -------------------------------------------------------------------- @@ -1307,7 +1314,7 @@ class CI_Email { } $this->_set_error_message('email_sent', $this->_get_protocol()); - return true; + return TRUE; } // -------------------------------------------------------------------- @@ -1422,7 +1429,7 @@ class CI_Email { } $this->_send_command('quit'); - return true; + return TRUE; } // -------------------------------------------------------------------- @@ -1515,7 +1522,7 @@ class CI_Email { if ($cmd == 'quit') fclose($this->_smtp_connect); - return true; + return TRUE; } // -------------------------------------------------------------------- @@ -1529,7 +1536,7 @@ class CI_Email { function _smtp_authenticate() { if ( ! $this->_smtp_auth) - return true; + return TRUE; if ($this->smtp_user == "" AND $this->smtp_pass == "") { @@ -1567,7 +1574,7 @@ class CI_Email { return FALSE; } - return true; + return TRUE; } // -------------------------------------------------------------------- @@ -1586,7 +1593,7 @@ class CI_Email { return FALSE; } else - return true; + return TRUE; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b