summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorDavid Barratt <david@davidwbarratt.com>2013-02-18 23:57:51 +0100
committerDavid Barratt <david@davidwbarratt.com>2013-02-18 23:57:51 +0100
commita0afc3aafad9552d5f8763fdc6f635b5b683d8b6 (patch)
tree3fe2b8717a2057564ebdb331e89edc8ba4445259 /system/libraries
parentb2834114746585b60a490992a02c1b136363e791 (diff)
parent6244086d6e251fc4b3c71d23da625ffb59b85d77 (diff)
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into develop
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Email.php48
1 files changed, 47 insertions, 1 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 997757b0a..1bf1da15e 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -94,6 +94,13 @@ class CI_Email {
* @var int
*/
public $smtp_timeout = 5;
+
+ /**
+ * SMTP persistent connection
+ *
+ * @var bool
+ */
+ public $smtp_keepalive = FALSE;
/**
* SMTP Encryption
@@ -401,6 +408,21 @@ class CI_Email {
}
// --------------------------------------------------------------------
+
+ /**
+ * Destructor - Releases Resources
+ *
+ * @return void
+ */
+ public function __destruct()
+ {
+ if (is_resource($this->_smtp_connect))
+ {
+ $this->_send_command('quit');
+ }
+ }
+
+ // --------------------------------------------------------------------
/**
* Initialize preferences
@@ -1824,7 +1846,15 @@ class CI_Email {
return FALSE;
}
- $this->_send_command('quit');
+ if ($this->smtp_keepalive)
+ {
+ $this->_send_command('reset');
+ }
+ else
+ {
+ $this->_send_command('quit');
+ }
+
return TRUE;
}
@@ -1837,6 +1867,11 @@ class CI_Email {
*/
protected function _smtp_connect()
{
+ if (is_resource($this->_smtp_connect))
+ {
+ return TRUE;
+ }
+
$ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : NULL;
$this->_smtp_connect = fsockopen($ssl.$this->smtp_host,
@@ -1851,6 +1886,7 @@ class CI_Email {
return FALSE;
}
+ stream_set_timeout($this->_smtp_connect, $this->smtp_timeout);
$this->_set_error_message($this->_get_smtp_data());
if ($this->smtp_crypto === 'tls')
@@ -1924,6 +1960,11 @@ class CI_Email {
$this->_send_data('DATA');
$resp = 354;
break;
+ case 'reset':
+
+ $this->_send_data('RSET');
+ $resp = 250;
+ break;
case 'quit' :
$this->_send_data('QUIT');
@@ -1973,6 +2014,11 @@ class CI_Email {
$reply = $this->_get_smtp_data();
+ if (strpos($reply, '503') !== 0) // Already authenticated
+ {
+ return TRUE;
+ }
+
if (strpos($reply, '334') !== 0)
{
$this->_set_error_message('lang:email_failed_smtp_login', $reply);