Hey osTicket-members,
I began using osTicket and I rly love it, cause it's not that oversized like other systems and it's opensource!
I usually sign my mails with S/MIME or PGP and was confused when the attachments didn't show up in the Ticket.
So I analysed the Code and noticed that the mails are 'scanned' and the attachments are excluded and saved. But this is a simple for-loop which scans for every attachment but not for every mailpart.
If you attach a mail to another mail and attach a file to the inner mail it won't be recognized by osTicket.
So I wrote a recursion which scans for every available mailpart it in it for attachments.
So S/MIME signed mails with attachments will be recognized as well.
I created a patch (attachted to this post) and I quote the changed code here again:
Open $Document_Root/api/pipe.php
find the following code (at the very end)
//Ticket created...save attachments if enabled.
$struct=$parser->getStruct();
if($struct && $struct->parts && $cfg->allowEmailAttachments()) {
for($i = 0; $i < count($struct->parts); $i++) {
$part=$struct->parts;
if($part->disposition
&& (!strcasecmp($part->disposition,'attachment') || !strcasecmp($part->disposition,'inline') || !strcasecmp($part->ctype_primary,'image'))){
$filename=$part->d_parameters;
if($filename && $cfg->canUploadFileType($filename)) {
$ticket->saveAttachment($filename,$part->body,$msgid,'M');
}
}
}
}
//print_r($var);
api_exit(EX_SUCCESS);
and replace it by this:
//Ticket created...save attachments if enabled.
$struct=$parser->getStruct();
if($struct && $struct->parts && $cfg->allowEmailAttachments()) {
$parts = $struct->parts;
getparts($parts, $cfg, $ticket, $msgid);
}
//Function has to be recursive, cause a mail can have multiple nested parts
//There is rly no need to check the depth of the recursion (how many parts will be there dude?)
function getparts($parts, $cfg, $ticket, $msgid) {
for($i = 0; $i < count($parts); $i++) {
$part = $parts;
if($part->parts) { getparts($part->parts, $cfg, $ticket, $msgid); }
if($part->disposition
&& (!strcasecmp($part->disposition, 'attachment') || !strcasecmp($part->disposition, 'inline') || !strcasecmp($part->ctype_primary, 'image'))) {
$filename=$part->d_parameters;
if($filename && $cfg->canUploadFileType($filename)) {
$ticket->saveAttachment($filename, $part->body, $msgid, 'M');
}
}
}
}
//print_r($var);
api_exit(EX_SUCCESS);
Would be nice if this fix could be considered to be used in the next release.
Greets,
HagRic.de - it-solutions
[pipe.patch.txt](https://forum.osticket.com/assets/files/migrated/c/1a6e628a507d9b2881b958a6334fb22.txt)