diff options
author | David Barratt <david@davidwbarratt.com> | 2013-02-18 23:57:51 +0100 |
---|---|---|
committer | David Barratt <david@davidwbarratt.com> | 2013-02-18 23:57:51 +0100 |
commit | a0afc3aafad9552d5f8763fdc6f635b5b683d8b6 (patch) | |
tree | 3fe2b8717a2057564ebdb331e89edc8ba4445259 | |
parent | b2834114746585b60a490992a02c1b136363e791 (diff) | |
parent | 6244086d6e251fc4b3c71d23da625ffb59b85d77 (diff) |
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into develop
-rw-r--r-- | system/helpers/form_helper.php | 2 | ||||
-rw-r--r-- | system/libraries/Email.php | 48 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 2 | ||||
-rw-r--r-- | user_guide_src/source/libraries/email.rst | 1 |
4 files changed, 51 insertions, 2 deletions
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index d6e3e85fa..692909c79 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -228,7 +228,7 @@ if ( ! function_exists('form_upload')) */ function form_upload($data = '', $value = '', $extra = '') { - $default = array('type' => 'file', 'name' => ''); + $defaults = array('type' => 'file', 'name' => ''); is_array($data) OR $data = array('name' => $data); $data['type'] = 'file'; return '<input '._parse_form_attributes($data, $defaults).$extra." />\n"; 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); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8d3f3705d..4e55182e5 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -262,6 +262,7 @@ Release Date: Not Released - Removed unused protected method ``_get_ip()`` (:doc:`Input Library <libraries/input>`'s ``ip_address()`` should be used anyway). - Internal method ``_prep_q_encoding()`` now utilizes PHP's *mbstring* and *iconv* extensions (when available) and no longer has a second (``$from``) argument. - Added an optional parameter to ``print_debugger()`` to allow specifying which parts of the message should be printed ('headers', 'subject', 'body'). + - Added SMTP keepalive option to avoid opening the connection for each ``Email::send()``. Accessible as ``$smtp_keepalive``. - :doc:`Pagination Library <libraries/pagination>` changes include: - Added support for the anchor "rel" attribute. - Added support for setting custom attributes. @@ -485,6 +486,7 @@ Bug fixes for 3.0 - Fixed a bug - :doc:`DB result <database/results>` method ``list_fields()`` didn't reset its field pointer for the *mysql*, *mysqli* and *mssql* drivers. - Fixed a bug (#73) - :doc:`Security Library <libraries/security>` method ``sanitize_filename()`` could be tricked by an XSS attack. - Fixed a bug (#2211) - :doc:`Migration Library <libraries/migration>` extensions couldn't execute ``CI_Migration::__construct()``. +- Fixed a bug (#2255) where ``smtp_timeout`` was not being applied to read and writes for the socket. Version 2.1.3 ============= diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst index 7d468251c..a55f1895d 100644 --- a/user_guide_src/source/libraries/email.rst +++ b/user_guide_src/source/libraries/email.rst @@ -89,6 +89,7 @@ Preference Default Value Options Descript **smtp_pass** No Default None SMTP Password. **smtp_port** 25 None SMTP Port. **smtp_timeout** 5 None SMTP Timeout (in seconds). +**smtp_keepalive** FALSE TRUE or FALSE (boolean) Enable persistent SMTP connections. **smtp_crypto** No Default tls or ssl SMTP Encryption **wordwrap** TRUE TRUE or FALSE (boolean) Enable word-wrap. **wrapchars** 76 Character count to wrap at. |