From fab638d96b6fd31e160df66ff02dc0281f9debb4 Mon Sep 17 00:00:00 2001 From: Marius Burkard <m.burkard@pixcept.de> Date: Sun, 7 Jun 2020 22:26:50 +0200 Subject: [PATCH] - migrated changes from interface to server --- server/lib/classes/ispcmail.inc.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/server/lib/classes/ispcmail.inc.php b/server/lib/classes/ispcmail.inc.php index cc83c74137..fbf5f84dca 100644 --- a/server/lib/classes/ispcmail.inc.php +++ b/server/lib/classes/ispcmail.inc.php @@ -169,7 +169,7 @@ class ispcmail { $this->smtp_host = $value; break; case 'smtp_port': - $this->smtp_port = $value; + if(intval($value) > 0) $this->smtp_port = $value; break; case 'smtp_user': $this->smtp_user = $value; @@ -586,8 +586,8 @@ class ispcmail { */ private function _smtp_login() { $this->_smtp_conn = fsockopen(($this->smtp_crypt == 'ssl' ? 'tls://' : '') . $this->smtp_host, $this->smtp_port, $errno, $errstr, 30); - $response = fgets($this->_smtp_conn, 515); if(empty($this->_smtp_conn)) return false; + $response = fgets($this->_smtp_conn, 515); //Say Hello to SMTP if($this->smtp_helo == '') $this->detectHelo(); @@ -598,13 +598,20 @@ class ispcmail { if($this->smtp_crypt == 'tls') { fputs($this->_smtp_conn, 'STARTTLS' . $this->_crlf); fgets($this->_smtp_conn, 515); + $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT; if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) { $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; } - stream_socket_enable_crypto($this->_smtp_conn, true, $crypto_method); + stream_context_set_option($this->_smtp_conn, 'ssl', 'verify_host', false); + stream_context_set_option($this->_smtp_conn, 'ssl', 'verify_peer', false); + stream_context_set_option($this->_smtp_conn, 'ssl', 'verify_peer_name', false); + stream_context_set_option($this->_smtp_conn, 'ssl', 'allow_self_signed', true); + if (stream_socket_enable_crypto($this->_smtp_conn, true, $crypto_method) != true) { + return false; + } } //AUTH LOGIN -- GitLab