From b661d888ae1a3714e90a1972f3a77c23b41abe89 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Mon, 6 May 2013 14:29:04 +0000 Subject: [PATCH] * API/phpmailer: introduce optional parameter to InlineImageExists, to be able to determine if all attachments are inline, or only some; this will be used to decide on the mimetype of the message to be sent (multipart/ related (all) or mixed (some)) --- phpgwapi/inc/class.phpmailer.inc.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/phpgwapi/inc/class.phpmailer.inc.php b/phpgwapi/inc/class.phpmailer.inc.php index 2cfdd8feac..a2f3a7d074 100644 --- a/phpgwapi/inc/class.phpmailer.inc.php +++ b/phpgwapi/inc/class.phpmailer.inc.php @@ -1236,7 +1236,7 @@ class PHPMailer { break; case 'attachments': case 'alt_attachments': - if($this->InlineImageExists()){ + if($this->InlineImageExists(true)){ $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE); } else { $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); @@ -1968,15 +1968,21 @@ class PHPMailer { /** * Returns true if an inline attachment is present. * @access public + * @param bool $matchall - matchall attachments to decide. Helpful if you want to decide this is a multipart/mixed or multipart/related mail * @return bool */ - public function InlineImageExists() { + public function InlineImageExists($matchall = false) { + $i=0; foreach($this->attachment as $attachment) { if ($attachment[6] == 'inline') { - return true; + if ($matchall) { + $i++; + } else { + return true; + } } } - return false; + return ($matchall?($i===count($this->attachment)):false); } /////////////////////////////////////////////////