summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-10-01 12:09:11 +0200
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-10-01 12:09:11 +0200
commit51a7b75ba023a4bf1e70840a19e0457f5123fb72 (patch)
tree5253b1a7bcb9ec99cb90c49ee2ac9604a5d68f5f /system
parent73b295ce336b7f2079895cc59d9c3c9e6713c84c (diff)
parent4c589aed7b0215e3d4105b11776bc45f299d291d (diff)
Merge pull request #508 from wooptoo/develop
Added TLS and SSL support to Email library
Diffstat (limited to 'system')
-rw-r--r--system/libraries/Email.php30
1 files changed, 29 insertions, 1 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.'>');