From 474e6fb670a4e642c0d1255d3b279545c217d4b6 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Mon, 18 Nov 2013 13:18:28 -0600 Subject: [PATCH] Fix attachment mishap in outgoing emails The detection of inline images in the mail processor causes inline images to be removed from the attachment list, if listed there. However, the attachments in the attachment list were not keyed by the attachment-id, so there was no proper way to detect and remove the attachments from the list. This patch properly keys the attachment list by the attachment file_id --- include/class.mailer.php | 9 +++++---- include/class.ticket.php | 2 -- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/class.mailer.php b/include/class.mailer.php index 0e89ddad5..a57f8d7be 100644 --- a/include/class.mailer.php +++ b/include/class.mailer.php @@ -78,11 +78,14 @@ class Mailer { } function addAttachment($attachment) { - $this->attachments[] = $attachment; + // XXX: This looks too assuming; however, the attachment processor + // in the ::send() method seems hard coded to expect this format + $this->attachments[$attachment['file_id']] = $attachment; } function addAttachments($attachments) { - $this->attachments = array_merge($this->attachments, $attachments); + foreach ($attachments as $a) + $this->addAttachment($a); } function send($to, $subject, $message, $options=null) { @@ -180,8 +183,6 @@ class Mailer { $mime->addAttachment($file->getData(), $file->getType(), $file->getName(),false); } - elseif($attachment['file'] && file_exists($attachment['file']) && is_readable($attachment['file'])) - $mime->addAttachment($attachment['file'],$attachment['type'],$attachment['name']); } } diff --git a/include/class.ticket.php b/include/class.ticket.php index 21d80ad0b..616656207 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1515,8 +1515,6 @@ class Ticket { if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator())) $msg['body'] = "<p style=\"display:none\">$tag<p>".$msg['body']; - //Set attachments if emailing. - $attachments = $cfg->emailAttachments()?$response->getAttachments():array(); $options = array( 'inreplyto' => $response->getEmailMessageId(), 'references' => $response->getEmailReferences()); -- GitLab