From 82f81ccafabf8e61ba759f9de887f4163d53fab1 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Thu, 26 May 2011 16:34:25 +0000 Subject: [PATCH] make sure AltBody is only added if there is an AltBody present; control messageType regard AltExtended too --- phpgwapi/inc/class.phpmailer.inc.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/phpgwapi/inc/class.phpmailer.inc.php b/phpgwapi/inc/class.phpmailer.inc.php index 5c6cec06cf..52161e9191 100644 --- a/phpgwapi/inc/class.phpmailer.inc.php +++ b/phpgwapi/inc/class.phpmailer.inc.php @@ -1268,9 +1268,12 @@ class PHPMailer { switch($this->message_type) { case 'alt': - $body .= $this->GetBoundary($this->boundary[1], '', $this->AltBodyContentType, ''); // may be set by client, defaults to text/plain - $body .= $this->EncodeString($this->AltBody, $this->Encoding); - $body .= $this->LE.$this->LE; + if (!empty($this->AltBody)) + { + $body .= $this->GetBoundary($this->boundary[1], '', $this->AltBodyContentType, ''); // may be set by client, defaults to text/plain + $body .= $this->EncodeString($this->AltBody, $this->Encoding); + $body .= $this->LE.$this->LE; + } $body .= $this->GetBoundary($this->boundary[1], '', $this->BodyContentType, ''); //is dependent on IsHTML $body .= $this->EncodeString($this->Body, $this->Encoding); $body .= $this->LE.$this->LE; @@ -1294,10 +1297,13 @@ class PHPMailer { case 'alt_attachments': $body .= sprintf("--%s%s", $this->boundary[1], $this->LE); $body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE); - $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body - $body .= $this->EncodeString($this->AltBody, $this->Encoding); - $body .= $this->LE.$this->LE; - $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body + if (!empty($this->AltBody)) + { + $body .= $this->GetBoundary($this->boundary[2], '', $this->AltBodyContentType, '') . $this->LE; // Create text body + $body .= $this->EncodeString($this->AltBody, $this->Encoding); + $body .= $this->LE.$this->LE; + } + $body .= $this->GetBoundary($this->boundary[2], '', $this->BodyContentType, '') . $this->LE; // Create the HTML body $body .= $this->EncodeString($this->Body, $this->Encoding); $body .= $this->LE.$this->LE; if (!empty($this->AltExtended)) @@ -1387,7 +1393,7 @@ class PHPMailer { * @return void */ public function SetMessageType() { - if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) { + if(count($this->attachment) < 1 && strlen($this->AltBody) < 1 && strlen($this->AltExtended) < 1) { $this->message_type = 'plain'; } else { if(count($this->attachment) > 0) {