diff --git a/api/src/Mail.php b/api/src/Mail.php index ce205516c6..9b78a7f4e9 100644 --- a/api/src/Mail.php +++ b/api/src/Mail.php @@ -6573,7 +6573,7 @@ class Mail * @param Mailer $_mailObject instance of the Mailer Object to be used * @param string $_html2parse the html to parse and to be altered, if conditions meet * @param $mail_bo mail bo object - * @return void + * @return array|null return inline images stored as tmp file in vfs as array of attachments otherwise null */ static function processURL2InlineImages(Mailer $_mailObject, &$_html2parse, $mail_bo) { @@ -6678,7 +6678,14 @@ class Mail $_html2parse = str_replace($images[0][$i], $images[1][$i].'="'.$cid.'"', $_html2parse); } } + $attachments [] = array( + 'name' => $filename, + 'type' => $mimeType, + 'file' => $attachment_file, + 'tmp_name' => $attachment_file + ); } + return is_array($attachments) ? $attachments : null; } } diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index d9fcdc9aa6..1a60099a1d 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -2226,6 +2226,8 @@ class mail_compose * @param array $_formData * @param array $_identity * @param boolean $_autosaving =false true: autosaving, false: save-as-draft or send + * + * @return array returns found inline images as attachment structure */ function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false) { @@ -2359,7 +2361,7 @@ class mail_compose $_mailObject->setBody($this->convertHTMLToText($body, true, true)); } // convert URL Images to inline images - if possible - if (!$_autosaving) Mail::processURL2InlineImages($_mailObject, $body, $mail_bo); + if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo); if (strpos($body,"")!==false) { $body = str_replace(array('',''),'',$body); @@ -2464,6 +2466,7 @@ class mail_compose } if ($connection_opened) $mail_bo->closeConnection(); } + return is_array($inline_images)?$inline_images:array(); } /** @@ -2826,8 +2829,8 @@ class mail_compose } //error_log($this->sessionData['mailaccount']); //error_log(__METHOD__.__LINE__.':'.array2string($this->sessionData['mailidentity']).'->'.array2string($identity)); - // create the messages - $this->createMessage($mail, $_formData, $identity); + // create the messages and store inline images + $inline_images = $this->createMessage($mail, $_formData, $identity); // remember the identity if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); #print "
". $mail->getMessageHeader() ."


"; @@ -3157,6 +3160,8 @@ class mail_compose if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' ) { + $this->sessionData['attachments'] = array_merge((array)$this->sessionData['attachments'], (array)$inline_images); + foreach(array('to_infolog','to_tracker','to_calendar') as $app_key) { $entryid = $_formData['to_integrate_ids'][0][$app_key];