From b43e60875a3339c57a68a1405f6874d57a5c19a2 Mon Sep 17 00:00:00 2001 From: Timothy Hobbs Date: Wed, 27 Mar 2019 17:38:00 +0100 Subject: [PATCH] Don't use file paths because they don't work on S3 Fixes #721 on develop but not on master --- helpdesk/templated_email.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/helpdesk/templated_email.py b/helpdesk/templated_email.py index ae64aae5..720e9445 100644 --- a/helpdesk/templated_email.py +++ b/helpdesk/templated_email.py @@ -100,13 +100,10 @@ def send_templated_mail(template_name, if files: for filename, filefield in files: - mime = mimetypes.guess_type(filename) - if mime[0] is not None and mime[0] == "text/plain": - with open(filefield.path, 'r') as attachedfile: - content = attachedfile.read() - msg.attach(filename, content) - else: - msg.attach_file(filefield.path) + filefield.open('rb') + content = filefield.read() + msg.attach(filename, content) + filefield.close() logger.debug('Sending email to: {!r}'.format(recipients)) try: