From 394dc4b403874a055e84ab5a6cd66ffb084b154e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Nov 2019 19:03:00 +0100 Subject: [PATCH] Try to fix php error with imap_utf7_encode --- .../class/emailcollector.class.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index efdb3ea5d3b..c464e38d4a7 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -683,6 +683,38 @@ class EmailCollector extends CommonObject return $connectstringserver; } + /** + * Convert str to UTF-7 imap default mailbox names + * + * @param string $str String to encode + * @return string Encode string + */ + function getEncodedUtf7($str) { + if (function_exists('mb_convert_encoding')) { + # change spaces by entropy because mb_convert fail with spaces + $str=ereg_replace(" ","xyxy",$str); + # if mb_convert work + if ($str = mb_convert_encoding($str,"UTF-7")) { + # change characters + $str=preg_replace("/\+A/","&A",$str); + # change to spaces again + $str=preg_replace("/xyxy/"," ",$str); + # return encoded string + return $str; + # else + } else { + # print error and return false + echo "error: is not possible to encode this string '$str'.[". + imap_last_error(). + "]"; + return false; + } + } + else { + return $str; + } + } + /** * Action executed by scheduler * CAN BE A CRON TASK. In such a case, paramerts come from the schedule job setup field 'Parameters'