Osticket: No attachments in emails for new tickets.

Created on 18 Apr 2016  路  10Comments  路  Source: osTicket/osTicket

Attachments aren't attached to emails on new tickets. Oddly enough, they are working on responses.

Most helpful comment

You can add the files in the email templates with these tokens

%{message.files}
%{response.files}

All 10 comments

possible fix in include/class.ticket.php

@@ -3591,8 +3591,13 @@ static function open($vars, &$errors) {
             else
                 $signature='';

-            $attachments = ($cfg->emailAttachments() && $response)
-                ? $response->getAttachments() : array();
+            $attachments = array();
+            //this is the attachment bug
+            if($tform->getField('message')->getWidget()->getAttachments($cfg)) {
+                $attachments = $ticket->getThread($vars)->getLastMessage()->getAttachments();
+            }elseif($cfg->emailAttachments() && $response) {
+                $attachments = $response->getAttachments();
+            }

@catbadger I'm confused. Ticket creation via email does not go through Ticket::open, which you modified here. It goes through Ticket::create. I don't see how your fix would address the problem you describe.

Ticket::open calls Ticket::create. This fix worked for me. How would you fix it with the offending code being in ticket::open?

@catbadger - Why would you be attaching attachments to a message when you're opening a ticket on behalf of the user? Issue detail is meant to describe the issue. If you want attachments sent to user then you need to attached them to the response.

@protich why would you build it into the interface and not allow it? secondly our support team needs to attach to the ticket, like the UI appears to allow.

@catbadger -- You're missing the point -- you can attach documents, if you wish, but it won't get sent as part of the response. And for your information, you can disable (hide) issue summary and details via help topic setting.

Your proposed change tries to propagate files attached to message as part of response -- that's what I have issues with.

So whats the right way? Care to illustrate with code?

You can add the files in the email templates with these tokens

%{message.files}
%{response.files}

but then there's no code to actually attach the files?

%{message.files} is resolved for email template processing and throws an OOBContent exception to interrupt the template processing and add attachments
https://github.com/osTicket/osTicket/blob/develop/include/class.thread.php#L1099-L1100

and the template variable replacement engine handles the OOBContent by adding the files into the extras array
https://github.com/osTicket/osTicket/blob/develop/include/class.variable.php#L136-L140

at the end of the variable replacement system, TextWithExtras is returned to reflect the HTML content of the template along with the attachments
https://github.com/osTicket/osTicket/blob/develop/include/class.variable.php#L119-L121

and the mailer handles the TextWithExtras object by extracting the HTML text and adding the attachments to the email
https://github.com/osTicket/osTicket/blob/develop/include/class.mailer.php#L424-L432

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lifeofguenter picture lifeofguenter  路  4Comments

extremesurf picture extremesurf  路  3Comments

simonnzg picture simonnzg  路  5Comments

joseaguardia picture joseaguardia  路  4Comments

cervedgroup picture cervedgroup  路  5Comments