From 18dd31c4715cbf949236e087ceac361a360e09d4 Mon Sep 17 00:00:00 2001 From: yehudah Date: Sun, 22 Jul 2018 09:34:11 +0000 Subject: [PATCH] Better support for secure delivery and auth contacts (wp-config) git-svn-id: https://plugins.svn.wordpress.org/post-smtp/trunk@1912939 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- .../Zend-1.12.10/Mail/Protocol/Smtp.php | 9 ++++- Postman/PostmanOptions.php | 34 ++++++++++++++++--- Postman/PostmanViewController.php | 2 +- postman-smtp.php | 4 +-- readme.txt | 7 +++- 5 files changed, 47 insertions(+), 9 deletions(-) diff --git a/Postman/Postman-Mail/Zend-1.12.10/Mail/Protocol/Smtp.php b/Postman/Postman-Mail/Zend-1.12.10/Mail/Protocol/Smtp.php index b71ff100..be6d9089 100644 --- a/Postman/Postman-Mail/Zend-1.12.10/Mail/Protocol/Smtp.php +++ b/Postman/Postman-Mail/Zend-1.12.10/Mail/Protocol/Smtp.php @@ -208,7 +208,14 @@ public function helo($host = '127.0.0.1') stream_context_set_option($this->_socket, 'ssl', 'verify_peer_name', false); stream_context_set_option($this->_socket, 'ssl', 'allow_self_signed', true); - if (!stream_socket_enable_crypto($this->_socket, 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; + } + + if (!stream_socket_enable_crypto($this->_socket, true, $crypto_method)) { /** * @see Postman_Zend_Mail_Protocol_Exception */ diff --git a/Postman/PostmanOptions.php b/Postman/PostmanOptions.php index 193f8c97..20d3a046 100644 --- a/Postman/PostmanOptions.php +++ b/Postman/PostmanOptions.php @@ -260,16 +260,42 @@ public function getAuthenticationType() { return $this->options [ PostmanOptions::AUTHENTICATION_TYPE ]; } } public function getEncryptionType() { - if ( isset( $this->options [ PostmanOptions::SECURITY_TYPE ] ) ) { - return $this->options [ PostmanOptions::SECURITY_TYPE ]; } + $port = $this->getPort(); + switch ($port): + case 25: + return 'none'; + break; + case 465: + return 'ssl'; + break; + case 587: + return 'tls'; + break; + case 2525: + return 'tls'; + break; + default: + return isset( $this->options [ PostmanOptions::SECURITY_TYPE ] ) ? $this->options [ PostmanOptions::SECURITY_TYPE ] : 'none'; + endswitch; } public function getUsername() { + if ( defined( POST_SMTP_AUTH_USERNAME ) ) { + return POST_SMTP_AUTH_USERNAME; + } + if ( isset( $this->options [ PostmanOptions::BASIC_AUTH_USERNAME ] ) ) { - return $this->options [ PostmanOptions::BASIC_AUTH_USERNAME ]; } + return $this->options [ PostmanOptions::BASIC_AUTH_USERNAME ]; + } } public function getPassword() { + + if ( defined( POST_SMTP_AUTH_PASSWORD ) ) { + return POST_SMTP_AUTH_PASSWORD; + } + if ( isset( $this->options [ PostmanOptions::BASIC_AUTH_PASSWORD ] ) ) { - return base64_decode( $this->options [ PostmanOptions::BASIC_AUTH_PASSWORD ] ); } + return base64_decode( $this->options [ PostmanOptions::BASIC_AUTH_PASSWORD ] ); + } } public function getMandrillApiKey() { if ( isset( $this->options [ PostmanOptions::MANDRILL_API_KEY ] ) ) { diff --git a/Postman/PostmanViewController.php b/Postman/PostmanViewController.php index 5fb8cb1f..7aeeae41 100644 --- a/Postman/PostmanViewController.php +++ b/Postman/PostmanViewController.php @@ -307,7 +307,7 @@ private function displayTopNavigation() { echo '

- Version ' . $version . ' released with lockfile fix and new PHP requirement: Read Here + Version ' . $version . ' released with better compability for secure ports: Read Here