Modifying email notifications with plugin adding attachments
Posted: 20 Oct 2023, 11:13
The task
When assigning a user to a bug the notification email MUST contain the bug's attachments of type image
The reason
Workers in the field get their tasks by assigning bugs to them. They are craftsmen equiped with mobile phones and actually never access the MantisBT system. Their respective users are just dummys with valid email addresses to be able to forward the task to them
The solution approaches
1) I wrote a plugin hooking to EVENT_DISPLAY_EMAIL which reads the attachments from the database via file_api, converts them into base64 encoded email attachments, creates the appropriate attachment structure and appends it to the message text provided to the hook function. This kind of works: my string is inserted into the mail correctly but it cannot work since the mail itself ist not flagged as multipart.
Question: Is there any other event I am not aware of (I've read the Developers guide thoroughly) which gives deeper access to the notification email's structure? I'd actually create it myself completely. Maybe I look the wrong way and there is some other solution approach I don't see yet.
2) I wrote a plugin hooking to EVENT_DISPLAY_EMAIL which inserts valid URLs pointing to the attachments located in a publicly acessible folder on the webserver. The links are inserted into the notification email and can be clicked. The browser opens and the image should be displayed in the browser. Unfortunately, the files in Mantis' upload folder lose their file extension when being renamed by the file_api. Due to the HTTP header configuration of the webserver - which is not under my administrative control - the browser downloads the file immediately instead of displaying it. If I append an appropriate file extension to the attachment files on the disk the browser shows the image instead of downloading it.
Question: Is there any chance to modify the behavior of the file_api generating the file names by means of a plugin? Maybe via the EVENT_REPORT_BUG hook? Are the attachment filenames accessible and persistently modifyable from there?
When assigning a user to a bug the notification email MUST contain the bug's attachments of type image
The reason
Workers in the field get their tasks by assigning bugs to them. They are craftsmen equiped with mobile phones and actually never access the MantisBT system. Their respective users are just dummys with valid email addresses to be able to forward the task to them
The solution approaches
1) I wrote a plugin hooking to EVENT_DISPLAY_EMAIL which reads the attachments from the database via file_api, converts them into base64 encoded email attachments, creates the appropriate attachment structure and appends it to the message text provided to the hook function. This kind of works: my string is inserted into the mail correctly but it cannot work since the mail itself ist not flagged as multipart.
Question: Is there any other event I am not aware of (I've read the Developers guide thoroughly) which gives deeper access to the notification email's structure? I'd actually create it myself completely. Maybe I look the wrong way and there is some other solution approach I don't see yet.
2) I wrote a plugin hooking to EVENT_DISPLAY_EMAIL which inserts valid URLs pointing to the attachments located in a publicly acessible folder on the webserver. The links are inserted into the notification email and can be clicked. The browser opens and the image should be displayed in the browser. Unfortunately, the files in Mantis' upload folder lose their file extension when being renamed by the file_api. Due to the HTTP header configuration of the webserver - which is not under my administrative control - the browser downloads the file immediately instead of displaying it. If I append an appropriate file extension to the attachment files on the disk the browser shows the image instead of downloading it.
Question: Is there any chance to modify the behavior of the file_api generating the file names by means of a plugin? Maybe via the EVENT_REPORT_BUG hook? Are the attachment filenames accessible and persistently modifyable from there?