From 2aa5a18635a8982b7318d0976ae5d00832fa71ca Mon Sep 17 00:00:00 2001 From: Rick Ellis Date: Tue, 30 Sep 2008 21:23:58 +0000 Subject: Did a little cleanup for better readability --- system/libraries/Email.php | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 8c56ccca0..e9a5344fe 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -59,7 +59,7 @@ class CI_Email { var $_atc_boundary = ""; var $_header_str = ""; var $_smtp_connect = ""; - var $_encoding = "8bit"; + var $_encoding = "8bit"; var $_IP = FALSE; var $_smtp_auth = FALSE; var $_replyto_flag = FALSE; @@ -74,16 +74,16 @@ class CI_Email { var $_protocols = array('mail', 'sendmail', 'smtp'); 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)'); + var $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)'); /** * Constructor - Sets Email Preferences * * The constructor can be passed an array of config values - */ + */ function CI_Email($config = array()) - { + { if (count($config) > 0) { $this->initialize($config); @@ -105,7 +105,7 @@ class CI_Email { * @access public * @param array * @return void - */ + */ function initialize($config = array()) { $this->clear(); @@ -277,7 +277,9 @@ class CI_Email { $cc = $this->clean_email($cc); if ($this->validate) + { $this->validate_email($cc); + } $this->_set_header('Cc', implode(", ", $cc)); @@ -630,15 +632,15 @@ class CI_Email { { if ($this->mailtype == 'html' && count($this->_attach_name) == 0) { - return 'html'; + return 'html'; } elseif ($this->mailtype == 'html' && count($this->_attach_name) > 0) { - return 'html-attach'; + return 'html-attach'; } elseif ($this->mailtype == 'text' && count($this->_attach_name) > 0) { - return 'plain-attach'; + return 'plain-attach'; } else { @@ -950,7 +952,9 @@ class CI_Email { } if ($this->_get_protocol() == 'mail') + { $this->_header_str = substr($this->_header_str, 0, -1); + } } // -------------------------------------------------------------------- @@ -1167,14 +1171,14 @@ class CI_Email { // Reduce multiple spaces $str = preg_replace("| +|", " ", $str); - + // kill nulls $str = preg_replace('/\x00+/', '', $str); // Standardize newlines if (strpos($str, "\r") !== FALSE) { - $str = str_replace(array("\r\n", "\r"), "\n", $str); + $str = str_replace(array("\r\n", "\r"), "\n", $str); } // We are intentionally wrapping so mail servers will encode characters @@ -1425,18 +1429,26 @@ class CI_Email { if ($this->_safe_mode == TRUE) { if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str)) + { return FALSE; + } else + { return TRUE; + } } else { // most documentation of sendmail using the "-f" flag lacks a space after it, however // we've encountered servers that seem to require it to be in place. if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From']))) + { return FALSE; + } else + { return TRUE; + } } } @@ -1487,14 +1499,18 @@ class CI_Email { $this->_send_command('from', $this->clean_email($this->_headers['From'])); foreach($this->_recipients as $val) + { $this->_send_command('to', $val); + } if (count($this->_cc_array) > 0) { foreach($this->_cc_array as $val) { if ($val != "") - $this->_send_command('to', $val); + { + $this->_send_command('to', $val); + } } } @@ -1503,7 +1519,9 @@ class CI_Email { foreach($this->_bcc_array as $val) { if ($val != "") - $this->_send_command('to', $val); + { + $this->_send_command('to', $val); + } } } -- cgit v1.2.3-24-g4f1b