diff --git a/CHANGELOG-1.0.md b/CHANGELOG-1.0.md index 1f312c3..0fd29ac 100644 --- a/CHANGELOG-1.0.md +++ b/CHANGELOG-1.0.md @@ -3,6 +3,11 @@ CHANGELOG for 1.0.x This changelog references any relevant changes introduced in 1.0 minor versions. +* 1.0.2 (2019-10-22) + * **Misc. Updates:** + * Use https when available while refreshing mailboxes via CLI + * Updated README.md with link to the official gitter chat for uvdesk/mailbox-component + * 1.0.1 (2019-10-15) * **Misc. Updates:** * Only users with admin level privileges can configure mailbox settings diff --git a/Console/RefreshMailboxCommand.php b/Console/RefreshMailboxCommand.php index cb61193..21dd648 100644 --- a/Console/RefreshMailboxCommand.php +++ b/Console/RefreshMailboxCommand.php @@ -95,6 +95,8 @@ public function refreshMailbox($server_host, $server_username, $server_password, if (is_array($emailCollection)) { $emailCount = count($emailCollection); + $useSecureConnection = $this->isSecureConnectionAvailable(); + $output->writeln("\n 5. Total fetched email -> $emailCount"); $output->writeln("\n 6. Starting to convert Emails into Tickets -> \n=============================================\n=============================================\n"); $counter = 1; @@ -102,7 +104,7 @@ public function refreshMailbox($server_host, $server_username, $server_password, foreach ($emailCollection as $id => $messageNumber) { $output->writeln("\n Converting email $counter out of $emailCount."); $message = imap_fetchbody($imap, $messageNumber, ""); - $this->pushMessage($message); + $this->pushMessage($message, $useSecureConnection); $counter ++; } @@ -113,24 +115,36 @@ public function refreshMailbox($server_host, $server_username, $server_password, return; } - public function pushMessage($message) + public function pushMessage($message, bool $secure = false) { $router = $this->container->get('router'); $router->getContext()->setHost($this->container->getParameter('uvdesk.site_url')); + $router->getContext()->setScheme(true === $secure ? 'https' : 'http'); $curlHandler = curl_init(); $requestUrl = $router->generate('helpdesk_member_mailbox_notification', [], UrlGeneratorInterface::ABSOLUTE_URL); - if ($this->container->getParameter('uvdesk.site_url') != $router->getContext()->getHost()) { - $requestUrl = str_replace($router->getContext()->getHost(), $this->container->getParameter('uvdesk.site_url'), $requestUrl); - } - curl_setopt($curlHandler, CURLOPT_HEADER, 0); curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlHandler, CURLOPT_POST, 1); curl_setopt($curlHandler, CURLOPT_URL, $requestUrl); curl_setopt($curlHandler, CURLOPT_POSTFIELDS, http_build_query(['email' => $message])); + $curlResponse = curl_exec($curlHandler); curl_close($curlHandler); } + + protected function isSecureConnectionAvailable() + { + $headers = [CURLOPT_NOBODY => true, CURLOPT_HEADER => false]; + $curlHandler = curl_init('https://' . $this->container->getParameter('uvdesk.site_url')); + + curl_setopt_array($curlHandler, $headers); + curl_exec($curlHandler); + + $isSecureRequestAvailable = curl_errno($curlHandler) === 0 ? true : false; + curl_close($curlHandler); + + return $isSecureRequestAvailable; + } } diff --git a/README.md b/README.md index c88775a..590c8a3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,34 @@ # mailbox The Mailbox component provides tools that allows your helpdesk to process tickets from multiple email sources. + +

+ +

+ +

+ Latest Stable Version + Total Downloads + License + connect on gitter +

+ +The **Mailbox** component enables your [UVDesk Community][1] helpdesk to fetch emails from multiple sources and process them into tickets effortlessly. + +Installation +-------------- + +Before installing, make sure that you have [Composer][2] installed. + +To require mailbox-component into your helpdesk project, simply run the following composer command from your project root: + +```bash +$ composer require uvdesk/mailbox-component +``` + +License +-------------- + +The **Mailbox** component and libraries included within the bundle are released under the MIT or BSD license. + +[1]: https://www.uvdesk.com/ +[2]: https://getcomposer.org/ \ No newline at end of file