more finetunig and debug, as of garbled content / contenttypes

This commit is contained in:
Klaus Leithoff 2015-04-30 13:37:20 +00:00
parent 9ce25811e5
commit e2ee8b9771

View File

@ -502,6 +502,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
{
$bodyObj = $mailObject->findBody(preg_match("/html/i", $ContentType) ? 'html' : 'plain');
$body = $bodyObj ?$bodyObj->getContents() : null;
translation::replaceEmailAdresses($body);
$simpleBodyType = (preg_match("/html/i", $ContentType)?'text/html':'text/plain');
if ($this->debugLevel>1) debugLog("IMAP-Sendmail: fetched simple body as ".(preg_match("/html/i", $ContentType)?'html':'text').'=>'.$body);
}
@ -511,6 +512,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
$AltBody = ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null;
// prefer plain over html
$body = $Body ?$Body : $AltBody;
translation::replaceEmailAdresses($body);
if ($this->debugLevel>1) debugLog("IMAP-Sendmail: fetched body as ".(strlen(strip_tags($body)) == strlen($body)?'text':'html').'=>'.$body);
}
//error_log(__METHOD__.__LINE__.array2string($mailObject));
@ -731,18 +733,23 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
//debugLog(__METHOD__.__LINE__.' -> '.$body);
// remove carriage-returns from body, set the body of the mailObject
if (trim($body) =='' /*&& trim($mailObject->getMessageBody())=='' && $attachmentNames*/) $body .= ($attachmentNames?$attachmentNames:lang('no text body supplied, check attachments for message text'));// to avoid failure on empty messages with attachments
//debugLog(__METHOD__.__LINE__.' -> '.$body);
if (preg_match("^text/html^i", $ContentType) || preg_match("^multipart^i", $ContentType))
{
if ($html_body = $mailObject->findBody('html'))
{
if (strlen(strip_tags($body)) == strlen($body)) $body = "<pre>".$body."</pre>";
if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__.' -> '.$body);
$html_body->setContents($body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
}
if ($text_body = $mailObject->findBody('plain')) $text_body->setContents(translation::convertHTMLToText($body),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
if ($text_body = $mailObject->findBody('plain'))
{
if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__.' -> '.translation::convertHTMLToText($body));
$text_body->setContents(translation::convertHTMLToText($body),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
}
}
else
{
if ($this->debugLevel>1) debugLog(__METHOD__.__LINE__.' -> '.translation::convertHTMLToText($body));
if ($text_body = $mailObject->findBody('plain')) $text_body->setContents(translation::convertHTMLToText($body),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING));
}
//advanced debugging