From 767eaec731825f50a6f4b0b5a0c1a66bd27fbd50 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Tue, 5 Jul 2016 14:50:25 +0800 Subject: [PATCH] MDL-51242 messageinbound: Guess the port from hostspec Existing language strings for the host component suggest that the host can be provided in the format hostname:port, but we previously did not support this. This patch explodes the string based on the colon character and assumes that if there are two parts, that they are in the format hostname:port. Note: This does not attempt to deal with full host specifications (e.g. protocol://hostname:port), as this is beyond the scope of this change. --- admin/tool/messageinbound/classes/manager.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/admin/tool/messageinbound/classes/manager.php b/admin/tool/messageinbound/classes/manager.php index 8bb57ac54c1..a352f7c618d 100644 --- a/admin/tool/messageinbound/classes/manager.php +++ b/admin/tool/messageinbound/classes/manager.php @@ -103,6 +103,15 @@ class manager { 'debug' => empty($CFG->debugimap) ? null : fopen('php://stderr', 'w'), ); + if (strpos($configuration['hostspec'], ':')) { + $hostdata = explode(':', $configuration['hostspec']); + if (count($hostdata) === 2) { + // A hostname in the format hostname:port has been provided. + $configuration['hostspec'] = $hostdata[0]; + $configuration['port'] = $hostdata[1]; + } + } + $this->client = new \Horde_Imap_Client_Socket($configuration); try {