summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/libraries/Email.php30
-rw-r--r--user_guide/changelog.html1
-rw-r--r--user_guide/libraries/email.html5
3 files changed, 34 insertions, 2 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index c8cb8549e..ef20e1978 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -36,6 +36,7 @@ class CI_Email {
var $smtp_pass = ""; // SMTP Password
var $smtp_port = "25"; // SMTP Port
var $smtp_timeout = 5; // SMTP Timeout in seconds
+ var $smtp_crypto = ""; // SMTP Encryption. Can be null, tls or ssl.
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
@@ -1667,7 +1668,14 @@ class CI_Email {
*/
protected function _smtp_connect()
{
- $this->_smtp_connect = fsockopen($this->smtp_host,
+ $ssl = NULL;
+
+ if ($this->smtp_crypto == 'ssl')
+ {
+ $ssl = 'ssl://';
+ }
+
+ $this->_smtp_connect = fsockopen($ssl.$this->smtp_host,
$this->smtp_port,
$errno,
$errstr,
@@ -1680,6 +1688,20 @@ class CI_Email {
}
$this->_set_error_message($this->_get_smtp_data());
+
+ if ($this->smtp_crypto == 'tls')
+ {
+ $this->_send_command('hello');
+ $this->_send_command('starttls');
+ $crypto = stream_socket_enable_crypto($this->_smtp_connect, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT);
+ }
+
+ if ($crypto !== TRUE)
+ {
+ $this->_set_error_message('lang:email_smtp_error', $this->_get_smtp_data());
+ return FALSE;
+ }
+
return $this->_send_command('hello');
}
@@ -1706,6 +1728,12 @@ class CI_Email {
$resp = 250;
break;
+ case 'starttls' :
+
+ $this->_send_data('STARTTLS');
+
+ $resp = 220;
+ break;
case 'from' :
$this->_send_data('MAIL FROM:<'.$data.'>');
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 81514af73..fef05f78e 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -106,6 +106,7 @@ Change Log
<li>Added <kbd>is_unique</kbd> to the <a href="libraries/form_validation.html">Form Validation library</a>.</li>
<li>Modified valid_ip() to use PHP's filter_var() when possible (>= PHP 5.2) in the <a href="libraries/form_validation.html">Form Validation</a> library.</li>
<li>Added <kbd>$config['use_page_numbers']</kbd> to the <a href="libraries/pagination.html">Pagination library</a>, which enables real page numbers in the URI.</li>
+ <li>Added TLS and SSL Encryption for SMTP.</li>
</ul>
</li>
<li>Core
diff --git a/user_guide/libraries/email.html b/user_guide/libraries/email.html
index d246254ab..de2f1c0c9 100644
--- a/user_guide/libraries/email.html
+++ b/user_guide/libraries/email.html
@@ -63,6 +63,7 @@ Email Class
<ul>
<li>Multiple Protocols: Mail, Sendmail, and SMTP</li>
+<li>TLS and SSL Encryption for SMTP</li>
<li>Multiple recipients</li>
<li>CC and BCCs</li>
<li>HTML or Plaintext email</li>
@@ -152,6 +153,8 @@ will NOT need to use the <dfn>$this->email->initialize()</dfn> function if you s
</tr><tr>
<td class="td"><strong>smtp_timeout</strong></td><td class="td">5</td><td class="td">None</td><td class="td">SMTP Timeout (in seconds).</td>
</tr><tr>
+<td class="td"><strong>smtp_crypto</strong></td><td class="td">No Default</td><td class="td">tls or ssl</td><td class="td">SMTP Encryption.</td>
+</tr><tr>
<td class="td"><strong>wordwrap</strong></td><td class="td">TRUE</td><td class="td">TRUE or FALSE (boolean)</td><td class="td">Enable word-wrap.</td>
</tr><tr>
<td class="td"><strong>wrapchars</strong></td><td class="td">76</td><td class="td"> </td><td class="td">Character count to wrap at.</td>
@@ -304,4 +307,4 @@ Next Topic:&nbsp;&nbsp;<a href="encryption.html">Encryption Class</a>
</div>
</body>
-</html> \ No newline at end of file
+</html>