Don't use file paths because they don't work on S3

Fixes #721 on develop but not on master
This commit is contained in:
Timothy Hobbs 2019-03-27 17:38:00 +01:00
parent 7f27eb9428
commit b43e60875a

View File

@ -100,13 +100,10 @@ def send_templated_mail(template_name,
if files: if files:
for filename, filefield in files: for filename, filefield in files:
mime = mimetypes.guess_type(filename) filefield.open('rb')
if mime[0] is not None and mime[0] == "text/plain": content = filefield.read()
with open(filefield.path, 'r') as attachedfile:
content = attachedfile.read()
msg.attach(filename, content) msg.attach(filename, content)
else: filefield.close()
msg.attach_file(filefield.path)
logger.debug('Sending email to: {!r}'.format(recipients)) logger.debug('Sending email to: {!r}'.format(recipients))
try: try: