Merge pull request #777 from auto-mat/abs-paths1

Don't use file paths when sending emails because they don't work on S3
This commit is contained in:
Garret Wassermann 2019-09-24 19:40:01 -04:00 committed by GitHub
commit 86444e2bc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: