From d5e8cdca9799508b4c887f939ea44d8e3571f8c9 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Wed, 19 Oct 2016 10:01:38 +0000 Subject: [PATCH] rework of fix for problem regarding send with bcc when using esync --- api/src/Mail.php | 11 +++++++---- mail/inc/class.mail_zpush.inc.php | 5 ++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/api/src/Mail.php b/api/src/Mail.php index cb6075d926..9f744e5b99 100644 --- a/api/src/Mail.php +++ b/api/src/Mail.php @@ -6973,10 +6973,9 @@ class Mail * @param Mailer $mailer instance of SMTP Mailer object * @param string|ressource|Horde_Mime_Part $message string or resource containing the RawMessage / object Mail_mimeDecoded message (part)) * @param boolean $force8bitOnPrimaryPart (default false. force transferEncoding and charset to 8bit/utf8 if we have a textpart as primaryPart) - * @param string &$bccAddresses (reference; default empty string; used to transport bcc addresses to the caller) * @throws Exception\WrongParameter when the required Horde_Mail_Part not found */ - function parseRawMessageIntoMailObject(Mailer $mailer, $message, $force8bitOnPrimaryPart=false, &$bccAddresses='') + function parseRawMessageIntoMailObject(Mailer $mailer, $message, $force8bitOnPrimaryPart=false) { if (is_string($message) || is_resource($message)) { @@ -7011,11 +7010,15 @@ class Mail //may be altered when retrieving the message e.g. from server //error_log(__METHOD__.__LINE__.':'.$header.'->'.$val.'<->'.$mailer->getHeader('Content-Transfer-Encoding')); break; + case 'Bcc': + case 'bcc': + //error_log(__METHOD__.__LINE__.':'.$header.'->'.$val); + $mailer->addBcc($val); + break; default: //error_log(__METHOD__.__LINE__.':'.$header.'->'.$val); - if (strtolower($header)=='bcc') $bccAddresses .= $val; $mailer->addHeader($header, $val, $overwrite); - //error_log(__METHOD__.__LINE__.':'.'getHeader('.$header.')'.array2string($mailer->getHeader($header)).(strtolower($header)=='bcc'?$bccAddresses:'')); + //error_log(__METHOD__.__LINE__.':'.'getHeader('.$header.')'.array2string($mailer->getHeader($header))); } } } diff --git a/mail/inc/class.mail_zpush.inc.php b/mail/inc/class.mail_zpush.inc.php index cdba3466ad..51b6a8b4e4 100644 --- a/mail/inc/class.mail_zpush.inc.php +++ b/mail/inc/class.mail_zpush.inc.php @@ -420,8 +420,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, if (Api\Translation::detect_encoding($sigTextPlain)!='ascii') $force8bit=true; // initialize the new Api\Mailer object for sending $mailObject = new Api\Mailer(self::$profileID); - $bccAddresses=''; - $this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime,$force8bit,$bccAddresses); + $this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime,$force8bit); // Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8 $mailObject->Sender = $activeMailProfile['ident_email']; $mailObject->setFrom($activeMailProfile['ident_email'],Mail::generateIdentityString($activeMailProfile,false)); @@ -443,7 +442,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); } // BCC - foreach(Mail::parseAddressList(($bccAddresses?$bccAddresses:$mailObject->getHeader("Bcc"))) as $addressObject) { + foreach($mailObject->getAddresses('bcc') as $addressObject) { if (!$addressObject->valid) continue; ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) ); //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);