Commit 0ccbacae authored by Seamus Lee's avatar Seamus Lee

Use composer for Net_SMTP and Net_Socket and patch for TLS and CiviCRM Custom Error

Roll back Net_Socket for php compatabilty
parent b5bc4402
......@@ -23,7 +23,9 @@
"phpoffice/phpword": "^0.13.0",
"pear/Validate_Finance_CreditCard": "dev-master",
"civicrm/civicrm-cxn-rpc": "~0.16.12.05",
"pear/Auth_SASL": "1.1.0"
"pear/Auth_SASL": "1.1.0",
"pear/Net_SMTP": "1.6.*",
"pear/Net_socket": "1.0.*"
},
"repositories": [
{
......@@ -35,12 +37,14 @@
"post-install-cmd": [
"bash tools/scripts/composer/dompdf-cleanup.sh",
"bash tools/scripts/composer/tcpdf-cleanup.sh",
"bash tools/scripts/composer/pear-execption-fix.sh"
"bash tools/scripts/composer/pear-exception-fix.sh",
"bash tools/scripts/composer/net-smtp-fix.sh"
],
"post-update-cmd": [
"bash tools/scripts/composer/dompdf-cleanup.sh",
"bash tools/scripts/composer/tcpdf-cleanup.sh",
"bash tools/scripts/composer/pear-execption-fix.sh"
"bash tools/scripts/composer/pear-exception-fix.sh",
"bash tools/scripts/composer/net-smtp-fix.sh"
]
}
}
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "60d5a363eaca7fd7db0dbb3ba0599fa5",
"content-hash": "9717496290241ba85372c78b619e957b",
"packages": [
{
"name": "civicrm/civicrm-cxn-rpc",
......@@ -197,6 +197,119 @@
"description": "Abstraction of various SASL mechanism responses",
"time": "2017-03-07T14:37:05+00:00"
},
{
"name": "pear/net_smtp",
"version": "1.6.3",
"source": {
"type": "git",
"url": "https://github.com/pear/Net_SMTP.git",
"reference": "7b6240761adf6ee245098e238a25d5c35650d82c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pear/Net_SMTP/zipball/7b6240761adf6ee245098e238a25d5c35650d82c",
"reference": "7b6240761adf6ee245098e238a25d5c35650d82c",
"shasum": ""
},
"require": {
"pear/net_socket": "*",
"pear/pear_exception": "*",
"php": ">=4.0.5"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"suggest": {
"pear/auth_sasl": "Install optionally via your project's composer.json"
},
"type": "library",
"autoload": {
"psr-0": {
"Net": "./"
}
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
"./"
],
"license": [
"PHP License"
],
"authors": [
{
"name": "Jon Parise",
"email": "jon@php.net",
"homepage": "http://www.indelible.org",
"role": "Lead"
},
{
"name": "Chuck Hagenbuch",
"email": "chuck@horde.org",
"role": "Lead"
}
],
"description": "An implementation of the SMTP protocol",
"homepage": "http://pear.github.io/Net_SMTP/",
"keywords": [
"email",
"mail",
"smtp"
],
"time": "2015-08-02T17:20:17+00:00"
},
{
"name": "pear/net_socket",
"version": "1.0.14",
"source": {
"type": "git",
"url": "https://github.com/pear/Net_Socket.git",
"reference": "fcd33efd77e4b35ce85489141ab9145343579fe8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pear/Net_Socket/zipball/fcd33efd77e4b35ce85489141ab9145343579fe8",
"reference": "fcd33efd77e4b35ce85489141ab9145343579fe8",
"shasum": ""
},
"require": {
"pear/pear_exception": "*"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"type": "library",
"autoload": {
"psr-0": {
"Net": "./"
}
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
"./"
],
"license": [
"PHP License"
],
"authors": [
{
"name": "Chuck Hagenbuch",
"email": "chuck@horde.org",
"role": "Lead"
},
{
"name": "Aleksander Machniak",
"email": "alec@php.net",
"role": "Lead"
},
{
"name": "Stig Bakken",
"email": "stig@php.net",
"role": "Lead"
}
],
"description": "More info available on: http://pear.php.net/package/Net_Socket",
"time": "2014-02-20T19:27:06+00:00"
},
{
"name": "pear/pear_exception",
"version": "v1.0.0",
......
#!/bin/bash
## Cleanup the vendor tree. The main issue here is that civi Civi is
## deployed as a module inside a CMS, so all its source-code gets published.
## Some libraries distribute admin tools and sample files which should not
## be published.
##
## This script should be idempotent -- if you rerun it several times, it
## should always produce the same post-condition.
## Replace a line in a file
## This is a bit like 'sed -i', but dumber and more cross-platform.
# Add in CiviCRM custom error message for CRM-8744.
if ! grep -q 'CRM-8744' vendor/pear/net_smtp/Net/SMTP.php; then
patch vendor/pear/net_smtp/Net/SMTP.php < tools/scripts/composer/patches/net-smtp-patch.txt
fi
if ! grep -q '@STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT' vendor/pear/net_smtp/Net/SMTP.php; then
patch vendor/pear/net_smtp/Net/SMTP.php < tools/scripts/composer/patches/net-smtp-tls-patch.txt
fi
--- SMTP.php 2017-01-15 05:19:55.000000000 +1100
+++ SMTP.php.new 2017-05-20 09:01:52.832373840 +1000
@@ -368,8 +368,10 @@
return true;
}
- return PEAR::raiseError('Invalid response code received from server',
- $this->_code, PEAR_ERROR_RETURN);
+ // CRM-8744
+ $errorMessage = 'Invalid response code received from SMTP server while sending email. This is often caused by a misconfiguration in Outbound Email settings. Please verify the settings at Administer CiviCRM >> Global Settings >> Outbound Email (SMTP).';
+ return PEAR::raiseError($errorMessage, $this->_code, PEAR_ERROR_RETURN);
+
}
/**
diff --git a/Net/SMTP.php b/Net/SMTP.php
index 28eae8c..8f4e92b 100644
--- a/Net/SMTP.php
+++ b/Net/SMTP.php
@@ -602,7 +602,17 @@
if (PEAR::isError($result = $this->_parseResponse(220))) {
return $result;
}
- if (PEAR::isError($result = $this->_socket->enableCrypto(true, STREAM_CRYPTO_METHOD_TLS_CLIENT))) {
+ if (isset($this->socket_options['ssl']['crypto_method'])) {
+ $crypto_method = $this->socket_options['ssl']['crypto_method'];
+ } else {
+ /* STREAM_CRYPTO_METHOD_TLS_ANY_CLIENT constant does not exist
+ * and STREAM_CRYPTO_METHOD_SSLv23_CLIENT constant is
+ * inconsistent across PHP versions. */
+ $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT
+ | @STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT
+ | @STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
+ }
+ if (PEAR::isError($result = $this->socket->enableCrypto(true, $crypto_method))) {
return $result;
} elseif ($result !== true) {
return PEAR::raiseError('STARTTLS failed');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment