summaryrefslogtreecommitdiffstats
path: root/system/libraries/Email.php
diff options
context:
space:
mode:
authorRadu Potop <wooptoo@gmail.com>2011-09-28 12:57:51 +0200
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-11-13 20:16:39 +0100
commitc78301cee7b648911601f663731ddb4871d1bba4 (patch)
tree8252476cc002c47b35f6c9fd49c1c076e6d2ecf5 /system/libraries/Email.php
parenta35e31c3ead0396e2a7c7be9b292c66a6457a1a0 (diff)
Added TLS and SSL support to Email library. Fixes issue #171
Diffstat (limited to 'system/libraries/Email.php')
-rw-r--r--system/libraries/Email.php20
1 files changed, 19 insertions, 1 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index c8b727c34..9ec40af9d 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
@@ -1678,7 +1679,10 @@ 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,
@@ -1691,6 +1695,14 @@ class CI_Email {
}
$this->_set_error_message($this->_get_smtp_data());
+
+ if ($this->smtp_crypto == 'tls')
+ {
+ $this->_send_command('hello');
+ $this->_send_command('starttls');
+ stream_socket_enable_crypto($this->_smtp_connect, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT);
+ }
+
return $this->_send_command('hello');
}
@@ -1717,6 +1729,12 @@ class CI_Email {
$resp = 250;
break;
+ case 'starttls' :
+
+ $this->_send_data('STARTTLS');
+
+ $resp = 220;
+ break;
case 'from' :
$this->_send_data('MAIL FROM:<'.$data.'>');