diff options
author | Mike Funk <mfunk@xulonpress.com> | 2011-10-10 16:31:56 +0200 |
---|---|---|
committer | Mike Funk <mfunk@xulonpress.com> | 2011-10-10 16:31:56 +0200 |
commit | 8afb848fded8fbdfa24b72df7f067e960c83c0e8 (patch) | |
tree | bf3d8fa70610253cb13a87c1aa9d634dcee9f413 /system/libraries/Email.php | |
parent | 25246b6b29d87ad7a4f304a7b5623c9f57953356 (diff) | |
parent | bdbe6d222c15e9d1b42a8ee3a3e7fe04b753c1ba (diff) |
Codeigniter develop latest.
Diffstat (limited to 'system/libraries/Email.php')
-rw-r--r-- | system/libraries/Email.php | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php index e28c23a04..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 @@ -138,6 +139,7 @@ class CI_Email { * Initialize the Email Data * * @access public + * @param bool * @return void */ public function clear($clear_attachments = FALSE) @@ -452,7 +454,7 @@ class CI_Email { */ public function set_alt_message($str = '') { - $this->alt_message = $str; + $this->alt_message = (string) $str; return $this; } @@ -477,12 +479,12 @@ class CI_Email { * Set Wordwrap * * @access public - * @param string + * @param bool * @return void */ public function set_wordwrap($wordwrap = TRUE) { - $this->wordwrap = ($wordwrap === FALSE) ? FALSE : TRUE; + $this->wordwrap = (bool) $wordwrap; return $this; } @@ -1666,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, @@ -1679,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'); } @@ -1705,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.'>'); |