* Mail: fix problem regarding send with bcc when using esync

This commit is contained in:
Klaus Leithoff 2016-10-18 13:59:32 +00:00
parent 57201d51bc
commit c47d8a26c3
2 changed files with 10 additions and 8 deletions

View File

@ -6974,9 +6974,10 @@ class Mail
* @param Mailer $mailer instance of SMTP Mailer object * @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 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 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 * @throws Exception\WrongParameter when the required Horde_Mail_Part not found
*/ */
function parseRawMessageIntoMailObject(Mailer $mailer, $message, $force8bitOnPrimaryPart=false) function parseRawMessageIntoMailObject(Mailer $mailer, $message, $force8bitOnPrimaryPart=false, &$bccAddresses='')
{ {
if (is_string($message) || is_resource($message)) if (is_string($message) || is_resource($message))
{ {
@ -7013,7 +7014,9 @@ class Mail
break; break;
default: default:
//error_log(__METHOD__.__LINE__.':'.$header.'->'.$val); //error_log(__METHOD__.__LINE__.':'.$header.'->'.$val);
if (strtolower($header)=='bcc') $bccAddresses .= $val;
$mailer->addHeader($header, $val, $overwrite); $mailer->addHeader($header, $val, $overwrite);
//error_log(__METHOD__.__LINE__.':'.'getHeader('.$header.')'.array2string($mailer->getHeader($header)).(strtolower($header)=='bcc'?$bccAddresses:''));
} }
} }
} }

View File

@ -436,17 +436,15 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
if (Api\Translation::detect_encoding($sigTextPlain)!='ascii') $force8bit=true; if (Api\Translation::detect_encoding($sigTextPlain)!='ascii') $force8bit=true;
// initialize the new Api\Mailer object for sending // initialize the new Api\Mailer object for sending
$mailObject = new Api\Mailer(self::$profileID); $mailObject = new Api\Mailer(self::$profileID);
$bccAddresses='';
$this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime,$force8bit); $this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime,$force8bit,$bccAddresses);
// Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8 // Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8
$mailObject->Sender = $activeMailProfile['ident_email']; $mailObject->Sender = $activeMailProfile['ident_email'];
$mailObject->setFrom($activeMailProfile['ident_email'],Mail::generateIdentityString($activeMailProfile,false)); $mailObject->setFrom($activeMailProfile['ident_email'],Mail::generateIdentityString($activeMailProfile,false));
$mailObject->addHeader('X-Mailer', 'mail-Activesync'); $mailObject->addHeader('X-Mailer', 'mail-Activesync');
// prepare addressee list; moved the adding of addresses to the mailobject down // prepare addressee list; moved the adding of addresses to the mailobject down
// to // to
foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) {
if (!$addressObject->valid) continue; if (!$addressObject->valid) continue;
ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) ); ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) );
@ -461,7 +459,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
$ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
} }
// BCC // BCC
foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { foreach(Mail::parseAddressList(($bccAddresses?$bccAddresses:$mailObject->getHeader("Bcc"))) as $addressObject) {
if (!$addressObject->valid) continue; if (!$addressObject->valid) continue;
ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) ); ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) );
//$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal);
@ -802,8 +800,9 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
$mailAddr[] = array($emailAddress, $addressObject->personal); $mailAddr[] = array($emailAddress, $addressObject->personal);
} }
} }
$BCCmail=''; //$BCCmail='';
if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); if (count($mailAddr)>0) $mailObject->forceBccHeader();
//$BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr);
foreach($folderArray as $folderName) { foreach($folderArray as $folderName) {
if($this->mail->isSentFolder($folderName)) { if($this->mail->isSentFolder($folderName)) {
$flags = '\\Seen'; $flags = '\\Seen';