From 3188aee005dd501a37eea4bdf85277938598f574 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 6 Sep 2013 14:49:12 +0000 Subject: [PATCH] Fetch attachments in mail fetch This code was lost when the message-id tracking feature was implemented --- include/class.mailfetch.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php index 57d828274..604950279 100644 --- a/include/class.mailfetch.php +++ b/include/class.mailfetch.php @@ -423,6 +423,25 @@ class MailFetcher { $newticket=true; $errors=array(); + + // Fetch attachments if any. + if($ost->getConfig()->allowEmailAttachments() + && ($struct = imap_fetchstructure($this->mbox, $mid)) + && ($attachments=$this->getAttachments($struct))) { + + $vars['attachments'] = array(); + foreach($attachments as $a ) { + $file = array('name' => $a['name'], 'type' => $a['type']); + + //Check the file type + if(!$ost->isFileTypeAllowed($file)) + $file['error'] = 'Invalid file type (ext) for '.Format::htmlchars($file['name']); + else //only fetch the body if necessary TODO: Make it a callback. + $file['data'] = $this->decode(imap_fetchbody($this->mbox, $mid, $a['index']), $a['encoding']); + $vars['attachments'][] = $file; + } + } + if (($thread = ThreadEntry::lookupByEmailHeaders($vars)) && ($message = $thread->postEmail($vars))) { if ($message === true) -- GitLab