diff --git a/interface/lib/classes/ispcmail.inc.php b/interface/lib/classes/ispcmail.inc.php
index b818e1e44a6732db717bee6560001a6ebba9ef35..522fd1a71b6f0e6bf4beebbff0c9e2ba4a06aac7 100644
--- a/interface/lib/classes/ispcmail.inc.php
+++ b/interface/lib/classes/ispcmail.inc.php
@@ -599,10 +599,16 @@ class ispcmail {
 			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_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', 'allow_self_signed', true);
-			stream_socket_enable_crypto($this->_smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
+			stream_socket_enable_crypto($this->_smtp_conn, true, $crypto_method);
 		}
 
 		//AUTH LOGIN
diff --git a/server/lib/classes/ispcmail.inc.php b/server/lib/classes/ispcmail.inc.php
index 305b39f35ba47e235413cf4e364cdc4987cd6ce0..cc83c7413725801af4d0cb6e3192f6a41b833186 100644
--- a/server/lib/classes/ispcmail.inc.php
+++ b/server/lib/classes/ispcmail.inc.php
@@ -598,7 +598,13 @@ class ispcmail {
 		if($this->smtp_crypt == 'tls') {
 			fputs($this->_smtp_conn, 'STARTTLS' . $this->_crlf);
 			fgets($this->_smtp_conn, 515);
-			stream_socket_enable_crypto($this->_smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
+			$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);
 		}
 
 		//AUTH LOGIN