Skip to content
Snippets Groups Projects
Commit 2f5a9e89 authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #708 from greezybacon/issue/mail-fetch-attachments


Fetch attachments in mail fetch
Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents fbf3fac0 3188aee0
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment