diff options
author | Radu Potop <wooptoo@gmail.com> | 2011-09-28 12:57:51 +0200 |
---|---|---|
committer | Radu Potop <wooptoo@gmail.com> | 2011-09-28 12:57:51 +0200 |
commit | bbf04b011bd30c9c67970aa5a5049a32a01474b4 (patch) | |
tree | 183603e95dbcbea39c486c107a35de2da8f0f08a /system | |
parent | 5a3284edd6f3de5871804c7e24a9d74e57b2b7a6 (diff) |
Added TLS and SSL support to Email library. Fixes issue #171
Diffstat (limited to 'system')
-rw-r--r-- | system/libraries/Email.php | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php index c8cb8549e..648bb6b4d 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,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, @@ -1680,6 +1684,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'); } @@ -1706,6 +1718,12 @@ class CI_Email { $resp = 250; break; + case 'starttls' : + + $this->_send_data('STARTTLS'); + + $resp = 220; + break; case 'from' : $this->_send_data('MAIL FROM:<'.$data.'>'); |