From 13095cbc1b1b0509ac8c984e7a5fd704d9826569 Mon Sep 17 00:00:00 2001 From: diegorivera Date: Wed, 19 Oct 2011 02:56:15 -0200 Subject: Update system/libraries/Email.php --- system/libraries/Email.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index e28c23a04..2916b9a13 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -379,7 +379,15 @@ class CI_Email { */ public function message($body) { - $this->_body = stripslashes(rtrim(str_replace("\r", "", $body))); + $this->_body = rtrim(str_replace("\r", "", $body)); + + //strip slashes only if magic quotes is ON + //if we do it with magic quotes OFF, it strips real, user-inputted chars. + if (get_magic_quotes_gpc()) + { + $this->_body = stripslashes($this->_body); + } + return $this; } -- cgit v1.2.3-24-g4f1b From 6eab49a844b3542a5efee6620233a86f645a30f5 Mon Sep 17 00:00:00 2001 From: diegorivera Date: Wed, 19 Oct 2011 11:18:45 -0200 Subject: I wasn't following the CI code style guide. --- system/libraries/Email.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 2916b9a13..5f8d48682 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -383,10 +383,10 @@ class CI_Email { //strip slashes only if magic quotes is ON //if we do it with magic quotes OFF, it strips real, user-inputted chars. - if (get_magic_quotes_gpc()) - { + if (get_magic_quotes_gpc()) + { $this->_body = stripslashes($this->_body); - } + } return $this; } -- cgit v1.2.3-24-g4f1b From 75b1f3991013c17cacac18e47879c483fe1cf542 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 20 Oct 2011 10:11:59 +0300 Subject: get_magic_quotes_gpc() to be executed only if PHP version is 5.3 or lower --- system/libraries/Email.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'system/libraries/Email.php') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 5f8d48682..c8b727c34 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -381,9 +381,13 @@ class CI_Email { { $this->_body = rtrim(str_replace("\r", "", $body)); - //strip slashes only if magic quotes is ON - //if we do it with magic quotes OFF, it strips real, user-inputted chars. - if (get_magic_quotes_gpc()) + /* strip slashes only if magic quotes is ON + if we do it with magic quotes OFF, it strips real, user-inputted chars. + + NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and + it will probably not exist in future versions at all. + */ + if ( ! is_php('5.4') && get_magic_quotes_gpc()) { $this->_body = stripslashes($this->_body); } -- cgit v1.2.3-24-g4f1b From c78301cee7b648911601f663731ddb4871d1bba4 Mon Sep 17 00:00:00 2001 From: Radu Potop Date: Wed, 28 Sep 2011 13:57:51 +0300 Subject: Added TLS and SSL support to Email library. Fixes issue #171 --- system/libraries/Email.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'system/libraries/Email.php') 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.'>'); -- cgit v1.2.3-24-g4f1b