summaryrefslogtreecommitdiffstats
path: root/system/libraries/Email.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-07-26 20:03:12 +0200
committerAndrey Andreev <narf@devilix.net>2016-07-26 20:03:12 +0200
commit77266bc6a01668b2106b9974da02e2a7ceaf2fe6 (patch)
tree955346c3278c03a2ff4174b9d078e9416a298ee9 /system/libraries/Email.php
parenta9874a638970ef826f835718e58b197ff3672566 (diff)
parent0b9540209499fbd0515e13fdc66e85dea4b6baad (diff)
Merge branch '3.1-stable' into develop
Conflicts resolved: .travis.yml system/core/CodeIgniter.php system/database/drivers/oci8/oci8_forge.php system/database/drivers/pdo/subdrivers/pdo_oci_forge.php system/helpers/path_helper.php system/libraries/Email.php user_guide_src/source/changelog.rst user_guide_src/source/conf.py user_guide_src/source/contributing/index.rst user_guide_src/source/general/requirements.rst user_guide_src/source/general/styleguide.rst user_guide_src/source/installation/downloads.rst user_guide_src/source/installation/upgrade_310.rst user_guide_src/source/installation/upgrading.rst
Diffstat (limited to 'system/libraries/Email.php')
-rw-r--r--system/libraries/Email.php86
1 files changed, 46 insertions, 40 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 0a55e1841..e9f69f065 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -387,18 +387,8 @@ class CI_Email {
public function __construct(array $config = array())
{
$this->charset = config_item('charset');
-
- if (count($config) > 0)
- {
- $this->initialize($config);
- }
- else
- {
- $this->_smtp_auth = ! ($this->smtp_user === '' && $this->smtp_pass === '');
- }
-
+ $this->initialize($config);
$this->_safe_mode = ( ! is_php('5.4') && ini_get('safe_mode'));
- $this->charset = strtoupper($this->charset);
log_message('info', 'Email Class Initialized');
}
@@ -406,28 +396,15 @@ class CI_Email {
// --------------------------------------------------------------------
/**
- * Destructor - Releases Resources
- *
- * @return void
- */
- public function __destruct()
- {
- if (is_resource($this->_smtp_connect))
- {
- $this->_send_command('quit');
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
* Initialize preferences
*
- * @param array
+ * @param array $config
* @return CI_Email
*/
- public function initialize($config = array())
+ public function initialize(array $config = array())
{
+ $this->clear();
+
foreach ($config as $key => $val)
{
if (isset($this->$key))
@@ -444,9 +421,9 @@ class CI_Email {
}
}
}
- $this->clear();
- $this->_smtp_auth = ! ($this->smtp_user === '' && $this->smtp_pass === '');
+ $this->charset = strtoupper($this->charset);
+ $this->_smtp_auth = isset($this->smtp_user[0], $this->smtp_pass[0]);
return $this;
}
@@ -1942,6 +1919,7 @@ class CI_Email {
if ( ! $this->_send_command('from', $this->clean_email($this->_headers['From'])))
{
+ $this->_smtp_end();
return FALSE;
}
@@ -1949,6 +1927,7 @@ class CI_Email {
{
if ( ! $this->_send_command('to', $val))
{
+ $this->_smtp_end();
return FALSE;
}
}
@@ -1959,6 +1938,7 @@ class CI_Email {
{
if ($val !== '' && ! $this->_send_command('to', $val))
{
+ $this->_smtp_end();
return FALSE;
}
}
@@ -1970,6 +1950,7 @@ class CI_Email {
{
if ($val !== '' && ! $this->_send_command('to', $val))
{
+ $this->_smtp_end();
return FALSE;
}
}
@@ -1977,6 +1958,7 @@ class CI_Email {
if ( ! $this->_send_command('data'))
{
+ $this->_smtp_end();
return FALSE;
}
@@ -1986,30 +1968,38 @@ class CI_Email {
$this->_send_data('.');
$reply = $this->_get_smtp_data();
-
$this->_set_error_message($reply);
+ $this->_smtp_end();
+
if (strpos($reply, '250') !== 0)
{
$this->_set_error_message('lang:email_smtp_error', $reply);
return FALSE;
}
- if ($this->smtp_keepalive)
- {
- $this->_send_command('reset');
- }
- else
- {
- $this->_send_command('quit');
- }
-
return TRUE;
}
// --------------------------------------------------------------------
/**
+ * SMTP End
+ *
+ * Shortcut to send RSET or QUIT depending on keep-alive
+ *
+ * @return void
+ */
+ protected function _smtp_end()
+ {
+ ($this->smtp_keepalive)
+ ? $this->_send_command('reset')
+ : $this->_send_command('quit');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* SMTP Connect
*
* @return string
@@ -2193,6 +2183,11 @@ class CI_Email {
return FALSE;
}
+ if ($this->smtp_keepalive)
+ {
+ $this->_smtp_auth = FALSE;
+ }
+
return TRUE;
}
@@ -2382,4 +2377,15 @@ class CI_Email {
return 'application/x-unknown-content-type';
}
+ // --------------------------------------------------------------------
+
+ /**
+ * Destructor
+ *
+ * @return void
+ */
+ public function __destruct()
+ {
+ is_resource($this->_smtp_connect) && $this->_send_command('quit');
+ }
}